修复: 设置页和分离窗口渲染崩溃(TDZ + 窗口权限通配符)
- AdvancedSection clampApprovalTimeout 常量移到 reactive 之前(打包后 const 初始化顺序 TDZ) - @/i18n 去掉对 @/stores/appSettings 的 import,改直读 localStorage - Tauri capability 加 ai-detached-* / fe-detached-* 通配符(分离窗口 listen 权限)
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import zhCN from './zh-CN'
|
||||
import en from './en'
|
||||
import { useAppSettingsStore } from '@/stores/appSettings'
|
||||
|
||||
// 界面语言:模块加载时 appSettings 缓存尚未填充(loadAll 在 App.vue onMounted 异步执行),
|
||||
// 故这里 get() 拿到默认 'zh-CN';真实用户偏好由 App.vue 在 loadAll 完成后回填到
|
||||
// i18n.global.locale.value,初帧渲染短暂 zh-CN 不影响功能。
|
||||
const getInitialLocale = () => {
|
||||
// 界面语言:直接读 localStorage(避免 import @/stores/appSettings 形成循环依赖 TDZ)。
|
||||
// appSettings.loadAll 也会从 SQLite 写入 localStorage,此处直读与 store 行为一致。
|
||||
const getInitialLocale = (): string => {
|
||||
if (typeof window !== 'undefined') {
|
||||
return useAppSettingsStore().get<string>('df-language', 'zh-CN')
|
||||
try {
|
||||
return localStorage.getItem('df-language') || 'zh-CN'
|
||||
} catch {
|
||||
return 'zh-CN'
|
||||
}
|
||||
}
|
||||
return 'zh-CN'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user