From d2f67d060c79f7469f3b18b557bb2d2f3c1c9ccd Mon Sep 17 00:00:00 2001 From: dengqichen Date: Fri, 13 Dec 2024 09:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B7=A5=E5=85=B7=E6=A0=8F?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Workflow/Definition/Design/index.tsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/Workflow/Definition/Design/index.tsx b/frontend/src/pages/Workflow/Definition/Design/index.tsx index 9f3a4336..98001fe2 100644 --- a/frontend/src/pages/Workflow/Definition/Design/index.tsx +++ b/frontend/src/pages/Workflow/Definition/Design/index.tsx @@ -165,11 +165,20 @@ const WorkflowDesign: React.FC = () => { }, }; + // 创建节点时设置完整的属性 graph.addNode({ ...nodeConfig, x: point.x, y: point.y, - data: { type: node.type }, + // 保存完整的节点信息 + type: node.type, + code: node.code, + graph: { + shape: node.graphConfig.uiSchema.shape, + size: node.graphConfig.uiSchema.size, + style: node.graphConfig.uiSchema.style, + ports: node.graphConfig.uiSchema.ports + }, // 保存节点定义,用于后续编辑 nodeDefinition: node, }); @@ -201,17 +210,20 @@ const WorkflowDesign: React.FC = () => { try { // 获取所有节点和边的数据 const nodes = graph.getNodes().map(node => { + const nodeDefinition = node.getProp('nodeDefinition'); const nodeType = node.getProp('type'); - const nodeDefinition = NODE_REGISTRY_CONFIG[nodeType]; return { id: node.id, - code: node.getProp('code'), + code: nodeType, // 设置 code 为节点的 type type: nodeType, name: node.attr('label/text'), graph: { shape: nodeDefinition?.graphConfig.uiSchema.shape, - size: node.size(), + size: { + width: node.size().width, + height: node.size().height + }, style: nodeDefinition?.graphConfig.uiSchema.style, ports: nodeDefinition?.graphConfig.uiSchema.ports },