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,14 +1,15 @@
<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { screenshots } from '../data/versions.js'
import { useLocale } from '../../../composables/useLocale.js'
import { assets } from '../config.js'
const { locale } = useI18n({ useScope: 'global' })
const { t } = useLocale()
const images = assets.screenshots
const current = ref(0)
let timer = null
function go(i) {
current.value = (i + screenshots.length) % screenshots.length
current.value = (i + images.length) % images.length
}
function next() {
go(current.value + 1)
@@ -31,8 +32,8 @@ onUnmounted(pause)
<div class="carousel" @mouseenter="pause" @mouseleave="resume">
<div class="carousel__viewport">
<div class="carousel__track" :style="{ transform: `translateX(-${current * 100}%)` }">
<figure v-for="(s, i) in screenshots" :key="i" class="carousel__slide">
<img :src="s.src" :alt="locale === 'zh-CN' ? s.caption.zh : s.caption.en" loading="lazy" />
<figure v-for="(src, i) in images" :key="i" class="carousel__slide">
<img :src="src" :alt="t('mobileGame.screenshots.caption', { n: i + 1 })" loading="lazy" />
</figure>
</div>
</div>
@@ -42,7 +43,7 @@ onUnmounted(pause)
<div class="carousel__dots">
<button
v-for="(s, i) in screenshots"
v-for="(src, i) in images"
:key="i"
class="carousel__dot"
:class="{ 'is-active': i === current }"