diff --git a/inc/helpers/menu-decoration.php b/inc/helpers/menu-decoration.php index 61700bd5..a3c34472 100644 --- a/inc/helpers/menu-decoration.php +++ b/inc/helpers/menu-decoration.php @@ -45,20 +45,30 @@ function aksrt_get_menu_item_decoration($menu_item): array { } /** - * @param string $icon_class FA5 icon class. + * @param string $icon_class Icon-picker value (FA5 class, zibsvg- or customsvg-). * @param bool $enabled Global switch. */ function aksrt_render_menu_icon(string $icon_class, bool $enabled = true): string { if (!$enabled || $icon_class === '') { return ''; } + + // Sprite/inline values must reach aksrt_icon_markup untouched — the legacy + // fa-prefix padding below would corrupt them (zibsvg-hot → fa fas fa-zibsvg-hot). + if (str_starts_with($icon_class, 'zibsvg-')) { + return aksrt_icon_markup($icon_class, 'icon mr3 menu-item-icon'); + } + if (str_starts_with($icon_class, 'customsvg-')) { + return aksrt_icon_markup($icon_class, 'mr3 menu-item-icon'); + } + // legacy uses the Font Awesome 5 `fa` prefix. if (strpos($icon_class, 'fa') === false) { $icon_class = 'fa fas fa-' . ltrim($icon_class, '-'); } elseif (strpos($icon_class, 'fa-') === 0 && strpos($icon_class, ' ') === false) { $icon_class = 'fa ' . $icon_class; } - return ''; + return aksrt_icon_markup($icon_class, 'mr3 menu-item-icon'); } /** diff --git a/tests/widget-system/icon-picker-contract.test.cjs b/tests/widget-system/icon-picker-contract.test.cjs index 575ab21f..ec33bc19 100644 --- a/tests/widget-system/icon-picker-contract.test.cjs +++ b/tests/widget-system/icon-picker-contract.test.cjs @@ -90,6 +90,34 @@ test('FA5 loads under a single canonical handle everywhere', () => { } }); +test('custom settings pages and standalone save paths speak the three icon formats', () => { + // 手机底部Tab / 右侧悬浮按钮 custom pages render the shared picker. + for (const page of ['assets/admin/src/pages/content/FooterTabbarSettings.vue', 'assets/admin/src/pages/content/FloatingButtonsSettings.vue']) { + const source = read(page); + assert.match(source, /import FaIconPicker from '@\/components\/form\/FaIconPicker\.vue'/); + assert.match(source, /import IconValue from '@\/components\/form\/IconValue\.vue'/); + assert.match(source, / { + const helper = read('inc/helpers/menu-decoration.php'); + assert.match(helper, /str_starts_with\(\$icon_class, 'zibsvg-'\)/); + assert.match(helper, /aksrt_icon_markup\(\$icon_class, 'icon mr3 menu-item-icon'\)/); + assert.doesNotMatch(helper, /'