Files
DevFlow/src/i18n/index.ts
T
lxy bce2fea4e5 修复: 设置页和分离窗口渲染崩溃(TDZ + 窗口权限通配符)
- AdvancedSection clampApprovalTimeout 常量移到 reactive 之前(打包后 const 初始化顺序 TDZ)
- @/i18n 去掉对 @/stores/appSettings 的 import,改直读 localStorage
- Tauri capability 加 ai-detached-* / fe-detached-* 通配符(分离窗口 listen 权限)
2026-07-01 01:09:26 +08:00

30 lines
778 B
TypeScript

import { createI18n } from 'vue-i18n'
import zhCN from './zh-CN'
import en from './en'
// 界面语言:直接读 localStorage(避免 import @/stores/appSettings 形成循环依赖 TDZ)。
// appSettings.loadAll 也会从 SQLite 写入 localStorage,此处直读与 store 行为一致。
const getInitialLocale = (): string => {
if (typeof window !== 'undefined') {
try {
return localStorage.getItem('df-language') || 'zh-CN'
} catch {
return 'zh-CN'
}
}
return 'zh-CN'
}
const i18n = createI18n({
legacy: false,
globalInjection: true, // 模板中可直接用 $t / $tc
locale: getInitialLocale(),
fallbackLocale: 'en',
messages: {
'zh-CN': zhCN as Record<string, any>,
en: en as Record<string, any>,
},
})
export default i18n