diff --git a/apps/web/index.html b/apps/web/index.html index a6d6327..2afd1bc 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -3,8 +3,22 @@ - + + 灵犀 · 信息流素材生产平台 + +
diff --git a/apps/web/src/shell.spec.ts b/apps/web/src/shell.spec.ts new file mode 100644 index 0000000..bb4eee7 --- /dev/null +++ b/apps/web/src/shell.spec.ts @@ -0,0 +1,26 @@ +import { readFileSync } from 'node:fs'; + +import { describe, expect, it } from 'vitest'; + +/** 从 spec 所在目录解析仓库内文件,避免依赖测试运行目录 */ +function readRepoFile(relativePath: string): string { + return readFileSync(new URL(relativePath, import.meta.url), 'utf8'); +} + +/** HTML 外壳不支持暗色模式:深色 color-scheme 会让浏览器在样式加载前画黑屏 */ +describe('HTML 外壳首屏防闪烁', () => { + const html = readRepoFile('../index.html'); + const tokens = readRepoFile('../../../packages/ui/src/theme/tokens.css'); + + it('只声明浅色 color-scheme,不声明 dark', () => { + expect(html).not.toMatch(/name="color-scheme"\s+content="dark"/); + expect(html).toMatch(/name="color-scheme"\s+content="light"/); + expect(html).toMatch(/color-scheme:\s*light/); + }); + + it('预置的应用底色与主题 token 一致', () => { + const appBackground = /--lx-color-bg-app:\s*(#[0-9a-fA-F]{6})/.exec(tokens)?.[1] ?? ''; + expect(appBackground).not.toBe(''); + expect(html.toLowerCase()).toContain(`background-color: ${appBackground.toLowerCase()}`); + }); +}); diff --git a/packages/ui/src/theme/tokens.css b/packages/ui/src/theme/tokens.css index ac41160..eb0c2dc 100644 --- a/packages/ui/src/theme/tokens.css +++ b/packages/ui/src/theme/tokens.css @@ -1,4 +1,7 @@ :root { + /* 本期仅浅色主题(Cloud Blue),不提供暗色模式;锁定浅色方案,避免系统深色偏好影响表单控件与滚动条 */ + color-scheme: light; + /* 方向 A · 云白蓝(Cloud Blue):传统企业后台骨架 + 现代浅色质感 */ --lx-color-bg-app: #f5f7fa; --lx-color-bg-panel: #ffffff;