From d3d95b13badd8e09620b6f8695a1dd4dca9f87dc Mon Sep 17 00:00:00 2001 From: ZLY Date: Mon, 5 Jan 2026 09:59:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(convertFlowData):=20=E5=BC=80=E5=A7=8B/?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E8=8A=82=E7=82=B9=E5=A2=9E=E5=8A=A0=E7=AE=80?= =?UTF-8?q?=E5=8D=95=E7=9A=84=E5=94=AF=E4=B8=80=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/convertFlowData.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/utils/convertFlowData.ts b/src/utils/convertFlowData.ts index 4ff6ad8..2d6e809 100644 --- a/src/utils/convertFlowData.ts +++ b/src/utils/convertFlowData.ts @@ -25,11 +25,12 @@ export const convertFlowData = (flowData: any, useDefault = true) => { if (!flowData || Object.keys(flowData).length === 0) { // 如果useDefault为true且flowData为空,则返回默认的开始和结束节点 + const timestamp = Date.now(); if (useDefault) { return { nodes: [ { - id: 'start', + id: `start-${timestamp}`, type: 'start', position: { x: 200, y: 200 }, data: { @@ -44,7 +45,7 @@ export const convertFlowData = (flowData: any, useDefault = true) => { } }, { - id: 'end', + id: `end-${timestamp}`, type: 'end', position: { x: 600, y: 200 }, data: { @@ -107,10 +108,10 @@ export const convertFlowData = (flowData: any, useDefault = true) => { // 确定节点类型 let nodeType = 'BASIC'; - if (nodeId === 'start') { + if (nodeId.includes('start')) { nodeType = 'start'; } - else if (nodeId === 'end') { + else if (nodeId.includes('end')) { nodeType = 'end'; } else if (nodeConfig.component?.type === 'LOOP_START' || nodeConfig.component?.type === 'LOOP_END') { @@ -405,10 +406,10 @@ export const revertFlowData = (nodes: any[], edges: any[]) => { // 确定节点类型 let nodeType = node.data.type; // 特殊处理 start 和 end 节点 - if (nodeId === 'start') { + if (nodeId.includes('start')) { nodeType = 'start'; } - else if (nodeId === 'end') { + else if (nodeId.includes('end')) { nodeType = 'end'; } @@ -666,7 +667,7 @@ const getNodeApiIns = (nodeId: string, nodeConfig: any, currentProjectCompData: else if (nodeConfig.component?.type === 'LOOP_END') { return [{ name: 'continue', desc: '', dataType: '', defaultValue: '' }]; } - else if (nodeId === 'end') { + else if (nodeId.includes('end')) { return [{ name: 'end', desc: '', dataType: '', defaultValue: '' }]; } else { @@ -748,10 +749,10 @@ const getNodeApiOuts = (nodeId: string, nodeConfig: any, currentProjectCompData: return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }]; } } - else if (nodeId === 'start') { + else if (nodeId.includes('start')) { return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }]; } - else if (nodeId === 'end') { + else if (nodeId.includes('end')) { return []; } else { @@ -777,10 +778,10 @@ const getNodeApiOutHandle = (nodeId: string, nodeConfig: any) => { else if (nodeConfig.component?.type === 'LOOP_END') { return 'break'; } - else if (nodeId === 'start') { + else if (nodeId.includes('start')) { return 'start'; } - else if (nodeId === 'end') { + else if (nodeId.includes('end')) { return 'end'; } return 'done';