bugfix: 切换对话时先清空当前列表
This commit is contained in:
@@ -113,7 +113,7 @@
|
|||||||
const handleSendMessage = async (
|
const handleSendMessage = async (
|
||||||
message: {
|
message: {
|
||||||
text: string
|
text: string
|
||||||
images: Array<{ url: string; name: string }>,
|
images: Array<{ url: string; name: string }>
|
||||||
tempImages: any[]
|
tempImages: any[]
|
||||||
},
|
},
|
||||||
skipUserMessage = false
|
skipUserMessage = false
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
id: messageList.value.length + 1,
|
id: messageList.value.length + 1,
|
||||||
text: message.text,
|
text: message.text,
|
||||||
isUser: true,
|
isUser: true,
|
||||||
imageUrls:message.tempImages
|
imageUrls: message.tempImages
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,8 +360,20 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const setChatInfo = (data) => {
|
const setChatInfo = (info) => {
|
||||||
// messageList.value = list
|
// 先清空列表
|
||||||
|
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 { ancestors, current } = data
|
||||||
const imgList = []
|
const imgList = []
|
||||||
const ancestorsList = []
|
const ancestorsList = []
|
||||||
@@ -395,11 +407,12 @@
|
|||||||
}
|
}
|
||||||
}) || []
|
}) || []
|
||||||
|
|
||||||
messageList.value = [...ancestorsList, ...currentList]
|
// 延迟设置新数据,确保 UI 有时间响应清空操作
|
||||||
params.versionID = current.id
|
nextTick(() => {
|
||||||
sketchList.value = imgList
|
messageList.value = [...ancestorsList, ...currentList]
|
||||||
// console.log('messagelist:', messageList.value)
|
params.versionID = current?.id
|
||||||
// debugger
|
sketchList.value = imgList
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|||||||
@@ -54,7 +54,6 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
const handleSelectNode = () => {
|
const handleSelectNode = () => {
|
||||||
console.log('handleSelectNode')
|
|
||||||
getNodeAncestors({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then(
|
getNodeAncestors({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then(
|
||||||
(res) => {
|
(res) => {
|
||||||
console.log('res', res)
|
console.log('res', res)
|
||||||
@@ -65,7 +64,7 @@
|
|||||||
|
|
||||||
const handleGetProjectInfoAndHistory = () => {
|
const handleGetProjectInfoAndHistory = () => {
|
||||||
getProjectInfo({ id: route.params.id }).then((res) => {
|
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
|
let data = res?.project || res
|
||||||
if (data?.latestNodeId) data.nodeId = data.latestNodeId
|
if (data?.latestNodeId) data.nodeId = data.latestNodeId
|
||||||
projectStore.setProject({
|
projectStore.setProject({
|
||||||
|
|||||||
@@ -232,15 +232,15 @@
|
|||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
|
|
||||||
uploadImage(formData).then((res) => {
|
uploadImage(formData).then((res) => {
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
uploadedImages.value.push({
|
uploadedImages.value.push({
|
||||||
url: e.target?.result as string,
|
url: e.target?.result as string,
|
||||||
name: file.name,
|
name: file.name,
|
||||||
path: res
|
path: res
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
reader.readAsDataURL(file)
|
reader.readAsDataURL(file)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -565,6 +565,9 @@
|
|||||||
|
|
||||||
const handleCreateProject = async () => {
|
const handleCreateProject = async () => {
|
||||||
// 这里可以添加创建项目的逻辑
|
// 这里可以添加创建项目的逻辑
|
||||||
|
if (!inputValue.value.trim()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const params = {
|
const params = {
|
||||||
type: typeValue.value,
|
type: typeValue.value,
|
||||||
area: areaValue.value,
|
area: areaValue.value,
|
||||||
|
|||||||
Reference in New Issue
Block a user