bugfix: 切换对话时先清空当前列表

This commit is contained in:
2026-03-02 16:40:40 +08:00
parent 4063dfb106
commit 1669ac78a9
3 changed files with 35 additions and 20 deletions

View File

@@ -113,7 +113,7 @@
const handleSendMessage = async (
message: {
text: string
images: Array<{ url: string; name: string }>,
images: Array<{ url: string; name: string }>
tempImages: any[]
},
skipUserMessage = false
@@ -129,7 +129,7 @@
id: messageList.value.length + 1,
text: message.text,
isUser: true,
imageUrls:message.tempImages
imageUrls: message.tempImages
})
}
@@ -360,8 +360,20 @@
)
}
const setChatInfo = (data) => {
// messageList.value = list
const setChatInfo = (info) => {
// 先清空列表
const data = info.conversation
const project = info.project
messageList.value = []
params.versionID = ''
sketchList.value = []
params.configParams.type = project.type
params.configParams.region = project.area
params.configParams.style = project.style
params.configParams.temperature = project.temperature
// 如果没有数据,直接返回
if (!data) return
const { ancestors, current } = data
const imgList = []
const ancestorsList = []
@@ -395,11 +407,12 @@
}
}) || []
messageList.value = [...ancestorsList, ...currentList]
params.versionID = current.id
sketchList.value = imgList
// console.log('messagelist:', messageList.value)
// debugger
// 延迟设置新数据,确保 UI 有时间响应清空操作
nextTick(() => {
messageList.value = [...ancestorsList, ...currentList]
params.versionID = current?.id
sketchList.value = imgList
})
}
defineExpose({