From 28721ad45abe794ac0c4bc5939188002e679738e Mon Sep 17 00:00:00 2001 From: ZLY Date: Mon, 27 Oct 2025 14:24:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(flow):=E4=BC=98=E5=8C=96=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E6=95=B0=E6=8D=AE=E8=BD=AC=E6=8D=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/flowEditor/utils/appFlowhandle.ts | 2 -- src/utils/convertAppFlowData.ts | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/pages/flowEditor/utils/appFlowhandle.ts b/src/pages/flowEditor/utils/appFlowhandle.ts index 5dddb09..030d7ea 100644 --- a/src/pages/flowEditor/utils/appFlowhandle.ts +++ b/src/pages/flowEditor/utils/appFlowhandle.ts @@ -12,8 +12,6 @@ export const appFLowHandle = (initialData, useDefault, setNodes, setEdges, dispa nodes: convertedNodes, edges: convertedEdges } = convertAppFlowData(initialData); - console.log('nodes:', convertedNodes); - console.log('edges:', convertedEdges); // 为所有边添加类型 diff --git a/src/utils/convertAppFlowData.ts b/src/utils/convertAppFlowData.ts index fbe5075..b3c6f34 100644 --- a/src/utils/convertAppFlowData.ts +++ b/src/utils/convertAppFlowData.ts @@ -14,6 +14,17 @@ export const convertAppFlowData = (appFlowData: any[]) => { // 处理每个应用流程数据项(每个应用作为一个节点) appFlowData.forEach((app: any, index: number) => { + // 添加过滤逻辑:如果 eventListenes 和 eventSends 都为空,则不生成节点 + const hasEventListenes = app.eventListenes && app.eventListenes.length > 0 && + app.eventListenes.some((event: any) => event && !event.topic?.includes('**empty**')); + const hasEventSends = app.eventSends && app.eventSends.length > 0 && + app.eventSends.some((event: any) => event && !event.topic?.includes('**empty**')); + + // 如果两者都为空,则跳过当前应用节点的创建 + if (!hasEventListenes && !hasEventSends) { + return; + } + // 构造节点数据 const node: any = { id: app.appId || `app_${index}`, @@ -29,7 +40,7 @@ export const convertAppFlowData = (appFlowData: any[]) => { dataType: '', defaultValue: '', topic: event.topic - })) : [], + })).filter((event: any) => event && !event.topic?.includes('**empty**')) : [], // eventSends 作为 apiOuts(输出) apiOuts: app.eventSends ? app.eventSends.map((event: any) => ({ name: event.eventName, @@ -37,7 +48,7 @@ export const convertAppFlowData = (appFlowData: any[]) => { dataType: '', defaultValue: '', topic: event.topic - })) : [], + })).filter((event: any) => event && !event.topic?.includes('**empty**')) : [], // 提取 dataIns 和 dataOuts 属性 dataIns: [], dataOuts: []