进行了一些小优化

This commit is contained in:
2026-08-30 21:48:59 +08:00
parent a73fa9a6c0
commit 71444b139a
12 changed files with 280 additions and 147 deletions
+21 -12
View File
@@ -359,17 +359,30 @@ final class WidgetSchemas {
['id' => 'orderby', 'type' => 'select', 'label' => '排序', 'default' => 'registered', 'options' => ['registered' => '注册时间', 'display_name' => '名称', 'post_count' => '文章数', 'points' => '积分', 'followers' => '粉丝']],
];
}
$fields = [
['id' => 'show_cover', 'type' => 'switcher', 'label' => '显示封面', 'default' => true],
['id' => 'show_posts', 'type' => 'switcher', 'label' => '显示文章', 'default' => $slug === 'author_card'],
['id' => 'show_buttons', 'type' => 'switcher', 'label' => '显示快捷按钮', 'default' => true],
['id' => 'primary_action', 'type' => 'select', 'label' => '主按钮', 'default' => 'submit', 'options' => self::user_actions()],
['id' => 'secondary_action', 'type' => 'select', 'label' => '次按钮', 'default' => 'home', 'options' => self::user_actions()],
$button_fields = [
['id' => 'show_button', 'type' => 'switcher', 'label' => '显示按钮', 'description' => $slug === 'user_card' ? '登录后才会显示' : '当登录用户就是文章作者的时候才会显示', 'default' => true],
['id' => 'button_1', 'type' => 'radio', 'label' => '按钮1类型', 'default' => 'post', 'options' => ['post' => '文章投稿'], 'dependency' => ['show_button', '!=', '']],
['id' => 'button_1_class', 'type' => 'palette', 'label' => '按钮1颜色', 'default' => 'jb-pink', 'options' => self::zib_palette(), 'dependency' => ['show_button', '!=', '']],
['id' => 'button_1_text', 'type' => 'text', 'label' => '按钮1文字', 'default' => '发布文章', 'dependency' => ['show_button', '!=', '']],
['id' => 'button_2', 'type' => 'radio', 'label' => '按钮2类型', 'default' => 'center', 'options' => ['home' => '个人主页', 'center' => '用户中心'], 'dependency' => ['show_button', '!=', '']],
['id' => 'button_2_class', 'type' => 'palette', 'label' => '按钮2颜色', 'default' => 'jb-blue', 'options' => self::zib_palette(), 'dependency' => ['show_button', '!=', '']],
['id' => 'button_2_text', 'type' => 'text', 'label' => '按钮2文字', 'default' => '用户中心', 'dependency' => ['show_button', '!=', '']],
];
if ($slug === 'user_card') {
$fields[] = ['id' => 'loged_title', 'type' => 'text', 'label' => '未登录文案', 'default' => 'Hi!请登录'];
return [
['id' => 'show_img_bg', 'type' => 'switcher', 'label' => '显示封面', 'default' => true],
['id' => 'loged_title', 'type' => 'text', 'label' => '未登录的文案', 'default' => 'HI!请登录'],
...$button_fields,
];
}
return $fields;
return [
['id' => 'show_img_bg', 'type' => 'switcher', 'label' => '显示封面', 'default' => true],
['id' => 'show_posts', 'type' => 'switcher', 'label' => '显示文章', 'default' => true],
['id' => 'post_style', 'type' => 'radio', 'label' => '显示样式', 'default' => 'mini', 'options' => ['mini' => '简约风格', 'card' => '图文卡片'], 'dependency' => ['show_posts', '!=', '']],
['id' => 'limit', 'type' => 'spinner', 'label' => '显示数量', 'default' => 6, 'min' => 2, 'max' => 12, 'step' => 1, 'unit' => '篇', 'dependency' => ['show_posts', '!=', '']],
['id' => 'orderby', 'type' => 'select', 'label' => '排序方式', 'default' => 'date', 'options' => ['modified' => '最近更新', 'date' => '最新发布', 'views' => '最多浏览', 'like' => '最多点赞', 'comment_count' => '最多评论', 'favorite' => '最多收藏', 'rand' => '随机'], 'dependency' => ['show_posts', '!=', '']],
...$button_fields,
];
}
private static function icon_cards_fields(): array {
@@ -474,8 +487,4 @@ final class WidgetSchemas {
private static function pay_types(): array {
return ['' => '全部', 'reading' => '付费阅读', 'download' => '付费下载', 'gallery' => '付费图库', 'video' => '付费视频', 'vip' => 'VIP 专属'];
}
private static function user_actions(): array {
return ['home' => '个人主页', 'submit' => '前台投稿', 'vip' => '会员中心', 'orders' => '订单中心', 'recharge' => '余额充值', 'signin' => '签到'];
}
}