2026-02-10 13:05:24 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="agent-wrapper flex space-between">
|
2026-02-23 10:54:17 +08:00
|
|
|
<div class="openVersionTree">
|
2026-02-25 15:10:03 +08:00
|
|
|
<div class="btn" @click="versionTreeData.drawer = true">Version Tree</div>
|
2026-02-11 17:27:51 +08:00
|
|
|
</div>
|
2026-02-23 10:54:17 +08:00
|
|
|
<div class="content-wrapper">
|
2026-03-13 17:23:56 +08:00
|
|
|
<Agent
|
|
|
|
|
ref="agentRef"
|
|
|
|
|
:title="agentTitle"
|
|
|
|
|
@update:sketchList="updateSketchList"
|
|
|
|
|
@setTitle="handleSetTitle"
|
|
|
|
|
/>
|
2026-02-23 10:54:17 +08:00
|
|
|
<div class="preview-wrapper">
|
2026-03-13 17:23:56 +08:00
|
|
|
<Preview
|
|
|
|
|
ref="previewRef"
|
|
|
|
|
:type="previewType"
|
|
|
|
|
:sketchList="sketchList"
|
|
|
|
|
@deleteSketch="handleDeleteSketch"
|
|
|
|
|
/>
|
2026-02-23 10:54:17 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-02-26 16:48:08 +08:00
|
|
|
<VersionTreeIndex
|
|
|
|
|
ref="VersionTreeIndexRef"
|
|
|
|
|
v-model:versionTreeData="versionTreeData"
|
|
|
|
|
@restore="handleRestore"
|
2026-03-02 11:29:07 +08:00
|
|
|
@selectNode="handleSelectNode"
|
2026-02-26 16:48:08 +08:00
|
|
|
/>
|
2026-02-10 13:05:24 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-03-13 17:23:56 +08:00
|
|
|
import { ref, watch, onMounted, computed, onUnmounted } from 'vue'
|
2026-02-10 13:05:24 +08:00
|
|
|
import Agent from './components/Agent.vue'
|
2026-02-11 17:27:51 +08:00
|
|
|
import Preview from './components/Preview.vue'
|
2026-02-23 13:28:43 +08:00
|
|
|
import VersionTreeIndex from './components/versionTree/index.vue'
|
2026-02-26 10:19:51 +08:00
|
|
|
import { useProjectStore } from '@/stores'
|
|
|
|
|
import { getProjectInfo } from '@/api/agent'
|
2026-03-02 11:29:07 +08:00
|
|
|
import { clearNodeChat, getNodeAncestors } from '@/api/versitonTree'
|
2026-03-27 11:50:13 +08:00
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
2026-03-13 17:23:56 +08:00
|
|
|
import MyEvent from '@/utils/myEvent'
|
2026-03-27 11:50:13 +08:00
|
|
|
import { useI18n } from 'vue-i18n'
|
2026-02-27 16:51:58 +08:00
|
|
|
|
2026-03-02 11:29:07 +08:00
|
|
|
const route = useRoute()
|
2026-03-27 11:50:13 +08:00
|
|
|
const router = useRouter()
|
|
|
|
|
const { t } = useI18n()
|
2026-03-02 11:29:07 +08:00
|
|
|
const projectStore = useProjectStore()
|
2026-02-26 10:19:51 +08:00
|
|
|
|
2026-03-13 17:23:56 +08:00
|
|
|
const previewRef = ref(null)
|
|
|
|
|
|
2026-03-06 11:51:11 +08:00
|
|
|
const agentTitle = ref('Conversation')
|
2026-02-25 15:10:03 +08:00
|
|
|
const previewType = ref<'sketch' | 'report'>('sketch')
|
2026-02-26 10:19:51 +08:00
|
|
|
const VersionTreeIndexRef = ref()
|
2026-02-26 16:48:08 +08:00
|
|
|
const agentRef = ref()
|
2026-02-25 15:10:03 +08:00
|
|
|
const sketchList = ref([])
|
|
|
|
|
const updateSketchList = (newVal) => {
|
|
|
|
|
sketchList.value = newVal
|
2026-02-26 10:19:51 +08:00
|
|
|
// VersionTreeIndexRef.value.getVersionTree()
|
2026-02-25 15:10:03 +08:00
|
|
|
}
|
2026-02-23 10:54:17 +08:00
|
|
|
|
2026-03-31 11:39:42 +08:00
|
|
|
const handleDeleteSketch = (id) => {
|
|
|
|
|
sketchList.value = sketchList.value
|
|
|
|
|
.map((sketchItem) => {
|
|
|
|
|
if (sketchItem.hasOwnProperty(id)) {
|
|
|
|
|
delete sketchItem[id]
|
|
|
|
|
}
|
|
|
|
|
return sketchItem
|
|
|
|
|
})
|
|
|
|
|
.filter((sketchItem) => Object.keys(sketchItem).length > 0)
|
2026-03-11 10:53:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-13 17:23:56 +08:00
|
|
|
const handleSetTitle = (title: string) => {
|
|
|
|
|
agentTitle.value = title
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-23 10:54:17 +08:00
|
|
|
const versionTreeData = ref({
|
2026-02-26 16:48:08 +08:00
|
|
|
drawer: false
|
2026-02-26 10:19:51 +08:00
|
|
|
})
|
|
|
|
|
|
2026-02-26 16:48:08 +08:00
|
|
|
const handleRestore = () => {
|
2026-03-02 11:29:07 +08:00
|
|
|
// agentRef.value?.inputRef?.addReportTag('Restore')
|
|
|
|
|
clearNodeChat({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then(
|
2026-03-02 13:54:52 +08:00
|
|
|
(res) => {
|
2026-03-05 15:33:58 +08:00
|
|
|
agentRef.value.setChatInfo({ conversation: res, project: {} })
|
2026-03-02 13:54:52 +08:00
|
|
|
}
|
2026-03-02 11:29:07 +08:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
const handleSelectNode = () => {
|
|
|
|
|
getNodeAncestors({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then(
|
|
|
|
|
(res) => {
|
2026-03-03 10:28:16 +08:00
|
|
|
agentRef.value.setChatInfo({ conversation: res, project: {} })
|
2026-03-02 11:29:07 +08:00
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
2026-02-26 16:48:08 +08:00
|
|
|
|
2026-03-25 10:11:13 +08:00
|
|
|
const handleGetProjectInfoAndHistory = () => {
|
2026-03-17 15:41:44 +08:00
|
|
|
handleOpenSketch()
|
2026-03-02 13:40:17 +08:00
|
|
|
getProjectInfo({ id: route.params.id }).then((res) => {
|
2026-03-31 11:39:42 +08:00
|
|
|
if (!res) {
|
2026-03-27 11:50:13 +08:00
|
|
|
router.push({ name: 'mainInput' })
|
|
|
|
|
ElMessage.warning(t('Home.notFound'))
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-03-02 16:40:40 +08:00
|
|
|
if (res) agentRef.value.setChatInfo(res)
|
2026-03-02 13:40:17 +08:00
|
|
|
let data = res?.project || res
|
2026-03-02 13:54:52 +08:00
|
|
|
if (data?.latestNodeId) data.nodeId = data.latestNodeId
|
2026-03-06 11:51:11 +08:00
|
|
|
if (data) {
|
|
|
|
|
agentTitle.value = data.name
|
|
|
|
|
}
|
2026-03-02 11:45:40 +08:00
|
|
|
projectStore.setProject({
|
2026-03-02 13:54:52 +08:00
|
|
|
...data
|
2026-03-02 11:45:40 +08:00
|
|
|
})
|
2026-03-02 11:29:07 +08:00
|
|
|
})
|
2026-02-26 16:48:08 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-27 16:51:58 +08:00
|
|
|
const proJectId = computed(() => route.params.id)
|
2026-03-02 11:29:07 +08:00
|
|
|
|
2026-03-27 16:49:29 +08:00
|
|
|
const handleOpenReport = (data) => {
|
|
|
|
|
previewRef.value.setSessionId(data.sessionId)
|
2026-04-01 16:59:22 +08:00
|
|
|
previewRef.value.setReport(data.reportName, data.report)
|
2026-03-13 17:23:56 +08:00
|
|
|
previewType.value = 'report'
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-16 11:43:19 +08:00
|
|
|
const handleOpenUrls = (data) => {
|
2026-03-16 14:11:01 +08:00
|
|
|
previewRef.value.setUrls(data)
|
|
|
|
|
previewType.value = 'url'
|
2026-03-16 11:43:19 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-17 11:22:47 +08:00
|
|
|
const handleOpenSketch = () => {
|
|
|
|
|
previewType.value = 'sketch'
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-27 16:51:58 +08:00
|
|
|
watch(
|
|
|
|
|
() => proJectId.value,
|
2026-04-02 10:05:29 +08:00
|
|
|
async (newVal, oldVal) => {
|
|
|
|
|
if (oldVal && agentRef.value && typeof agentRef.value.saveSession === 'function') {
|
|
|
|
|
agentRef.value.saveSession(oldVal as string)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-02 13:40:17 +08:00
|
|
|
projectStore.clearProject()
|
2026-04-02 10:05:29 +08:00
|
|
|
|
2026-02-26 16:48:08 +08:00
|
|
|
if (newVal) {
|
2026-04-02 10:05:29 +08:00
|
|
|
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 {
|
2026-03-27 11:45:06 +08:00
|
|
|
MyEvent.emit('projectChange')
|
2026-02-26 16:48:08 +08:00
|
|
|
}
|
2026-02-26 10:19:51 +08:00
|
|
|
}
|
2026-02-26 16:48:08 +08:00
|
|
|
)
|
2026-02-26 10:19:51 +08:00
|
|
|
|
2026-02-26 16:48:08 +08:00
|
|
|
onMounted(() => {
|
2026-03-13 17:23:56 +08:00
|
|
|
MyEvent.add('openReport', handleOpenReport)
|
2026-03-16 11:43:19 +08:00
|
|
|
MyEvent.add('openUrls', handleOpenUrls)
|
2026-03-25 10:11:13 +08:00
|
|
|
MyEvent.add('openSketch', handleOpenSketch)
|
2026-03-02 13:40:17 +08:00
|
|
|
projectStore.clearProject()
|
|
|
|
|
if (proJectId.value) {
|
2026-03-02 11:29:07 +08:00
|
|
|
handleGetProjectInfoAndHistory()
|
2026-02-26 10:19:51 +08:00
|
|
|
}
|
2026-02-23 10:54:17 +08:00
|
|
|
})
|
2026-03-13 17:23:56 +08:00
|
|
|
onUnmounted(() => {
|
|
|
|
|
MyEvent.remove('openReport', handleOpenReport)
|
2026-03-16 11:43:19 +08:00
|
|
|
MyEvent.remove('openUrls', handleOpenUrls)
|
2026-03-17 11:22:47 +08:00
|
|
|
MyEvent.remove('OpenSketch')
|
2026-03-13 17:23:56 +08:00
|
|
|
})
|
2026-02-10 13:05:24 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.agent-wrapper {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
border-top: 0.1rem solid #c9c9c9;
|
2026-02-23 10:54:17 +08:00
|
|
|
padding: 0rem 2.3rem 6rem 2.8rem;
|
|
|
|
|
flex-direction: column;
|
2026-02-25 15:10:03 +08:00
|
|
|
.openVersionTree {
|
2026-02-23 13:28:43 +08:00
|
|
|
padding: 2rem 0rem;
|
2026-02-23 10:54:17 +08:00
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
height: min-content;
|
2026-02-25 15:10:03 +08:00
|
|
|
> .btn {
|
2026-03-03 11:39:56 +08:00
|
|
|
padding: 0 1.45rem;
|
|
|
|
|
line-height: 4rem;
|
2026-02-23 10:54:17 +08:00
|
|
|
font-weight: 500;
|
|
|
|
|
font-size: 1.4rem;
|
2026-03-03 11:23:25 +08:00
|
|
|
border-radius: 3rem;
|
2026-02-23 10:54:17 +08:00
|
|
|
position: relative;
|
|
|
|
|
background: white;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
&::before {
|
|
|
|
|
content: '';
|
|
|
|
|
position: absolute;
|
|
|
|
|
inset: -1px;
|
2026-02-25 15:10:03 +08:00
|
|
|
background: linear-gradient(
|
|
|
|
|
119.03deg,
|
|
|
|
|
rgba(233, 121, 60, 0.8) 1.61%,
|
|
|
|
|
rgba(255, 207, 144, 0.8) 101.01%
|
|
|
|
|
);
|
2026-03-03 11:23:25 +08:00
|
|
|
border-radius: 2.5rem;
|
2026-02-23 10:54:17 +08:00
|
|
|
z-index: -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 15:10:03 +08:00
|
|
|
.content-wrapper {
|
2026-02-23 10:54:17 +08:00
|
|
|
display: flex;
|
|
|
|
|
flex: 1;
|
|
|
|
|
justify-content: space-between;
|
2026-02-24 13:20:05 +08:00
|
|
|
overflow: hidden;
|
2026-02-23 10:54:17 +08:00
|
|
|
}
|
2026-02-10 13:05:24 +08:00
|
|
|
|
|
|
|
|
.c-svg {
|
|
|
|
|
width: initial;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.preview-wrapper {
|
2026-03-03 13:11:05 +08:00
|
|
|
// width: 56%;
|
|
|
|
|
flex: 1;
|
2026-02-10 13:05:24 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|