feat: 会话历史回溯

This commit is contained in:
2026-03-02 11:29:07 +08:00
parent 338c67d5b8
commit bd0a5a8c6b
7 changed files with 76 additions and 21 deletions

View File

@@ -13,6 +13,7 @@
ref="VersionTreeIndexRef"
v-model:versionTreeData="versionTreeData"
@restore="handleRestore"
@selectNode="handleSelectNode"
/>
</div>
</template>
@@ -24,13 +25,14 @@
import VersionTreeIndex from './components/versionTree/index.vue'
import { useProjectStore } from '@/stores'
import { getProjectInfo } from '@/api/agent'
import { clearNodeChat, getNodeAncestors } from '@/api/versitonTree'
import { useRoute } from 'vue-router'
const route = useRoute()
const projectStore = useProjectStore()
const agentTitle = ref('Retro Sofa Sketch')
const previewType = ref<'sketch' | 'report'>('sketch')
const route = useRoute()
const VersionTreeIndexRef = ref()
const agentRef = ref()
const sketchList = ref([])
@@ -45,20 +47,37 @@
})
const handleRestore = () => {
console.log('-----------', agentRef.value.inputRef.addReportTag)
// agentRef.value?.inputRef?.addReportTag('Restore')
clearNodeChat({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then(
(res) => {}
)
}
const handleSelectNode = () => {
console.log('handleSelectNode')
getNodeAncestors({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then(
(res) => {
console.log('res', res)
agentRef.value.setChatInfo(res)
}
)
}
agentRef.value?.inputRef?.addReportTag('Restore')
const handleGetProjectInfoAndHistory = () => {
getProjectInfo({ id: projectStore.state.id }).then((res) => {
// console.log('1111111',res);
agentRef.value.setChatInfo(res.conversation)
projectStore.setProject(res.project)
})
}
const proJectId = computed(() => route.params.id)
const projectStore = useProjectStore()
watch(
() => proJectId.value,
(newVal, oldVal) => {
if (newVal) {
projectStore.clearProject()
projectStore.setId(newVal)
}
}
)
@@ -66,18 +85,14 @@
() => projectStore.state.id,
(newVal, oldVal) => {
if (newVal) {
getProjectInfo({ id: newVal }).then((res) => {
projectStore.setProject(res.project)
})
handleGetProjectInfoAndHistory()
}
}
)
onMounted(() => {
if (projectStore.state.id) {
getProjectInfo({ id: projectStore.state.id }).then((res) => {
projectStore.setProject(res.project)
})
handleGetProjectInfoAndHistory()
}
})
</script>