fix
This commit is contained in:
@@ -27,3 +27,16 @@ export interface CreateProjectParamsType {
|
|||||||
export const createProject = (data: CreateProjectParamsType): Promise<any> => {
|
export const createProject = (data: CreateProjectParamsType): Promise<any> => {
|
||||||
return request({ url: '/api/project/init', method: 'post', data })
|
return request({ url: '/api/project/init', method: 'post', data })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取项目信息
|
||||||
|
* @param data 获取项目信息参数
|
||||||
|
* @param data.id 项目id
|
||||||
|
* @returns 获取项目信息
|
||||||
|
*/
|
||||||
|
export const getProjectInfo = (data) => {
|
||||||
|
return request({
|
||||||
|
url: `/api/project/${data.id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -25,4 +25,17 @@ export const versionTree = (data) => {
|
|||||||
url: `/api/version/${data.projectId}/chat/tree`,
|
url: `/api/version/${data.projectId}/chat/tree`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取版本树
|
||||||
|
* @param data 获取版本树的参数
|
||||||
|
* @param data.projectId 项目id
|
||||||
|
* @returns 获取版本树
|
||||||
|
*/
|
||||||
|
export const getNodeAncestors = (data) => {
|
||||||
|
return request({
|
||||||
|
url: `/api/version/${data.projectId}/chat/node/${data.id}/ancestors`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -3,13 +3,12 @@ import { ref, computed } from 'vue'
|
|||||||
export const useProjectStore = defineStore('project', () => {
|
export const useProjectStore = defineStore('project', () => {
|
||||||
const state = ref({// 项目参数
|
const state = ref({// 项目参数
|
||||||
id: '',
|
id: '',
|
||||||
|
nodeId: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
const setProject = (obj: any) => {
|
const setProject = (obj: any) => {
|
||||||
for (const key in obj) {
|
for (const key in obj) {
|
||||||
if(state.value[key]){
|
state.value[key] = obj[key]
|
||||||
state.value[key] = obj[key]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,3 +22,4 @@ export const useProjectStore = defineStore('project', () => {
|
|||||||
setId
|
setId
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
16
src/stores/versionTree.ts
Normal file
16
src/stores/versionTree.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { ref, computed } from 'vue'
|
||||||
|
export const useVersionTreeStore = defineStore('versionTree', () => {
|
||||||
|
const state = ref({
|
||||||
|
nodeDetail: {
|
||||||
|
|
||||||
|
},// 节点详情
|
||||||
|
})
|
||||||
|
|
||||||
|
const setNodeDetail = (v: any) => { state.value.nodeDetail = v }
|
||||||
|
|
||||||
|
return {
|
||||||
|
state,
|
||||||
|
setNodeDetail,
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -1,11 +1,17 @@
|
|||||||
<script setup lang="ts">
|
<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 VersionDetail from './versionDetail.vue'
|
||||||
import ChatDetail from './chatDetail.vue'
|
import ChatDetail from './chatDetail.vue'
|
||||||
|
import { useProjectStore } from '@/stores'
|
||||||
|
import { getChatNodeDetail, getNodeAncestors } from '@/api/versitonTree'
|
||||||
|
|
||||||
//const props = defineProps({
|
//const props = defineProps({
|
||||||
//})
|
//})
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const projectStore = useProjectStore()
|
||||||
|
|
||||||
const detailData = ref({
|
const detailData = ref({
|
||||||
id:1,
|
id:1,
|
||||||
versionDetail:{
|
versionDetail:{
|
||||||
@@ -17,9 +23,25 @@ const detailData = ref({
|
|||||||
userChatDetail:{
|
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(()=>{
|
onMounted(()=>{
|
||||||
})
|
})
|
||||||
onUnmounted(()=>{
|
onUnmounted(()=>{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import Detail from './detail/index.vue'
|
|||||||
// import { versionsList } from './tools/versionsData'
|
// import { versionsList } from './tools/versionsData'
|
||||||
import { findAndAddChild, findAndRemoveChild } from '../../../../../utils/treeDiagram'
|
import { findAndAddChild, findAndRemoveChild } from '../../../../../utils/treeDiagram'
|
||||||
import { useProjectStore } from '@/stores'
|
import { useProjectStore } from '@/stores'
|
||||||
import { versionTree, getChatNodeDetail } from '@/api/versitonTree'
|
import { versionTree } from '@/api/versitonTree'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
versionTreeData: {
|
versionTreeData: {
|
||||||
@@ -25,34 +25,39 @@ const props = defineProps({
|
|||||||
const versionsList = ref([])
|
const versionsList = ref([])
|
||||||
|
|
||||||
const projectStore = useProjectStore()
|
const projectStore = useProjectStore()
|
||||||
|
let oldProjectId:any = ''
|
||||||
watch(()=>props.versionTreeData?.drawer, (newVal, oldVal) => {
|
watch(()=>props.versionTreeData?.drawer, (newVal, oldVal) => {
|
||||||
console.log(newVal)
|
console.log(newVal,oldProjectId,projectStore.state.id)
|
||||||
if(newVal){
|
if(newVal && oldProjectId !== projectStore.state.id && projectStore.state.id){
|
||||||
versionTree({
|
getVersionTree()
|
||||||
projectId: projectStore.state.id
|
oldProjectId = JSON.parse(JSON.stringify(projectStore.state.id))
|
||||||
}).then(res => {
|
|
||||||
console.log(res)
|
|
||||||
// setVersionsList
|
|
||||||
// versionsList.value = res.data
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const getVersionTree = ()=>{
|
||||||
|
versionTree({
|
||||||
|
projectId: projectStore.state.id
|
||||||
|
}).then(res => {
|
||||||
|
setVersionsList([res])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const setVersionsList = (res)=>{
|
const setVersionsList = (res)=>{
|
||||||
versionsList.value = [res]
|
|
||||||
//设置versionId
|
//设置versionId
|
||||||
function traverseArray(items,father, callback) {
|
function traverseArray(items,father, callback) {
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
const item = items[i]
|
const item = items[i]
|
||||||
|
if(!item.url)continue
|
||||||
callback(item, i,father)
|
callback(item, i,father)
|
||||||
if (item.children && Array.isArray(item.children) && item.children.length > 0) {
|
if (item.children && Array.isArray(item.children) && item.children.length > 0) {
|
||||||
traverseArray(item.children, item, callback)
|
traverseArray(item.children, item, callback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
traverseArray(versionsList.value,'',(item,i,father)=>{
|
traverseArray(res,'',(item,i,father)=>{
|
||||||
item.versionId = father?`${father.versionId}-${i+1}`:'1'
|
item.versionId = father?`${father.versionId}-${i+1}`:'1'
|
||||||
})
|
})
|
||||||
|
versionsList.value = res
|
||||||
}
|
}
|
||||||
|
|
||||||
const treeRef = ref(null)
|
const treeRef = ref(null)
|
||||||
@@ -104,7 +109,7 @@ const versionDelete = (versionDetail)=>{
|
|||||||
let data = reactive({})
|
let data = reactive({})
|
||||||
// onMounted(() => {setVersionsList('')})
|
// onMounted(() => {setVersionsList('')})
|
||||||
onUnmounted(() => {})
|
onUnmounted(() => {})
|
||||||
defineExpose({})
|
defineExpose({getVersionTree})
|
||||||
const {} = toRefs(data)
|
const {} = toRefs(data)
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
@@ -146,6 +151,7 @@ const {} = toRefs(data)
|
|||||||
<div class="versionTreeBox">
|
<div class="versionTreeBox">
|
||||||
<div class="tree">
|
<div class="tree">
|
||||||
<Tree
|
<Tree
|
||||||
|
v-if="versionsList.length > 0"
|
||||||
ref="treeRef"
|
ref="treeRef"
|
||||||
:versionsList="versionsList"
|
:versionsList="versionsList"
|
||||||
:treeState="treeState"
|
:treeState="treeState"
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
import { ref, onMounted, onUnmounted, reactive, toRefs, watch, nextTick } from "vue";
|
import { ref, onMounted, onUnmounted, reactive, toRefs, watch, nextTick } from "vue";
|
||||||
import view1Item from './view1Item.vue'
|
import view1Item from './view1Item.vue'
|
||||||
import view2 from './view2/index.vue'
|
import view2 from './view2/index.vue'
|
||||||
|
import { useProjectStore } from '@/stores'
|
||||||
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
versionsList: {
|
versionsList: {
|
||||||
@@ -28,6 +30,8 @@ const view1Ref = ref(null)
|
|||||||
|
|
||||||
const isLoad = ref(false)
|
const isLoad = ref(false)
|
||||||
const treeStateTime = ref(true)
|
const treeStateTime = ref(true)
|
||||||
|
const projectStore = useProjectStore()
|
||||||
|
|
||||||
|
|
||||||
watch(()=>props.treeState,(newVal,oldVal)=>{
|
watch(()=>props.treeState,(newVal,oldVal)=>{
|
||||||
treeStateTime.value = false
|
treeStateTime.value = false
|
||||||
@@ -68,6 +72,8 @@ const initialize = ()=>{
|
|||||||
|
|
||||||
const setSelectItem = (item)=>{
|
const setSelectItem = (item)=>{
|
||||||
if(!item.versionId)return
|
if(!item.versionId)return
|
||||||
|
console.log(item)
|
||||||
|
// projectStore.setProject({latestNodeId: item.id})
|
||||||
emit('update:selectItem', {...item})
|
emit('update:selectItem', {...item})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ const { layout } = useLayout()
|
|||||||
async function layoutGraph(direction) {
|
async function layoutGraph(direction) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
nodes.value = layout(nodes.value, edges.value, direction)
|
nodes.value = layout(nodes.value, edges.value, direction)
|
||||||
console.log(nodes.value)
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
fitView()
|
fitView()
|
||||||
})
|
})
|
||||||
@@ -196,8 +195,10 @@ defineExpose({push})
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: var(--treeItem-background);
|
background-color: var(--treeItem-background);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
overflow: hidden;
|
||||||
&.active{
|
&.active{
|
||||||
background-color: var(--treeItem-active-background);
|
// background-color: var(--treeItem-active-background);
|
||||||
|
border: 2px solid #000;
|
||||||
}
|
}
|
||||||
&.start{
|
&.start{
|
||||||
background-color: #7A7A7A;
|
background-color: #7A7A7A;
|
||||||
|
|||||||
@@ -9,30 +9,50 @@
|
|||||||
<Preview :type="previewType" :sketchList="sketchList" />
|
<Preview :type="previewType" :sketchList="sketchList" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<VersionTreeIndex v-model:versionTreeData="versionTreeData" />
|
<VersionTreeIndex ref="VersionTreeIndexRef" v-model:versionTreeData="versionTreeData" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from 'vue'
|
import { ref, watch, onMounted } from 'vue'
|
||||||
import Agent from './components/Agent.vue'
|
import Agent from './components/Agent.vue'
|
||||||
import Preview from './components/Preview.vue'
|
import Preview from './components/Preview.vue'
|
||||||
import VersionTreeIndex from './components/versionTree/index.vue'
|
import VersionTreeIndex from './components/versionTree/index.vue'
|
||||||
|
import { useProjectStore } from '@/stores'
|
||||||
|
import { getProjectInfo } from '@/api/agent'
|
||||||
|
|
||||||
|
|
||||||
const agentTitle = ref('Retro Sofa Sketch')
|
const agentTitle = ref('Retro Sofa Sketch')
|
||||||
const previewType = ref<'sketch' | 'report'>('sketch')
|
const previewType = ref<'sketch' | 'report'>('sketch')
|
||||||
|
|
||||||
|
const VersionTreeIndexRef = ref()
|
||||||
|
|
||||||
const sketchList = ref([])
|
const sketchList = ref([])
|
||||||
const updateSketchList = (newVal) => {
|
const updateSketchList = (newVal) => {
|
||||||
console.log('newVal', newVal)
|
console.log('newVal', newVal)
|
||||||
sketchList.value = newVal
|
sketchList.value = newVal
|
||||||
|
// VersionTreeIndexRef.value.getVersionTree()
|
||||||
}
|
}
|
||||||
|
|
||||||
const versionTreeData = ref({
|
const versionTreeData = ref({
|
||||||
drawer: false,
|
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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user