修复: 设置页面崩溃(模块循环依赖致初始化失败)
共享层模块顶层导入状态仓库,而状态仓库又导入共享层符号,形成 循环引用。打包后运行时触发 TDZ 崩溃,设置页面无法打开。 修复方案: - 共享层删除模块顶层的状态仓库导入和全局 store 实例 - 改为由状态仓库在状态就绪后主动注入消息数组引用 - 共享层函数运行时惰性获取消息引用,不再编译期依赖 - store 实例改为函数内局部获取(运行时 store 已就绪) 零行为变更,纯依赖方向调整。
This commit is contained in:
@@ -52,7 +52,7 @@ import { useAiEvents } from '@/composables/ai/useAiEvents'
|
||||
import { useAiStream } from '@/composables/ai/useAiStream'
|
||||
// 批4 双轨收口:getConvState 从 aiShared 取(下沉破环,避免 stores/ai↔useAiEvents 反向环)。
|
||||
// F-09 per-conv streaming/currentText(DEC-07a 父④):convStreamStates Map + 辅助函数亦从 aiShared 取。
|
||||
import { getConvState, getConvStreamState, setConvStreaming, setConvCurrentText } from '@/composables/ai/aiShared'
|
||||
import { getConvState, getConvStreamState, setConvStreaming, setConvCurrentText, __bindMessages } from '@/composables/ai/aiShared'
|
||||
import { useAiSend, initDrainQueueListener } from '@/composables/ai/useAiSend'
|
||||
import { useAiApproval } from '@/composables/ai/useAiApproval'
|
||||
import { useAiConversations } from '@/composables/ai/useAiConversations'
|
||||
@@ -190,6 +190,8 @@ export const state = reactive(_stateBase) as typeof _stateBase & {
|
||||
}
|
||||
// 回填 stateRef:accessor 闭包读此引用(经 reactive 包装后的代理对象,activeConversationId 变化可追踪)。
|
||||
stateRef = state
|
||||
// 注入 messages 引用到 aiShared 共享层(破循环依赖,避免 Vite 打包 TDZ)。
|
||||
__bindMessages(state.messages)
|
||||
|
||||
// 旁注:此处不再保留 type-only 导出(AiChatEvent 等),因组件直接从 api/types import。
|
||||
// 若有外部模块仍从本文件 import 这些类型,下方 re-export 兜底:
|
||||
|
||||
Reference in New Issue
Block a user