From b98c801b9fd071d11c0a37c26ac291cf1640ab63 Mon Sep 17 00:00:00 2001 From: asp_ly Date: Sat, 14 Dec 2024 16:32:55 +0800 Subject: [PATCH] 1 --- .../Workflow/Definition/Design/index.tsx | 58 +++++++------------ 1 file changed, 20 insertions(+), 38 deletions(-) diff --git a/frontend/src/pages/Workflow/Definition/Design/index.tsx b/frontend/src/pages/Workflow/Definition/Design/index.tsx index 06926bfb..c3f9f015 100644 --- a/frontend/src/pages/Workflow/Definition/Design/index.tsx +++ b/frontend/src/pages/Workflow/Definition/Design/index.tsx @@ -953,14 +953,32 @@ const WorkflowDesign: React.FC = () => { const sourceNode = nodeMap.get(edge.from); const targetNode = nodeMap.get(edge.to); if (sourceNode && targetNode) { + // 根据节点类型获取正确的端口组 + const getPortByGroup = (node: any, group: string) => { + const ports = node.getPorts(); + const port = ports.find((p: any) => p.group === group); + return port?.id; + }; + + // 获取源节点的输出端口(一定是out组) + const sourcePort = getPortByGroup(sourceNode, 'out'); + + // 获取目标节点的输入端口(一定是in组) + const targetPort = getPortByGroup(targetNode, 'in'); + + if (!sourcePort || !targetPort) { + console.error('无法找到正确的端口:', edge); + return; + } + graphInstance.addEdge({ source: { cell: sourceNode.id, - port: edge.fromPort || sourceNode.getPorts()[0].id, // 使用指定的端口或默认第一个端口 + port: sourcePort, }, target: { cell: targetNode.id, - port: edge.toPort || targetNode.getPorts()[0].id, // 使用指定的端口或默认第一个端口 + port: targetPort, }, attrs: { line: { @@ -972,42 +990,6 @@ const WorkflowDesign: React.FC = () => { }, }, }, - tools: [ - { - name: 'source-arrowhead', - args: { - attrs: { - fill: '#fff', - stroke: '#5F95FF', - strokeWidth: 1, - d: 'M 0 -6 L -8 0 L 0 6 Z', - }, - }, - }, - { - name: 'target-arrowhead', - args: { - attrs: { - fill: '#fff', - stroke: '#5F95FF', - strokeWidth: 1, - d: 'M 0 -6 L 8 0 L 0 6 Z', - }, - }, - }, - ], - connector: { - name: 'rounded', - args: { - radius: 8 - } - }, - router: { - name: 'manhattan', - args: { - padding: 1 - } - }, labels: [{ attrs: {label: {text: edge.name || ''}} }]