bugfix: 切换对话时先清空当前列表
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
)
|
||||
}
|
||||
const handleSelectNode = () => {
|
||||
console.log('handleSelectNode')
|
||||
getNodeAncestors({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then(
|
||||
(res) => {
|
||||
console.log('res', res)
|
||||
@@ -65,7 +64,7 @@
|
||||
|
||||
const handleGetProjectInfoAndHistory = () => {
|
||||
getProjectInfo({ id: route.params.id }).then((res) => {
|
||||
if (res?.conversation) agentRef.value.setChatInfo(res.conversation)
|
||||
if (res) agentRef.value.setChatInfo(res)
|
||||
let data = res?.project || res
|
||||
if (data?.latestNodeId) data.nodeId = data.latestNodeId
|
||||
projectStore.setProject({
|
||||
|
||||
@@ -232,15 +232,15 @@
|
||||
formData.append('file', file)
|
||||
|
||||
uploadImage(formData).then((res) => {
|
||||
const reader = new FileReader()
|
||||
reader.onload = (e) => {
|
||||
uploadedImages.value.push({
|
||||
url: e.target?.result as string,
|
||||
name: file.name,
|
||||
path: res
|
||||
})
|
||||
}
|
||||
reader.readAsDataURL(file)
|
||||
const reader = new FileReader()
|
||||
reader.onload = (e) => {
|
||||
uploadedImages.value.push({
|
||||
url: e.target?.result as string,
|
||||
name: file.name,
|
||||
path: res
|
||||
})
|
||||
}
|
||||
reader.readAsDataURL(file)
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -565,6 +565,9 @@
|
||||
|
||||
const handleCreateProject = async () => {
|
||||
// 这里可以添加创建项目的逻辑
|
||||
if (!inputValue.value.trim()) {
|
||||
return
|
||||
}
|
||||
const params = {
|
||||
type: typeValue.value,
|
||||
area: areaValue.value,
|
||||
|
||||
Reference in New Issue
Block a user