Files
zMainPage/src/composables/useI18nLazy.js
Zikai e8dee338ed fix: EN切换失效、删除贡献者描述、版本按演进线分组(2D->3D)
- fix(i18n): composition 模式下响应式 locale 在 i18n.global 上(非 i18n.locale),
  loadLocaleAsync 与 useI18nLazy 改用 i18n.global.locale;
  useI18nLazy.current 改为派生自全局 locale 的 computed(单一数据源);
  各组件 useI18n() 加 useScope:'global' 确保读到同一 composer。
  headless 验证:默认中文(不下载EN chunk)->点EN加载en.[hash].js并切英文->切回中文 全通过
- content: 删除 MobileGame 概览中「主要贡献者 Zikai Wang... Hongxiang He...」句子
- timeline: 版本数据改为多演进线并行(zikai-ui/main/doby/roll-a-ball),
  每线带 2D/3D 形态标记,3D 线前显示「形态转变:2D -> 3D 滚球」转折标记
2026-07-12 15:03:04 +00:00

24 lines
702 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ref, computed } from 'vue'
import i18n, { loadLocaleAsync } from '../i18n/index.js'
const switching = ref(false)
// 语言懒加载切换逻辑
// current 派生自全局 i18n composer 的 localecomposition 模式下在 i18n.global
// 与各组件内 useI18n({ useScope: 'global' }) 读到的是同一个 ref。
export function useI18nLazy() {
const current = computed(() => i18n.global.locale.value)
async function switchLocale(locale) {
if (switching.value || current.value === locale) return
switching.value = true
try {
await loadLocaleAsync(locale)
} finally {
switching.value = false
}
}
return { current, switching, switchLocale }
}