From 59a9c7c80f6fc9f7f4aeca1863a9e62083e748e8 Mon Sep 17 00:00:00 2001 From: "X1627315083@163.com" <1627315083@qq.com> Date: Thu, 19 Mar 2026 17:14:57 +0800 Subject: [PATCH 1/9] fix --- .../components/nodes/result-image.vue | 24 +++++++------------ src/components/Canvas/FlowCanvas/index.vue | 2 +- .../Canvas/FlowCanvas/manager/StateManager.ts | 7 +++--- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/components/Canvas/FlowCanvas/components/nodes/result-image.vue b/src/components/Canvas/FlowCanvas/components/nodes/result-image.vue index d4ee34e..64176b8 100644 --- a/src/components/Canvas/FlowCanvas/components/nodes/result-image.vue +++ b/src/components/Canvas/FlowCanvas/components/nodes/result-image.vue @@ -23,7 +23,6 @@ import myEvent from '@/utils/myEvent' - import { downloadImage, base64Tofile } from '../../../tools/tools' + import { downloadImage } from '../../../tools/tools' import { reactive, ref, onBeforeUnmount, useAttrs, inject, watch, computed, onMounted } from 'vue' import HighlightAdmin from '@/components/highlightAdmin.vue' import { NODE_DATATYPE } from '../../tools/index.d' - import { uploadImage } from '@/api/upload' const openImagePreview = inject('openImagePreview') as (url: string) => void const openThreeModelPreview = inject('openThreeModelPreview') as (url: string) => void const props = defineProps({ @@ -205,25 +203,19 @@ eventManager.registerEvents() } const depthCanvasWorkbench = (options)=>{ - console.log(options) - // 1. 提取 MIME 类型和 Base64 数据 - const file = base64Tofile(options.url,'image.png') - const formData = new FormData() - formData.append('file', file) - uploadImage(formData).then((res) => { - data.imageProcessTasks.forEach((item) => { - if(item.taskId == options.taskId){ - item.url = res - } - }) + data.imageProcessTasks.forEach((item) => { + if(item.taskId == options.taskId){ + item.url = options.url + item.canvasId = options.canvasId || null + } }) - } const onEdit = (item: any) => { const data = { url:item.url, - id: item.taskId, + canvasId: item?.canvasId || null, + sketchId: stateManager.sketchId.value, onWorkbench:(options)=>{ let workbenchData = { ...item, diff --git a/src/components/Canvas/FlowCanvas/index.vue b/src/components/Canvas/FlowCanvas/index.vue index 1d3c144..bc65895 100644 --- a/src/components/Canvas/FlowCanvas/index.vue +++ b/src/components/Canvas/FlowCanvas/index.vue @@ -8,7 +8,7 @@ import FullscreenDialog from '../components/fullscreen-dialog.vue' import flowCanvas from './flow-canvas.vue' import { ref } from 'vue' - import { getSketchFlowCanvas, putSketchFlowCanvas } from '@/api/flow-canvas' + import { getSketchFlowCanvas } from '@/api/flow-canvas' import { useI18n } from 'vue-i18n' const dialogVisible = ref(false) diff --git a/src/components/Canvas/FlowCanvas/manager/StateManager.ts b/src/components/Canvas/FlowCanvas/manager/StateManager.ts index 0b0ee25..891d17c 100644 --- a/src/components/Canvas/FlowCanvas/manager/StateManager.ts +++ b/src/components/Canvas/FlowCanvas/manager/StateManager.ts @@ -63,8 +63,7 @@ export class StateManager { this.mxHistory = ref(50) this.historyList = ref([]) this.historyIndex = ref(0) - - this.sketchId = options.sketchId + this.sketchId = ref(options.sketchId) this.saveCanvasTimeInterval = 6000 this.saveCanvasTime = null @@ -188,12 +187,12 @@ export class StateManager { } /** 画布数据存储 */ async exportFlow (time:number = 0){ - if(!this.sketchId)return + if(!this.sketchId.value)return clearTimeout(this.saveCanvasTime) await new Promise((resolve) => { this.saveCanvasTime = setTimeout(()=>{ putSketchFlowCanvas({ - id: this.sketchId, + id: this.sketchId.value, canvasData: JSON.stringify(this.nodes.value) }).then(() => { resolve(true) }).catch(() => { From ecf928691e9f4e368109b4b54b3ae58b1e7fe0bf Mon Sep 17 00:00:00 2001 From: lzp Date: Fri, 20 Mar 2026 09:46:15 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=B7=B1=E5=BA=A6=E7=94=BB=E5=B8=83?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/depth-canvas.ts | 41 +++++++++++++++++++ .../components/depth-header-tools.vue | 4 +- .../Canvas/DepthCanvas/depth-canvas.vue | 9 ++-- src/components/Canvas/DepthCanvas/index.vue | 41 ++++++++++++++----- .../DepthCanvas/manager/CanvasManager.ts | 18 ++++---- 5 files changed, 90 insertions(+), 23 deletions(-) create mode 100644 src/api/depth-canvas.ts diff --git a/src/api/depth-canvas.ts b/src/api/depth-canvas.ts new file mode 100644 index 0000000..76a1db7 --- /dev/null +++ b/src/api/depth-canvas.ts @@ -0,0 +1,41 @@ +import request from '@/utils/request' + +/** + * 获取深度画布 + * @param id depth id + * @returns 深度画布数据 + */ +export const getDepthCanvas = (id: string) => { + return request({ + url: `/api/deep-canvas/${id}`, + method: 'get', + loading: true, + }) +} + +/** + * 保存深度画布 + * @param data 保存depth的画布数据 + * @returns 保存结果 + */ +export const saveDepthCanvas = (data: object) => { + return request({ + url: `/api/deep-canvas/update`, + method: 'put', + data, + loading: true, + }) +} + +/** + * 删除深度画布 + * @param id depth id + * @returns 删除结果 + */ +export const deleteDepthCanvas = (id: string) => { + return request({ + url: `/api/deep-canvas/${id}`, + method: 'delete', + loading: true, + }) +} diff --git a/src/components/Canvas/DepthCanvas/components/depth-header-tools.vue b/src/components/Canvas/DepthCanvas/components/depth-header-tools.vue index 0b0457b..0407255 100644 --- a/src/components/Canvas/DepthCanvas/components/depth-header-tools.vue +++ b/src/components/Canvas/DepthCanvas/components/depth-header-tools.vue @@ -178,8 +178,8 @@ } const onWorkbench = async () => { exportCanvasToImage(canvasManager.canvas).then((url) => { - const json = canvasManager.getCanvasJSON() - emit('workbench', { url, json }) + const { canvas, images } = canvasManager.getCanvasDisUrlJSON() + emit('workbench', { url, canvas, images }) }) } diff --git a/src/components/Canvas/DepthCanvas/depth-canvas.vue b/src/components/Canvas/DepthCanvas/depth-canvas.vue index 35855ac..66e569c 100644 --- a/src/components/Canvas/DepthCanvas/depth-canvas.vue +++ b/src/components/Canvas/DepthCanvas/depth-canvas.vue @@ -89,16 +89,19 @@ globalStore.setLoading(true) keyEventManager.registerEvents() const url = props.config.url || '' - const json = props.config.json || '' + const canvasData = props.config.canvasData || '' await canvasManager.initCanvas({ canvasRef, canvasViewWidth: canvasContainerRef.value.clientWidth, canvasViewHeight: canvasContainerRef.value.clientHeight, canvasWidth: props.config.width || 750, canvasHeight: props.config.height || 600, - url: json ? '' : url + url: canvasData ? '' : url }) - if (json) await canvasManager.loadJSON(json) + if (canvasData) { + const json = canvasManager.processCanvasDisUrlJSON(canvasData) + await canvasManager.loadJSON(json) + } globalStore.setLoading(false) stateManager.onMounted() diff --git a/src/components/Canvas/DepthCanvas/index.vue b/src/components/Canvas/DepthCanvas/index.vue index f560050..d53a8ba 100644 --- a/src/components/Canvas/DepthCanvas/index.vue +++ b/src/components/Canvas/DepthCanvas/index.vue @@ -9,33 +9,54 @@ + diff --git a/src/components/Canvas/DepthCanvas/depth-canvas.vue b/src/components/Canvas/DepthCanvas/depth-canvas.vue index 66e569c..60e2e52 100644 --- a/src/components/Canvas/DepthCanvas/depth-canvas.vue +++ b/src/components/Canvas/DepthCanvas/depth-canvas.vue @@ -6,8 +6,10 @@