避免 Iconify/el-icon 在部分浏览器不绘制,并去掉可关闭开关以免按钮被关掉。 Co-authored-by: Cursor <cursoragent@cursor.com>
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
/**
|
||
* 顶栏侧栏收起按钮必须始终可见:
|
||
* - 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'
|
||
)
|
||
})
|