diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 7323f4b..290a225 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -1,7 +1,7 @@ { "identifier": "default", "description": "DevFlow default permissions", - "windows": ["main", "ai-detached"], + "windows": ["main", "ai-detached", "ai-detached-*", "fe-detached-*"], "permissions": [ "core:default", "core:event:default", diff --git a/src/components/settings/AdvancedSection.vue b/src/components/settings/AdvancedSection.vue index a749966..7ceb18d 100644 --- a/src/components/settings/AdvancedSection.vue +++ b/src/components/settings/AdvancedSection.vue @@ -86,8 +86,14 @@ onMounted(async () => { // 字段。此处用 msg 拼标题+内容,dangerLabel 作确认按钮文案,自渲染独立弹层(上方模板)。 const { confirmState, confirmDialog, answerConfirm } = useConfirm() -// 三档合法值 + 脏值白名单兜底:KV 被外部改库为非法值(空串/非三档)时回退 low, -// 防 option);脏值回退默认 15min。 +// 必须在 settings reactive 之前定义,防打包后初始化顺序导致 TDZ。 +const VALID_APPROVAL_TIMEOUTS = [0, 300_000, 900_000, 1_800_000, 3_600_000] +function clampApprovalTimeout(raw: number): number { + return VALID_APPROVAL_TIMEOUTS.includes(raw) ? raw : 900_000 +} + +// 三档合法值 + 脏值白名单兜底 const VALID_MODES = ['low', 'medium', 'all'] as const type AutoMode = (typeof VALID_MODES)[number] function clampMode(raw: string): AutoMode { @@ -145,14 +151,6 @@ function markSaved() { rowLogLevel.value?.markSaved() } -// 审批超时合法选项白名单(对齐 无匹配 option 致控件空白。允许的取值:0/5/15/30/60 分钟对应毫秒数。 -const VALID_APPROVAL_TIMEOUTS = [0, 300_000, 900_000, 1_800_000, 3_600_000] -function clampApprovalTimeout(raw: number): number { - return VALID_APPROVAL_TIMEOUTS.includes(raw) ? raw : 900_000 -} - -// 审批超时下拉变更:落 KV(df-approval-timeout,ms)+ 显「已保存」反馈。 // 下一笔发起的审批即生效(aiShared.startApprovalTimer 每次实时读),已在跑的计时器沿用旧值。 function onApprovalTimeoutChange() { appSettings.set('df-approval-timeout', settings.approvalTimeout) diff --git a/src/i18n/index.ts b/src/i18n/index.ts index a1a3cf4..adc202c 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -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('df-language', 'zh-CN') + try { + return localStorage.getItem('df-language') || 'zh-CN' + } catch { + return 'zh-CN' + } } return 'zh-CN' }