From e6f5f035bb269c67fdc458c618b7b92753071f1e Mon Sep 17 00:00:00 2001 From: ZLY Date: Fri, 17 Oct 2025 17:07:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(flow):=E4=B8=BASWITCH=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4component=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useFlowCallbacks.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/hooks/useFlowCallbacks.ts b/src/hooks/useFlowCallbacks.ts index f7361f4..20b817d 100644 --- a/src/hooks/useFlowCallbacks.ts +++ b/src/hooks/useFlowCallbacks.ts @@ -60,8 +60,6 @@ export const useFlowCallbacks = ( const apiOuts = nodeParams.apiOuts || []; const apiIns = nodeParams.apiIns || []; - console.log('123:', apiIns, apiOuts); - if (apiOuts.some((api: any) => (api.name || api.id) === handleId) || apiIns.some((api: any) => (api.name || api.id) === handleId) || (handleId.includes('loop'))) { return 'api'; @@ -605,6 +603,15 @@ export const useFlowCallbacks = ( } }; + if (nodeType === 'SWITCH') { + newNode.data.component = { + customDef: JSON.stringify({ + apiOutIds: ['default'], + conditions: [] + }) + }; + } + // 将未定义的节点动态追加进nodeTypes const nodeMap = Array.from(Object.values(nodeTypeMap).map(key => key)); if (!nodeMap.includes(nodeType)) { @@ -707,6 +714,15 @@ export const useFlowCallbacks = ( } }; + if (nodeType === 'SWITCH') { + newNode.data.component = { + customDef: JSON.stringify({ + apiOutIds: ['default'], + conditions: [] + }) + }; + } + // 将未定义的节点动态追加进nodeTypes const nodeMap = Array.from(Object.values(nodeTypeMap).map(key => key)); // 目前默认添加的都是系统组件/本地组件