feat(short-drama-agent-front): 新增全局主题和左右布局切换
This commit is contained in:
1 parent
db9aea1694
commit
27ee9fd4ff
10 files changed
+709
-41
No files matched your search
@@ -26,7 +26,7 @@ afterEach(() => {
|
||||
wrapper = undefined
|
||||
localStorage.clear()
|
||||
delete document.documentElement.dataset.theme
|
||||
document.documentElement.style.colorScheme = ''
|
||||
document.documentElement.removeAttribute('style')
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
|
||||
@@ -188,6 +188,7 @@ describe('管理后台组件边界', () => {
|
||||
return option!.icon()
|
||||
}
|
||||
expect(firstMenuIcon().type).not.toBe(NPopover)
|
||||
|
||||
expect(wrapper.get('.admin-sider-footer').findComponent(NPopover).exists()).toBe(false)
|
||||
expect(wrapper.get('[aria-label="折叠侧栏"] svg').classes()).toContain('lucide-panel-left-close')
|
||||
expect(wrapper.findAll('.studio-logo svg')).toHaveLength(2)
|
||||
@@ -219,6 +220,26 @@ describe('管理后台组件边界', () => {
|
||||
'分镜设计',
|
||||
'镜头生产'
|
||||
])
|
||||
// 切换布局时保留分镜工作区的 DOM,刷新后从已保存的偏好恢复。
|
||||
const workspace = wrapper.get('#main-content .workspace-page').element
|
||||
const layoutToggle = wrapper.get('.workspace-layout-toggle')
|
||||
await layoutToggle.trigger('click')
|
||||
await flushPromises()
|
||||
const layoutOptions = [...document.querySelectorAll<HTMLElement>('.n-dropdown-option-body')]
|
||||
.filter(option => option.closest('.n-dropdown-menu'))
|
||||
.filter(option => ['居左', '居右', '居中'].includes(option.textContent?.trim() ?? ''))
|
||||
expect(layoutOptions.map(option => option.textContent?.trim())).toEqual(['居左', '居右'])
|
||||
layoutOptions[1]!.click()
|
||||
await flushPromises()
|
||||
expect(wrapper.get('.admin-layout').classes()).toContain('is-nav-right')
|
||||
expect(wrapper.get('#main-content .workspace-page').element).toBe(workspace)
|
||||
expect(layoutToggle.attributes('aria-label')).toBe('工作台布局:居右')
|
||||
expect(wrapper.get('[aria-label="展开侧栏"] svg').classes()).toContain('lucide-panel-right-open')
|
||||
wrapper.unmount()
|
||||
wrapper = mount(App, { attachTo: document.body, global: { plugins: [router] } })
|
||||
await flushPromises()
|
||||
expect(wrapper.get('.admin-layout').classes()).toContain('is-nav-right')
|
||||
|
||||
const settings = wrapper.get('.admin-sider-footer [aria-label="连接设置"]')
|
||||
expect(settings.text()).toBe('连接设置')
|
||||
await settings.trigger('click')
|
||||
@@ -254,7 +275,9 @@ describe('管理后台组件边界', () => {
|
||||
expect(css).toContain('@media (prefers-reduced-motion: reduce)')
|
||||
expect(css).toContain('.admin-sider.is-collapsed:is(:hover, :has(:focus-visible)) .n-menu-item-content-header')
|
||||
expect(css).toContain('clip-path: inset(0);')
|
||||
expect(css).toContain('transform: translateX(-6px);')
|
||||
expect(css).toContain('transform: translateX(var(--admin-nav-reveal-offset));')
|
||||
expect(css).toContain('--admin-nav-reveal-offset: -6px;')
|
||||
expect(css).toContain('--admin-nav-reveal-offset: 6px;')
|
||||
expect(css).not.toContain('.admin-sider-mask')
|
||||
expect(css).not.toContain('.admin-sider.is-overlay')
|
||||
for (const path of ['storyboard/StoryboardPage.vue', 'production/ProductionPage.vue']) {
|
||||
|
||||
@@ -9,7 +9,7 @@ afterEach(() => {
|
||||
scope = undefined
|
||||
localStorage.clear()
|
||||
delete document.documentElement.dataset.theme
|
||||
document.documentElement.style.colorScheme = ''
|
||||
document.documentElement.removeAttribute('style')
|
||||
vi.unstubAllGlobals()
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
@@ -152,6 +152,45 @@ describe('微信风格明暗主题', () => {
|
||||
expect(contrast(tokens['accent-text']!, tokens.selected!)).toBeGreaterThanOrEqual(4.5)
|
||||
})
|
||||
|
||||
it('主色同步到 Naive 和业务样式,刷新后与明暗偏好分别恢复', async () => {
|
||||
const state = setup()
|
||||
state.accent.value = 'blue'
|
||||
await nextTick()
|
||||
const root = document.documentElement
|
||||
const blue = state.overrides.value.common!.primaryColor!
|
||||
expect(blue).not.toBe('#07c160')
|
||||
expect(root.style.getPropertyValue('--app-accent')).toBe(blue)
|
||||
expect(root.style.getPropertyValue('--app-button-primary')).toBe(state.overrides.value.Button?.colorPrimary)
|
||||
expect(state.overrides.value.common?.successColor).toBe('#087c42')
|
||||
state.preference.value = 'dark'
|
||||
await nextTick()
|
||||
const darkBlue = state.overrides.value.common!.primaryColor
|
||||
expect(darkBlue).not.toBe(blue)
|
||||
scope!.stop()
|
||||
const restored = setup()
|
||||
expect(restored.accent.value).toBe('blue')
|
||||
expect(restored.isDark.value).toBe(true)
|
||||
expect(restored.overrides.value.common?.primaryColor).toBe(darkBlue)
|
||||
expect(restored.overrides.value.common?.successColor).toBe('#5cd693')
|
||||
restored.accent.value = 'green'
|
||||
await nextTick()
|
||||
expect(root.style.getPropertyValue('--app-accent')).toBe('#07c160')
|
||||
})
|
||||
|
||||
it.each([false, true])('明暗模式 %s 下所有预设的按钮白字和选中文字对比度充足', dark => {
|
||||
const state = setup(dark)
|
||||
for (const accent of ['blue', 'violet', 'pink', 'yellow', 'indigo', 'green', 'zinc'] as const) {
|
||||
state.accent.value = accent
|
||||
const { Button, Menu } = state.overrides.value
|
||||
for (const background of [Button!.colorPrimary, Button!.colorHoverPrimary, Button!.colorPressedPrimary]) {
|
||||
expect(contrast(String(Button!.textColorPrimary), String(background))).toBeGreaterThanOrEqual(4.5)
|
||||
}
|
||||
expect(contrast(String(Menu!.itemTextColorActive), String(Menu!.itemColorActive))).toBeGreaterThanOrEqual(
|
||||
4.5
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it('系统切换时浏览器主题色与页面同步', async () => {
|
||||
const meta = document.createElement('meta')
|
||||
meta.name = 'theme-color'
|
||||
|
||||
Reference in new issue
Block a user