From ce9843fed9fa83a967b1bfecc8628c0a5bdb31e7 Mon Sep 17 00:00:00 2001 From: "X1627315083@163.com" <1627315083@qq.com> Date: Thu, 19 Mar 2026 10:36:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=94=BB=E5=B8=83=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=9C=BA=E5=88=B6=EF=BC=8C=E6=8A=8A=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E7=94=BB=E5=B8=83=E6=8E=A5=E5=8F=A3=E6=94=BE=E5=88=B0=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=AE=A1=E7=90=86=E4=B8=AD=EF=BC=8C=E5=AE=8C=E5=96=84?= =?UTF-8?q?toRealStyle=E6=8F=90=E7=A4=BA=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FlowCanvas/components/header-tools.vue | 37 +++++++++++++---- .../components/nodes/cards/index.vue | 6 --- .../components/nodes/cards/to-real-style.vue | 10 ++--- .../components/nodes/result-image.vue | 2 + .../Canvas/FlowCanvas/flow-canvas.vue | 32 ++++++++------- src/components/Canvas/FlowCanvas/index.vue | 18 +------- .../Canvas/FlowCanvas/manager/EventManager.ts | 1 + .../Canvas/FlowCanvas/manager/StateManager.ts | 41 +++++++++++++++---- src/components/Canvas/tools/tools.ts | 10 ++--- 9 files changed, 94 insertions(+), 63 deletions(-) diff --git a/src/components/Canvas/FlowCanvas/components/header-tools.vue b/src/components/Canvas/FlowCanvas/components/header-tools.vue index 32249a3..2f840b0 100644 --- a/src/components/Canvas/FlowCanvas/components/header-tools.vue +++ b/src/components/Canvas/FlowCanvas/components/header-tools.vue @@ -11,10 +11,14 @@ - +
+ +
+
+ @@ -26,7 +30,8 @@ import { TOOLS } from '../manager/ToolManager' const props = defineProps({ zoom: { default: 1, type: Number }, - step: { default: 0.1, type: Number } + step: { default: 0.1, type: Number }, + downloadData: { default: {}, type: Object } }) const emit = defineEmits(['export', 'import']) const stateManager = inject('stateManager') as any @@ -109,8 +114,21 @@ cursor: not-allowed; } } - > button { - width: 10rem; + > div{ + position: relative; + > .mask{ + position: absolute !important; + top: 0; + left: 0; + height: 100%; + width: 100%; + zoom: .6; + pointer-events: none; + } + } + button { + // width: 10rem; + padding: 0 2.4rem; height: 3rem; border-radius: 0.4rem; border: none; @@ -118,12 +136,15 @@ color: #fff; font-size: 1.1rem; display: flex; + gap: 0.8rem; align-items: center; justify-content: center; - gap: 0.8rem; + position: relative; + cursor: pointer; &:active { opacity: 0.8; } } + } diff --git a/src/components/Canvas/FlowCanvas/components/nodes/cards/index.vue b/src/components/Canvas/FlowCanvas/components/nodes/cards/index.vue index 447593c..ee7c74c 100644 --- a/src/components/Canvas/FlowCanvas/components/nodes/cards/index.vue +++ b/src/components/Canvas/FlowCanvas/components/nodes/cards/index.vue @@ -155,12 +155,6 @@ } }) }) - stateManager.recordState() - // } else { - // subordNode.data.data.url = - // 'https://s3-alpha-sig.figma.com/img/8ce2/f1a4/12b93da90e5f17109e7430f14837fd14?Expires=1773619200&Key-Pair-Id=APKAQ4GOSFWCW27IBOMQ&Signature=kmLsTFtXJqfvuxj6husWlDkRDMOIRDjzUUjb7zh79GkBKihUHc0f59k5OAImHTPdaiEREUCCpn~8sQ-si5lenuauJpApCmAU~NsxjfQhuh9m5O~GiHenr2fKu0DIJ75-oCE3859fyxoSFXQgZ9PRmeb98kikMR6uRX9nI5TPUHgKO8ZgkhDBTW~iyaDT~1ybnoK7elPa6T2VzfO-bpIyY-MZ71VRq3RxwmZRxduqHEb3Dh-jjrHyh2SoQsHmUjSJOf-uYilfvpGUResZAjAq8ZVLEjvhzKC2bmCNZIp3RmhYO8ctU7pd5t91J6Xaa6jBLtGfMxbqIm652EC79K0RoA__' - // setTimeout(() => stateManager.recordState()) - // } } //删除功能卡片 const onDeleteClick = ()=>{ diff --git a/src/components/Canvas/FlowCanvas/components/nodes/cards/to-real-style.vue b/src/components/Canvas/FlowCanvas/components/nodes/cards/to-real-style.vue index 2e9d4d2..e28b9d8 100644 --- a/src/components/Canvas/FlowCanvas/components/nodes/cards/to-real-style.vue +++ b/src/components/Canvas/FlowCanvas/components/nodes/cards/to-real-style.vue @@ -28,23 +28,23 @@ const shortcutList = ref([ { label: 'Change the...', - value: 'Change the...' + value: 'Change the style to a realistic design. ' }, { label: 'Bright Colors...', - value: 'Bright Colors...' + value: 'Bright colors with modern patterns, change the style to a realistic furniture design. ' }, { label: 'Make the...', - value: 'Make the...' + value: 'Make the structure more refined and balanced, change the style to a realistic furniture style. ' }, { label: 'Imagine...', - value: 'Imagine...' + value: 'Imagine this furniture with detailed fabric textures, change the style to a realistic design. ' }, { label: 'Wood Materials with...', - value: 'Wood Materials with...' + value: 'Wood materials with natural oak texture and soft fabric, change the style to a realistic furniture design.' } ]) const modeList = ref([ diff --git a/src/components/Canvas/FlowCanvas/components/nodes/result-image.vue b/src/components/Canvas/FlowCanvas/components/nodes/result-image.vue index 1373186..edde429 100644 --- a/src/components/Canvas/FlowCanvas/components/nodes/result-image.vue +++ b/src/components/Canvas/FlowCanvas/components/nodes/result-image.vue @@ -161,6 +161,7 @@ item.scale.x = -item.scale.x }) stateManager.recordState() + stateManager.exportFlow(stateManager.saveCanvasTimeInterval) } }, { @@ -174,6 +175,7 @@ item.scale.y = -item.scale.y }) stateManager.recordState() + stateManager.exportFlow(stateManager.saveCanvasTimeInterval) } } ]) diff --git a/src/components/Canvas/FlowCanvas/flow-canvas.vue b/src/components/Canvas/FlowCanvas/flow-canvas.vue index ae727e8..314951f 100644 --- a/src/components/Canvas/FlowCanvas/flow-canvas.vue +++ b/src/components/Canvas/FlowCanvas/flow-canvas.vue @@ -47,7 +47,7 @@ - + () const nodeTypes = ref([NODE_TYPE.INPUT, NODE_TYPE.SECONDARY, NODE_TYPE.OUTPUT, NODE_TYPE.ALONE]) - // 状态管理器 - const stateManager = new StateManager({ vueFlow }) + const stateManager = new StateManager({ vueFlow,sketchId:props.config.imgId }) provide('stateManager', stateManager) // 事件管理器 @@ -191,29 +190,34 @@ } // 导出流程 const getFlowJson = () => { - if(!stateManager.isSave.value)return '' return JSON.stringify(stateManager.nodes.value) } - const exportFlow = () => { + const downloadData = ref({ + amount: 0, + progress: 0, + status: 'success',//success + }) + const exportFlow = async () => { // console.log(vueFlow.value) // console.log(vueFlow.value.toImage) let arr = stateManager.nodes.value.filter((v) => v.data.type === NODE_COMPONENT.RESULT_IMAGE) let imgList = [] - arr.forEach((v) => { + arr.forEach((v,i) => { v.data.data.imageProcessTasks.forEach((item,index) => { let url = item.url let name = url?.split(".").pop().split("?").shift(); - imgList.push({url:url,name:`${v.data.type}${index == 0?'':index}.${name}`}) + imgList.push({url:url,name:`${v.data.type}${i}-${index == 0?'':index}.${name}`}) }) }) - downImgListToZip(imgList) - console.log(imgList) + downloadData.value.amount = imgList.length + downloadData.value.status = 'loading' + await downImgListToZip(imgList,(progress)=>{ + downloadData.value.progress = progress + if(progress == downloadData.value.amount){ + downloadData.value.status = 'success' + } + }) return - // flowManager.exportFlow() - const str = getFlowJson() - stateManager.isSave.value = false - emit('exportFlow', str) - // localStorage.setItem('flow_json', str) } // 导入流程 const importFlow = async (json) => { diff --git a/src/components/Canvas/FlowCanvas/index.vue b/src/components/Canvas/FlowCanvas/index.vue index 98f83a6..2b64496 100644 --- a/src/components/Canvas/FlowCanvas/index.vue +++ b/src/components/Canvas/FlowCanvas/index.vue @@ -1,6 +1,6 @@ @@ -31,22 +31,7 @@ config.value.json = json dialogVisible.value = true } - const exportFlow = async (str) => { - if(!config.value.imgId || !str)return - await new Promise((resolve) => { - putSketchFlowCanvas({ - id: config.value.imgId, - canvasData: str },true).then(() => { - resolve(true) - }).catch(() => { - resolve(true) - }) - }) - } - const close = async () => { - const str = flowCanvasRef.value?.getFlowJson() - await exportFlow(str) dialogVisible.value = false } const handleBeforeUnload = (event) => { @@ -67,7 +52,6 @@ defineExpose({ open, close, - exportFlow })