feat: 小程序端 UI 优化与纯客户端化改造
- 移除微信订阅推送功能(云函数/订阅管理页),回归纯客户端零后端架构 - 新增今日黄历默认展示卡片 TodayAlmanacCard(9 语言翻译) - i18n 修复:启用 globalInjection 修复 $t 未注入,插值消息全部改为 Messages Functions 适配小程序端(63 处) - 修复底部导航切换失效与运势页数据不刷新 - 统一设计令牌(深褐主色 + 印红强调色),组件 UI 规范重构 - 图标 iconfont 化(FontAwesome 子集化,修复 Android 豆腐块) - 新增 postcss-px2rpx 机型自适应(仅 mp-weixin 构建生效) - 新增 5 个用户旅程 E2E 测试(31 用例)与验收报告 - 补充微信小程序项目配置(appid)
This commit is contained in:
@@ -8,6 +8,7 @@ import de from '../../locales/de'
|
||||
import fr from '../../locales/fr'
|
||||
import es from '../../locales/es'
|
||||
import pt from '../../locales/pt'
|
||||
import { i18n, I18N_OPTIONS } from '../../locales'
|
||||
|
||||
// 递归收集所有键路径
|
||||
function collectKeys(obj: Record<string, any>, prefix = ''): string[] {
|
||||
@@ -97,4 +98,38 @@ describe('TC-I18N-001~009: 国际化完整性验证', () => {
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
describe('TC-I18N-010: i18n 配置验证(防 P0 回归)', () => {
|
||||
it('createI18n 应启用 globalInjection,确保小程序端模板 $t 可用', () => {
|
||||
// legacy:false 模式下 globalInjection 必须为 true,
|
||||
// 否则小程序端模板渲染报 "TypeError: a.$t is not a function",全部页面异常
|
||||
expect(I18N_OPTIONS.globalInjection).toBe(true)
|
||||
})
|
||||
|
||||
it('createI18n 应使用 Composition API(legacy: false)', () => {
|
||||
expect(I18N_OPTIONS.legacy).toBe(false)
|
||||
expect((i18n as any).mode).toBe('composition')
|
||||
})
|
||||
|
||||
it('app.use(i18n) 后应在 globalProperties 注入 $t(小程序端模板可用)', async () => {
|
||||
const { createSSRApp } = await import('vue')
|
||||
const app = createSSRApp({ render: () => null })
|
||||
app.use(i18n)
|
||||
// globalInjection:true 会将 $t/$rt 注入 Vue 全局属性,供模板/render 使用
|
||||
const globalProperties = (app as any).config.globalProperties
|
||||
expect(globalProperties).toBeDefined()
|
||||
expect(typeof globalProperties.$t).toBe('function')
|
||||
expect(typeof globalProperties.$rt).toBe('function')
|
||||
})
|
||||
|
||||
it('Messages Functions 应正确插值(uni-app 小程序端不支持 {var} 字符串插值,必须用函数)', () => {
|
||||
i18n.global.locale.value = 'zh-CN'
|
||||
// 小程序端 {count} 字符串插值失效,函数形式是官方兼容方案
|
||||
expect(i18n.global.t('search.daysUnit', { count: 30 })).toBe('30天')
|
||||
expect(i18n.global.t('search.resultCount', { count: 20 })).toBe('共20条结果')
|
||||
expect(i18n.global.t('fortune.overallScore', { score: 55 })).toBe('综合运势:55分')
|
||||
expect(i18n.global.t('search.dateFormat', { year: 2026, month: 8, day: 18 })).toBe('2026年8月18日')
|
||||
expect(i18n.global.t('search.historyConditionDays', { count: 2, days: 30 })).toBe('2个条件,30天范围')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user