文件
shanghaipeiwan/server/tests/theme-consistency.spec.ts
xcbyy a1e3a137b6 fix(ui): 修复优惠券页/消息页导航栏位置偏高(标题与返回按钮应贴胶囊行)
- 原因:初版用 padding-top=safe-header-gap + 44px 内容行,把标题推到状态栏下方,顶部留白过大
- 改为与其它页面一致的规范:导航栏总高=var(--safe-header-gap),内容行 position:absolute;bottom:0;height:var(--capsule-height) 贴底对齐胶囊;标题绝对居中(translateX(-50%))
- 页面根改为 height:100vh + flex 纵向布局,列表用 flex:1 撑满剩余空间(tab-bar/滚动区不再按 100vh 硬算)
- 返回按钮对齐既有规范(64rpx 圆形底 + 38rpx 图标)
- 回归 97 套件/674 用例全绿(theme-consistency.spec.ts 增加导航规范断言)
2026-10-19 15:42:18 +08:00

55 行
2.5 KiB
TypeScript

// 已读取AGENTS.md
import * as fs from 'fs';
import * as path from 'path';
/**
* 第八十一批:新页面必须复用全局主题变量(随 theme-warm/theme-cool 切换自适应)。
* 背景:优惠券页/消息页初版写死深色,切到「暖阳晨曦」主题时不跟随,配色不一致。
*/
describe('第八十一批主题一致性闸门', () => {
const root = path.resolve(__dirname, '../../');
const read = (p: string) => fs.readFileSync(path.join(root, p), 'utf-8');
const coupons = read('pwuniapp/pages/user/coupons.vue');
const notifications = read('pwuniapp/pages/user/notifications.vue');
const workspace = read('pwuniapp/pages/expert/workspace.vue');
it('优惠券页使用全局主题变量而非写死配色', () => {
for (const v of ['var(--bg-primary', 'var(--bg-surface', 'var(--color-brand-gradient', 'var(--text-primary', 'var(--text-secondary', 'var(--text-muted', 'var(--border-subtle', 'var(--nav-bg']) {
expect(coupons).toContain(v);
}
expect(coupons).toContain("'theme-' + currentThemeKey");
});
it('消息通知页使用全局主题变量', () => {
for (const v of ['var(--bg-primary', 'var(--bg-surface', 'var(--color-brand', 'var(--text-primary', 'var(--text-muted', 'var(--border-subtle', 'var(--nav-bg']) {
expect(notifications).toContain(v);
}
expect(notifications).toContain("'theme-' + currentThemeKey");
});
it('大神工作台新增表单样式复用主题变量', () => {
expect(workspace).toContain('var(--bg-surface-elevated');
expect(workspace).toContain('var(--color-brand');
expect(workspace).toContain('var(--text-secondary');
expect(workspace).toContain('var(--text-primary');
});
it('新页面导航栏遵循统一规范(总高=安全区,内容行贴底对齐胶囊,标题绝对居中)', () => {
for (const page of [coupons, notifications]) {
expect(page).toContain('height: var(--safe-header-gap');
expect(page).toContain('position: absolute;');
expect(page).toContain('bottom: 0;');
expect(page).toContain('height: var(--capsule-height');
expect(page).toContain('transform: translateX(-50%)');
expect(page).toContain('flex-direction: column');
}
});
it('全局主题变量在 App.vue 中按主题定义', () => {
const app = read('pwuniapp/App.vue');
expect(app).toContain(':root, page {');
expect(app).toContain('.theme-warm {');
expect(app).toContain('--color-brand-gradient');
});
});