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:
Zikai
2026-07-12 16:08:25 +00:00
parent b3556b8639
commit c6dad2b79a
14 changed files with 341 additions and 273 deletions

View File

@@ -1,27 +1,26 @@
<script setup>
import { useI18n } from 'vue-i18n'
import { useLocale } from '../../../composables/useLocale.js'
const props = defineProps({
tabs: { type: Array, required: true }, // [{ id, label: {zh,en} }]
tabs: { type: Array, required: true }, // [{ id, labelKey }]
modelValue: { type: String, required: true }
})
const emit = defineEmits(['update:modelValue'])
const { locale } = useI18n({ useScope: 'global' })
const L = (obj) => (locale.value === 'zh-CN' ? obj.zh : obj.en)
const { t } = useLocale()
</script>
<template>
<div class="subtabs">
<button
v-for="t in tabs"
:key="t.id"
v-for="tab in tabs"
:key="tab.id"
type="button"
class="subtabs__btn"
:class="{ 'is-active': modelValue === t.id }"
@click="emit('update:modelValue', t.id)"
:class="{ 'is-active': modelValue === tab.id }"
@click="emit('update:modelValue', tab.id)"
>
{{ L(t.label) }}
{{ t(tab.labelKey) }}
</button>
</div>
</template>