refactor: 高内聚低耦合 - 配置集中化与 i18n 统一
结构优化:
- 新增 mobile-game/config.js:集中模块静态配置(资源路径、排行榜端点、
hero meta、子标签页定义),消除散落在各组件的硬编码
- 新增 composables/useLocale.js:共享语言辅助(t/isZh/pick),
消除 6 个组件各自重复定义的 L() helper
- 文案全部迁入 i18n locale(mobileGame 命名空间),消除模板内联 L('中','英')
- 数据文件 versions.js 去除 {zh,en} 对象,文案改由 i18n 键(tracks/versions)取
- 各组件改为读 config + t(),不再直接 useI18n,降低与 i18n 实现的耦合
headless 验证:中文(hero/meta/team/timeline/3D置顶) + 英文切换 + 切回中文 全通过
This commit is contained in:
46
src/modules/mobile-game/config.js
Normal file
46
src/modules/mobile-game/config.js
Normal file
@@ -0,0 +1,46 @@
|
||||
// mobile-game 模块的静态配置(集中管理,避免散落在各组件)
|
||||
// 文案走 i18n(见 locales 的 mobileGame 命名空间),此处只放纯配置与资源路径。
|
||||
|
||||
// 站点根绝对路径的资源引用
|
||||
export const assets = {
|
||||
// 截图轮播图源
|
||||
screenshots: [
|
||||
'/448/1.jpg',
|
||||
'/448/2.jpg',
|
||||
'/448/3.jpg'
|
||||
],
|
||||
// ML-Agents 演示视频
|
||||
video: {
|
||||
src: '/448/ml/449ml.mp4',
|
||||
poster: '/448/2.jpg'
|
||||
}
|
||||
}
|
||||
|
||||
// 排行榜后端(复用 449 现有 PHP 接口)
|
||||
export const leaderboard = {
|
||||
endpoint: '/449/449rest.php',
|
||||
// 拉取页数 x 每页条数 = 总条数
|
||||
pages: 3,
|
||||
perPage: 10
|
||||
}
|
||||
|
||||
// Hero 区元数据(i18n 键,文案在 locales/mobileGame.meta 下)
|
||||
export const heroMeta = {
|
||||
// meta 项顺序:labelKey -> valueKey
|
||||
items: [
|
||||
{ labelKey: 'mobileGame.meta.stack', valueKey: 'mobileGame.meta.stackValue' },
|
||||
{ labelKey: 'mobileGame.meta.period', valueKey: 'mobileGame.meta.periodValue' }
|
||||
],
|
||||
// 顶部 eyebrow tag
|
||||
courseKey: 'mobileGame.meta.course'
|
||||
}
|
||||
|
||||
// 子标签页定义(id 与 i18n 键)
|
||||
export const subTabs = [
|
||||
{ id: 'team', labelKey: 'mobileGame.subtabs.team' },
|
||||
{ id: 'iterations', labelKey: 'mobileGame.subtabs.iterations' },
|
||||
{ id: 'experiment', labelKey: 'mobileGame.subtabs.experiment' }
|
||||
]
|
||||
|
||||
// 默认激活的子标签页
|
||||
export const defaultSubTab = 'team'
|
||||
Reference in New Issue
Block a user