From 9a7afa8f6e6f889fbacd14b68aee00626ba369f5 Mon Sep 17 00:00:00 2001 From: zhanghao <774378400@qq.com> Date: Mon, 17 Nov 2025 14:54:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8A=82=E7=82=B9=E7=BC=A9=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/flow.js | 28 + src/views/flow/components/NodeTitle.vue | 388 ++++---- src/views/flow/config.js | 5 + src/views/flow/index.vue | 12 +- src/views/flow/nodes/common/serviceNode.vue | 247 +++-- src/views/flow/nodes/common/startNode.vue | 63 +- src/views/flow/nodes/function/loop.vue | 170 ++-- src/views/flow/nodes/function/sleep.vue | 868 ++++++++--------- src/views/flow/nodes/function/switch.vue | 998 +++++++++++--------- vite.config.js | 4 +- 10 files changed, 1564 insertions(+), 1219 deletions(-) diff --git a/src/utils/flow.js b/src/utils/flow.js index 94f7557..10187e6 100644 --- a/src/utils/flow.js +++ b/src/utils/flow.js @@ -127,6 +127,34 @@ export const formatTableData = (arr, data = {}) => { } export const addNewEdge = (nodeId) => { + const { edges } = lf.getGraphData(); + const ttt = edges.slice(); // 浅拷贝(比 JSON 深拷贝高效 10x+) + + const edgesToDelete = ttt.filter(_edge => + _edge.sourceNodeId === nodeId || _edge.targetNodeId === nodeId + ); + + edgesToDelete.forEach(edge => lf.deleteEdge(edge.id)); + + if (window.addNewEdgeTimer) { + clearTimeout(window.addNewEdgeTimer); // 清理上一次未执行的定时器 + } + + window.addNewEdgeTimer = setTimeout(() => { + edgesToDelete.forEach(item => { + lf.addEdge({ + type: "bezier", + sourceNodeId: item.sourceNodeId, + targetNodeId: item.targetNodeId, + sourceAnchorId: item.sourceAnchorId, + targetAnchorId: item.targetAnchorId + }); + }) + delete window.addNewEdgeTimer; + }, 50) +} + +export const newEdge = (nodeId) => { const { edges } = lf.getGraphData(); const arr = JSON.parse(JSON.stringify(edges)) arr.forEach(_edge => { diff --git a/src/views/flow/components/NodeTitle.vue b/src/views/flow/components/NodeTitle.vue index b7f61b4..1a66002 100644 --- a/src/views/flow/components/NodeTitle.vue +++ b/src/views/flow/components/NodeTitle.vue @@ -1,171 +1,217 @@ - - - \ No newline at end of file + + + diff --git a/src/views/flow/config.js b/src/views/flow/config.js index 46b30e1..9584e80 100644 --- a/src/views/flow/config.js +++ b/src/views/flow/config.js @@ -42,6 +42,11 @@ export const lfConfig = { // foldSize: 30, // 折叠后显示的图标尺寸 // }, edgeType: "bezier", + zoomConfig: { + min: 0.05, // 最小缩放比例(支持更小值,如 0.01,但不建议过小) + max: 3, // 最大缩放比例(可自定义) + step: 0.1 // 每次滚轮缩放的步长(默认 0.1) + }, style: { anchor: { show: true, // 强制全局锚点显示 diff --git a/src/views/flow/index.vue b/src/views/flow/index.vue index c0541a3..df850c9 100644 --- a/src/views/flow/index.vue +++ b/src/views/flow/index.vue @@ -54,7 +54,7 @@ - +