From 82c21262ed6aedd73c1bf011247debf174ad5c42 Mon Sep 17 00:00:00 2001 From: wuzilong <704541015@qq.com> Date: Mon, 16 Nov 2026 15:42:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(web-admin):=20=E9=A1=B6=E6=A0=8F=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=8A=98=E5=8F=A0=E6=8C=89=E9=92=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=86=85=E8=81=94=20SVG=20=E5=B9=B6=E5=A7=8B=E7=BB=88=E5=8F=AF?= =?UTF-8?q?=E8=A7=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 避免 Iconify/el-icon 在部分浏览器不绘制,并去掉可关闭开关以免按钮被关掉。 Co-authored-by: Cursor --- .../fold-menu-button-always-on.test.ts | 46 +++++++++++++ ...e-26-fold-icon-and-archive-plan-no.test.ts | 24 ++++++- .../core/base/art-svg-icon/index.vue | 6 +- .../core/layouts/art-header-bar/index.vue | 65 ++++++++++++++++--- .../composables/useSettingsConfig.ts | 8 +-- .../composables/useSettingsHandlers.ts | 2 +- .../widget/SettingActions.vue | 5 +- web-admin/src/store/modules/setting.ts | 16 +++-- web-admin/src/views/index/index.vue | 2 + 9 files changed, 143 insertions(+), 31 deletions(-) create mode 100644 web-admin/scripts/fold-menu-button-always-on.test.ts diff --git a/web-admin/scripts/fold-menu-button-always-on.test.ts b/web-admin/scripts/fold-menu-button-always-on.test.ts new file mode 100644 index 000000000..403b20042 --- /dev/null +++ b/web-admin/scripts/fold-menu-button-always-on.test.ts @@ -0,0 +1,46 @@ +/** + * 顶栏侧栏收起按钮必须始终可见: + * - persist afterRestore 强制 ensureMenuButtonVisible(禁止 toggle) + * - AppLayout 挂载时再次兜底 + * - 设置面板不再提供可关闭开关 + */ +import test from 'node:test' +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import { dirname, join } from 'node:path' +import { fileURLToPath } from 'node:url' + +const root = join(dirname(fileURLToPath(import.meta.url)), '..') + +test('setting store forces menu button visible on restore', () => { + const src = readFileSync(join(root, 'src/store/modules/setting.ts'), 'utf8') + assert.match(src, /ensureMenuButtonVisible\s*=\s*\(\)\s*=>\s*\{[\s\S]*?showMenuButton\.value\s*=\s*true/) + assert.match(src, /afterRestore:\s*\(ctx\)\s*=>\s*\{[\s\S]*?ensureMenuButtonVisible\(\)/) + assert.doesNotMatch( + src, + /afterRestore:[\s\S]*?if\s*\(\s*!ctx\.store\.showMenuButton\s*\)[\s\S]*?setButton\(\)/, + 'afterRestore must not rely on setButton toggle' + ) + assert.match( + src, + /const setButton = \(\) => \{\s*showMenuButton\.value = true/, + 'setButton must assign true, not toggle' + ) +}) + +test('AppLayout mount ensures menu button visible', () => { + const src = readFileSync(join(root, 'src/views/index/index.vue'), 'utf8') + assert.match(src, /ensureMenuButtonVisible\(\)/) +}) + +test('settings panel does not expose showMenuButton switch', () => { + const src = readFileSync( + join(root, 'src/components/core/layouts/art-settings-panel/composables/useSettingsConfig.ts'), + 'utf8' + ) + assert.doesNotMatch( + src, + /key:\s*'showMenuButton'/, + 'settings UI must not allow turning off the fold control' + ) +}) diff --git a/web-admin/scripts/issue-26-fold-icon-and-archive-plan-no.test.ts b/web-admin/scripts/issue-26-fold-icon-and-archive-plan-no.test.ts index 2858c7909..d7311a396 100644 --- a/web-admin/scripts/issue-26-fold-icon-and-archive-plan-no.test.ts +++ b/web-admin/scripts/issue-26-fold-icon-and-archive-plan-no.test.ts @@ -12,18 +12,36 @@ import { parse } from '@vue/compiler-sfc' const root = join(dirname(fileURLToPath(import.meta.url)), '..') -test('ArtSvgIcon: el-icon branch must not use Tailwind inline class', () => { +test('ArtSvgIcon: icon roots must not use Tailwind inline class', () => { const src = readFileSync(join(root, 'src/components/core/base/art-svg-icon/index.vue'), 'utf8') const { descriptor } = parse(src) const template = descriptor.template?.content || '' assert.match(template, /]*class="[^"]*art-svg-icon/) assert.doesNotMatch( template, - /]*class="[^"]*\binline\b/, - 'el-icon must not include Tailwind inline (breaks display:inline-flex in prod CSS order)' + /<(?:el-icon|Icon)\b[^>]*class="[^"]*\binline\b/, + 'icon roots must not include Tailwind inline (breaks display in prod CSS order)' ) }) +test('header fold button uses inline SVG button (Chrome-safe)', () => { + const src = readFileSync( + join(root, 'src/components/core/layouts/art-header-bar/index.vue'), + 'utf8' + ) + const { descriptor } = parse(src) + const template = descriptor.template?.content || '' + assert.match(template, /class="menu-fold-btn/) + assert.match(template, /menu-fold-btn__icon/) + assert.match(template, / - +