fix
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted, reactive, toRefs } from "vue";
|
||||
import { ref, onMounted, onUnmounted, reactive, watch } from "vue";
|
||||
import VersionDetail from './versionDetail.vue'
|
||||
import ChatDetail from './chatDetail.vue'
|
||||
import { useProjectStore } from '@/stores'
|
||||
import { getChatNodeDetail, getNodeAncestors } from '@/api/versitonTree'
|
||||
|
||||
//const props = defineProps({
|
||||
//})
|
||||
const emit = defineEmits([
|
||||
])
|
||||
|
||||
const projectStore = useProjectStore()
|
||||
|
||||
const detailData = ref({
|
||||
id:1,
|
||||
versionDetail:{
|
||||
@@ -17,9 +23,25 @@ const detailData = ref({
|
||||
userChatDetail:{
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
watch(()=>projectStore.state.nodeId, (newVal, oldVal) => {
|
||||
console.log(newVal)
|
||||
if(newVal){
|
||||
getChatNodeDetail({
|
||||
projectId: projectStore.state.id,
|
||||
id: newVal
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
})
|
||||
getNodeAncestors({
|
||||
projectId: projectStore.state.id,
|
||||
id: newVal
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
})
|
||||
}
|
||||
},{ immediate: true })
|
||||
onMounted(()=>{
|
||||
})
|
||||
onUnmounted(()=>{
|
||||
|
||||
@@ -5,7 +5,7 @@ import Detail from './detail/index.vue'
|
||||
// import { versionsList } from './tools/versionsData'
|
||||
import { findAndAddChild, findAndRemoveChild } from '../../../../../utils/treeDiagram'
|
||||
import { useProjectStore } from '@/stores'
|
||||
import { versionTree, getChatNodeDetail } from '@/api/versitonTree'
|
||||
import { versionTree } from '@/api/versitonTree'
|
||||
|
||||
const props = defineProps({
|
||||
versionTreeData: {
|
||||
@@ -25,34 +25,39 @@ const props = defineProps({
|
||||
const versionsList = ref([])
|
||||
|
||||
const projectStore = useProjectStore()
|
||||
let oldProjectId:any = ''
|
||||
watch(()=>props.versionTreeData?.drawer, (newVal, oldVal) => {
|
||||
console.log(newVal)
|
||||
if(newVal){
|
||||
versionTree({
|
||||
projectId: projectStore.state.id
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
// setVersionsList
|
||||
// versionsList.value = res.data
|
||||
})
|
||||
console.log(newVal,oldProjectId,projectStore.state.id)
|
||||
if(newVal && oldProjectId !== projectStore.state.id && projectStore.state.id){
|
||||
getVersionTree()
|
||||
oldProjectId = JSON.parse(JSON.stringify(projectStore.state.id))
|
||||
}
|
||||
})
|
||||
|
||||
const getVersionTree = ()=>{
|
||||
versionTree({
|
||||
projectId: projectStore.state.id
|
||||
}).then(res => {
|
||||
setVersionsList([res])
|
||||
})
|
||||
}
|
||||
|
||||
const setVersionsList = (res)=>{
|
||||
versionsList.value = [res]
|
||||
//设置versionId
|
||||
function traverseArray(items,father, callback) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i]
|
||||
if(!item.url)continue
|
||||
callback(item, i,father)
|
||||
if (item.children && Array.isArray(item.children) && item.children.length > 0) {
|
||||
traverseArray(item.children, item, callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
traverseArray(versionsList.value,'',(item,i,father)=>{
|
||||
traverseArray(res,'',(item,i,father)=>{
|
||||
item.versionId = father?`${father.versionId}-${i+1}`:'1'
|
||||
})
|
||||
versionsList.value = res
|
||||
}
|
||||
|
||||
const treeRef = ref(null)
|
||||
@@ -104,7 +109,7 @@ const versionDelete = (versionDetail)=>{
|
||||
let data = reactive({})
|
||||
// onMounted(() => {setVersionsList('')})
|
||||
onUnmounted(() => {})
|
||||
defineExpose({})
|
||||
defineExpose({getVersionTree})
|
||||
const {} = toRefs(data)
|
||||
</script>
|
||||
<template>
|
||||
@@ -146,6 +151,7 @@ const {} = toRefs(data)
|
||||
<div class="versionTreeBox">
|
||||
<div class="tree">
|
||||
<Tree
|
||||
v-if="versionsList.length > 0"
|
||||
ref="treeRef"
|
||||
:versionsList="versionsList"
|
||||
:treeState="treeState"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
import { ref, onMounted, onUnmounted, reactive, toRefs, watch, nextTick } from "vue";
|
||||
import view1Item from './view1Item.vue'
|
||||
import view2 from './view2/index.vue'
|
||||
import { useProjectStore } from '@/stores'
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
versionsList: {
|
||||
@@ -28,6 +30,8 @@ const view1Ref = ref(null)
|
||||
|
||||
const isLoad = ref(false)
|
||||
const treeStateTime = ref(true)
|
||||
const projectStore = useProjectStore()
|
||||
|
||||
|
||||
watch(()=>props.treeState,(newVal,oldVal)=>{
|
||||
treeStateTime.value = false
|
||||
@@ -68,6 +72,8 @@ const initialize = ()=>{
|
||||
|
||||
const setSelectItem = (item)=>{
|
||||
if(!item.versionId)return
|
||||
console.log(item)
|
||||
// projectStore.setProject({latestNodeId: item.id})
|
||||
emit('update:selectItem', {...item})
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ const { layout } = useLayout()
|
||||
async function layoutGraph(direction) {
|
||||
setTimeout(() => {
|
||||
nodes.value = layout(nodes.value, edges.value, direction)
|
||||
console.log(nodes.value)
|
||||
nextTick(() => {
|
||||
fitView()
|
||||
})
|
||||
@@ -196,8 +195,10 @@ defineExpose({push})
|
||||
cursor: pointer;
|
||||
background-color: var(--treeItem-background);
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
&.active{
|
||||
background-color: var(--treeItem-active-background);
|
||||
// background-color: var(--treeItem-active-background);
|
||||
border: 2px solid #000;
|
||||
}
|
||||
&.start{
|
||||
background-color: #7A7A7A;
|
||||
|
||||
@@ -9,30 +9,50 @@
|
||||
<Preview :type="previewType" :sketchList="sketchList" />
|
||||
</div>
|
||||
</div>
|
||||
<VersionTreeIndex v-model:versionTreeData="versionTreeData" />
|
||||
<VersionTreeIndex ref="VersionTreeIndexRef" v-model:versionTreeData="versionTreeData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import Agent from './components/Agent.vue'
|
||||
import Preview from './components/Preview.vue'
|
||||
import VersionTreeIndex from './components/versionTree/index.vue'
|
||||
import { useProjectStore } from '@/stores'
|
||||
import { getProjectInfo } from '@/api/agent'
|
||||
|
||||
|
||||
const agentTitle = ref('Retro Sofa Sketch')
|
||||
const previewType = ref<'sketch' | 'report'>('sketch')
|
||||
|
||||
const VersionTreeIndexRef = ref()
|
||||
|
||||
const sketchList = ref([])
|
||||
const updateSketchList = (newVal) => {
|
||||
console.log('newVal', newVal)
|
||||
sketchList.value = newVal
|
||||
// VersionTreeIndexRef.value.getVersionTree()
|
||||
}
|
||||
|
||||
const versionTreeData = ref({
|
||||
drawer: false,
|
||||
list: computed(() => {
|
||||
return []
|
||||
})
|
||||
})
|
||||
|
||||
const projectStore = useProjectStore()
|
||||
watch(()=>projectStore.state.id, (newVal, oldVal) => {
|
||||
if(newVal){
|
||||
getProjectInfo({ id: newVal }).then(res => {
|
||||
projectStore.setProject(res.project)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(()=>{
|
||||
if(projectStore.state.id){
|
||||
getProjectInfo({ id: projectStore.state.id }).then(res => {
|
||||
projectStore.setProject(res.project)
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user