fix(float): inline panel warnings, drop add-button type picker, mirror reference more-button defaults

This commit is contained in:
2026-09-26 21:01:55 +08:00
parent 6f2adfaef1
commit eb14c4afd3
5 changed files with 106 additions and 92 deletions
@@ -5,6 +5,9 @@
<i class="fa fas fa-arrows-alt-v" />
</button>
<strong class="float-btn-panel__title">{{ meta.title }}</strong>
<span v-if="meta.warn" class="float-btn-panel__warn">
<i class="fa fas fa-info-circle" /> {{ meta.warn }}
</span>
<template v-if="modelValue.type !== 'more'">
<n-tag v-if="modelValue.pc_s" size="small" type="info" :bordered="false">PC</n-tag>
<n-tag v-if="modelValue.m_s" size="small" type="warning" :bordered="false">移动</n-tag>
@@ -14,10 +17,6 @@
<i class="fa fas float-btn-panel__arrow" :class="expanded ? 'fa-angle-up' : 'fa-angle-down'" />
</div>
<div v-if="meta.warn" class="float-btn-panel__warn">
<i class="fa fas fa-info-circle" /> {{ meta.warn }}
</div>
<div v-show="expanded" class="float-btn-panel__body">
<div class="float-btn-panel__subtitle">{{ meta.panel }}</div>
@@ -35,23 +34,9 @@
<n-input :value="modelValue.desc" @update:value="patch({ desc: $event })" />
</n-form-item>
<template v-if="modelValue.type === 'add'">
<n-form-item label="选择按钮">
<div class="float-btn-panel__block">
<n-select
:value="modelValue.btns"
:options="ADD_BTN_OPTIONS"
multiple
placeholder="请选择按钮"
@update:value="patch({ btns: $event })"
/>
<div class="float-btn-panel__desc">选择并排序按钮,未开启的功能不会显示</div>
</div>
</n-form-item>
<n-form-item label="按钮图标">
<n-form-item v-if="modelValue.type === 'add'" label="按钮图标">
<FaIconPicker v-model="addIcon" placeholder="选择图标" />
</n-form-item>
</template>
<n-form-item v-if="modelValue.type === 'service_qq'" label="QQ号码">
<n-input :value="modelValue.qq" placeholder="仅填写数字" @update:value="patch({ qq: $event })" />
@@ -76,7 +61,7 @@ import FaIconPicker from '@/components/form/FaIconPicker.vue'
import AksMediaField from '@/components/form/AksMediaField.vue'
import FloatBtnCommonFields from './FloatBtnCommonFields.vue'
import FloatMoreButtonsEditor from './FloatMoreButtonsEditor.vue'
import { ADD_BTN_OPTIONS, FLOAT_BTN_META } from './floating-defaults.js'
import { FLOAT_BTN_META } from './floating-defaults.js'
const props = defineProps({
modelValue: { type: Object, required: true },
@@ -135,9 +120,12 @@ function patch(partial) {
}
.float-btn-panel__warn {
padding: 0 14px 10px 48px;
font-size: 12px;
color: #f0a020;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
min-width: 0;
}
.float-btn-panel__body {
@@ -16,9 +16,32 @@ export const FLOAT_BTN_META = {
more: { title: '更多按钮', panel: '添加更多自定义按钮' },
}
/** 发布按钮可选项。 */
export const ADD_BTN_OPTIONS = [{ label: '文章投稿', value: 'post' }]
const themeUri = (window.aksrtAdminData?.themeUri || '').replace(/\/$/, '')
/** 「更多按钮」出厂默认项(对齐参考主题 float_btn.more 默认值)。 */
export function giftMoreButton() {
return {
desc: '本站同款主题模板',
icon: 'zibsvg-gift-color',
link: { url: '', target: '' },
hover: `<a href="https://www.zibll.com/" target="_blank">
<div class="flex c-red">
<img class="flex0" alt="zibll子比主题" src="${themeUri}/assets/img/logo.png" height="30">
<div class="flex1 ml10">
<dt>本站同款主题模板</dt>
<div class="px12 mt10 muted-color">zibll子比主题是一款漂亮优雅的网站主题模板,功能强大,配置简单。</div>
<div class="but mt10 p2-10 c-blue btn-block px12">查看详情</div>
</div>
</div>
</a>`,
hover_width: 240,
pc_s: true,
m_s: true,
color: { color: '', bg: 'rgba(255, 111, 6, 0.2)' },
}
}
/** 「添加按钮」新增项默认值(参考主题 group 字段默认值)。 */
export function defaultMoreButton() {
return {
desc: '',
@@ -26,17 +49,17 @@ export function defaultMoreButton() {
link: { url: '', target: '' },
hover: '',
hover_width: 200,
pc_s: false,
m_s: false,
color: { color: '', bg: 'rgba(255, 111, 6, 0.2)' },
pc_s: true,
m_s: true,
color: { color: '', bg: '' },
}
}
export function defaultItems() {
return [
{ type: 'more', buttons: [defaultMoreButton()] },
{ type: 'more', buttons: [giftMoreButton()] },
{ type: 'pay_vip', pc_s: true, m_s: true, color: { color: '#f2c97d', bg: 'rgba(62,62,67,0.9)' } },
{ type: 'add', pc_s: true, m_s: false, color: emptyColor(), btns: ['post'], icon: 'fa fas fa-pencil-alt' },
{ type: 'add', pc_s: true, m_s: false, color: emptyColor(), icon: 'fa fas fa-pencil-alt' },
{ type: 'service_qq', pc_s: false, m_s: false, color: emptyColor(), qq: '' },
{ type: 'service_wechat', pc_s: true, m_s: true, color: emptyColor(), wechat_img: '' },
{ type: 'theme_mode', pc_s: false, m_s: false, color: emptyColor() },
+9 -22
View File
@@ -71,41 +71,27 @@ endif;
if (!function_exists('aksrt_get_float_add_html')) :
/**
* 发布按钮:单项直接链接;多项 hover 下拉 .drop-newadd。
*
* @param string[] $types
* 发布按钮:当前仅文章投稿,对应参考主题单按钮分支(直接链接)。
*/
function aksrt_get_float_add_html(array $types, string $icon, string $style): string {
if (!$types || !function_exists('aksrt_get_new_add_actions')) {
function aksrt_get_float_add_html(string $icon, string $style, bool $is_mobile): string {
if (!function_exists('aksrt_get_new_add_actions')) {
return '';
}
if (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::close_sign()) {
return '';
}
$actions = aksrt_get_new_add_actions($types);
$actions = aksrt_get_new_add_actions(['post']);
if (!$actions) {
return '';
}
$a = $actions[0];
$icon_html = $icon !== '' ? aksrt_icon_markup($icon) : '';
if ($icon_html === '') {
$icon_html = '<i class="fa fas fa-plus" aria-hidden="true"></i>';
}
if (count($actions) === 1) {
$a = $actions[0];
return '<a' . $style . ' rel="nofollow" class="newadd-btns float-btn add-btn" title="' . esc_attr($a['label']) . '" href="' . esc_url($a['url']) . '">' . $icon_html . '</a>';
}
$btns = '';
foreach ($actions as $a) {
$btns .= '<a rel="nofollow" class="btn-newadd" href="' . esc_url($a['url']) . '">'
. '<icon class="jb-green">' . aksrt_icon_markup((string) $a['icon']) . '</icon>'
. '<text>' . esc_html($a['label']) . '</text></a>';
}
return '<span' . $style . ' class="newadd-btns hover-show float-btn add-btn">' . $icon_html
. '<div class="hover-show-con dropdown-menu drop-newadd">' . $btns . '</div></span>';
return '<a' . $style . ' rel="nofollow" class="newadd-btns float-btn add-btn"' . aksrt_float_btn_tooltip_attr((string) $a['label'], $is_mobile) . ' href="' . esc_url($a['url']) . '">' . $icon_html . '</a>';
}
endif;
@@ -185,7 +171,7 @@ if (!function_exists('aksrt_float_right')) :
switch ($type) {
case 'theme_mode':
$btn .= '<a' . $style . ' class="float-btn toggle-theme hover-show"' . aksrt_float_btn_tooltip_attr(__('切换主题', 'aksrt'), $is_mobile) . ' href="javascript:;"><i class="fa fa-toggle-theme"></i></a>';
$btn .= '<a' . $style . ' class="float-btn toggle-theme hover-show"' . aksrt_float_btn_tooltip_attr(__('切换主题', 'aksrt'), $is_mobile) . ' href="javascript:;"><i class="fa fas fa-toggle-theme"></i></a>';
break;
case 'back_top':
@@ -224,7 +210,8 @@ if (!function_exists('aksrt_float_right')) :
break;
case 'add':
$btn .= aksrt_get_float_add_html((array) ($opt['btns'] ?? []), (string) ($opt['icon'] ?? ''), $style);
// 当前仅支持文章投稿,发布类型固定为 post。
$btn .= aksrt_get_float_add_html((string) ($opt['icon'] ?? ''), $style, $is_mobile);
break;
case 'more':
+34 -19
View File
@@ -18,9 +18,6 @@ class FloatButtons {
/** 固定按钮类型(默认显示顺序)。 */
public const TYPES = ['more', 'pay_vip', 'add', 'service_qq', 'service_wechat', 'theme_mode', 'qrcode', 'back_top'];
/** 发布按钮可选类型。 */
public const ADD_BTNS = ['post'];
/**
* 默认配置。
*/
@@ -35,10 +32,10 @@ class FloatButtons {
'items' => [
[
'type' => 'more',
'buttons' => [self::default_more_button()],
'buttons' => [self::gift_more_button()],
],
['type' => 'pay_vip', 'pc_s' => true, 'm_s' => true, 'color' => ['color' => '#f2c97d', 'bg' => 'rgba(62,62,67,0.9)']],
['type' => 'add', 'pc_s' => true, 'm_s' => false, 'color' => $empty_color, 'btns' => ['post'], 'icon' => 'fa fas fa-pencil-alt'],
['type' => 'add', 'pc_s' => true, 'm_s' => false, 'color' => $empty_color, 'icon' => 'fa fas fa-pencil-alt'],
['type' => 'service_qq', 'pc_s' => false, 'm_s' => false, 'color' => $empty_color, 'qq' => ''],
['type' => 'service_wechat', 'pc_s' => true, 'm_s' => true, 'color' => $empty_color, 'wechat_img' => ''],
['type' => 'theme_mode', 'pc_s' => false, 'm_s' => false, 'color' => $empty_color],
@@ -49,18 +46,44 @@ class FloatButtons {
}
/**
* 默认「更多按钮」子项。
* 「更多按钮」出厂默认项(对齐参考主题 float_btn.more 默认值)。
*/
public static function default_more_button(): array {
public static function gift_more_button(): array {
$img = get_template_directory_uri() . '/assets/img/logo.png';
return [
'desc' => '本站同款主题模板',
'icon' => 'zibsvg-gift-color',
'link' => ['url' => '', 'target' => ''],
'hover' => '<a href="https://www.zibll.com/" target="_blank">
<div class="flex c-red">
<img class="flex0" alt="zibll子比主题" src="' . esc_url($img) . '" height="30">
<div class="flex1 ml10">
<dt>本站同款主题模板</dt>
<div class="px12 mt10 muted-color">zibll子比主题是一款漂亮优雅的网站主题模板,功能强大,配置简单。</div>
<div class="but mt10 p2-10 c-blue btn-block px12">查看详情</div>
</div>
</div>
</a>',
'hover_width' => 240,
'pc_s' => true,
'm_s' => true,
'color' => ['color' => '', 'bg' => 'rgba(255, 111, 6, 0.2)'],
];
}
/**
* 「添加按钮」新增项默认值(参考主题 group 字段默认值)。
*/
public static function new_more_button(): array {
return [
'desc' => '',
'icon' => 'fa fas fa-heart',
'link' => ['url' => '', 'target' => ''],
'hover' => '',
'hover_width' => 200,
'pc_s' => false,
'm_s' => false,
'color' => ['color' => '', 'bg' => 'rgba(255, 111, 6, 0.2)'],
'pc_s' => true,
'm_s' => true,
'color' => ['color' => '', 'bg' => ''],
];
}
@@ -139,7 +162,7 @@ class FloatButtons {
}
// 参考主题:至少保留一个。
if ($buttons === []) {
$buttons[] = self::default_more_button();
$buttons[] = self::new_more_button();
}
return ['type' => 'more', 'buttons' => $buttons];
}
@@ -153,14 +176,6 @@ class FloatButtons {
switch ($type) {
case 'add':
$btns = [];
foreach ((array) ($item['btns'] ?? []) as $btn) {
$btn = (string) $btn;
if (in_array($btn, self::ADD_BTNS, true) && !in_array($btn, $btns, true)) {
$btns[] = $btn;
}
}
$out['btns'] = $btns;
$out['icon'] = aksrt_sanitize_icon_value((string) ($item['icon'] ?? ''));
break;
case 'service_qq':
+22 -21
View File
@@ -1,5 +1,5 @@
{
"generated_at": "2026-09-26T12:42:35+00:00",
"generated_at": "2026-09-26T12:59:57+00:00",
"errors": [],
"warnings": [
"customPage tools-update section 'tools/update' not in PHP schema (ok if pure operational page)",
@@ -62,7 +62,7 @@
"info": [
"PHP schema domains: global, page_display, post_list, permissions, users, payment, extensions, tools, ExtensionsAudit, ExtensionsIP, ExtensionsPush, ToolsBackup, ToolsHealth, ToolsImportExport",
"Menu pages discovered: 60",
"admin build ok; chunks=30"
"admin build ok; chunks=31"
],
"domains": {
"global": {
@@ -232,36 +232,37 @@
"entry": true,
"missing_chunks": [],
"chunks": [
"SchemaPage.DXZIPvzD.js",
"SchemaPage.raPtoAxi.js",
"vendor-vue.BYzo-2I-.js",
"FaIcon.B3OOcphx.js",
"FaIconPicker.DHrC0Y72.js",
"shared-api.BvxssbgC.js",
"FaIconPicker.ZNRF6_J7.js",
"shared-api.D5VInyXf.js",
"AksMediaField.DTi5-IR5.js",
"vendor-misc.buu8cFA9.js",
"level.E3ANSDAX.js",
"badge.CKTsmH1z.js",
"vendor-naive.D3KCxD1U.js",
"DeferredPage.BR2FUrUF.js",
"NativeOpsRedirect.DMOc4MZt.js",
"FloatingButtonsSettings.ChAj9F5j.js",
"FloatingButtonsSettings.CbTzuMvj.js",
"vendor-draggable.YNevSrwY.js",
"PageHeader.jmNZVzHG.js",
"FooterTabbarSettings.CwSsjNlJ.js",
"PostPageSettings.D7aU7Dv6.js",
"CommentSettings.CyFC7ABH.js",
"PermissionsCapabilities.BeLUij9c.js",
"CmsCredits.CTDJTkG-.js",
"ThemeInfoPage.CbJKzVFa.js",
"FooterTabbarSettings.BFZnXJRS.js",
"PostPageSettings.CV4lCwlK.js",
"CommentSettings.DINI9YV7.js",
"PermissionsCapabilities.Dwo7ED9D.js",
"CmsCredits.BeYe9Q4u.js",
"ThemeInfoPage.BEUFF9-H.js",
"ThemeAuthorizationPage.DqXs-wcM.js",
"DocsPage.0VHAQOLD.js",
"UsersVerify.BwpKCOcv.js",
"UsersLevel.BOBrM4ao.js",
"UsersBadge.BoxXBYpU.js",
"UsersWechatTemplate.CEr5O4Ax.js",
"ToolsImportExport.CAIX07JQ.js",
"ToolsHealth.DAW9Zcoi.js",
"ToolsUpdate.DlvVMvXs.js",
"ExtensionAI.CJ_ZQ8Tr.js"
"DocsPage.C9brbZ0-.js",
"UsersVerify.DF6GIMJm.js",
"UsersLevel.r4FMbDJx.js",
"UsersBadge.DQwTkMyA.js",
"UsersWechatTemplate.-k8FkSa8.js",
"ToolsImportExport.BcC8WeEX.js",
"ToolsHealth.pQpCqHX1.js",
"ToolsUpdate.Dl-oC250.js",
"ExtensionAI.B5qc_0CR.js"
]
}
}