feat: 用缓存处理对话中的项目切换问题

This commit is contained in:
2026-04-02 10:05:29 +08:00
parent b205633d0d
commit 836431788a
15 changed files with 208 additions and 51 deletions

View File

@@ -131,12 +131,26 @@
watch(
() => proJectId.value,
(newVal, oldVal) => {
async (newVal, oldVal) => {
if (oldVal && agentRef.value && typeof agentRef.value.saveSession === 'function') {
agentRef.value.saveSession(oldVal as string)
}
projectStore.clearProject()
if (newVal) {
handleGetProjectInfoAndHistory()
let restored = false
if (agentRef.value && typeof agentRef.value.restoreSession === 'function') {
restored = await agentRef.value.restoreSession(newVal as string)
}
if (!restored) {
handleGetProjectInfoAndHistory()
}
MyEvent.emit('projectChange')
} else {
MyEvent.emit('projectChange')
MyEvent.emit('resetAgent')
}
}
)