From 18725c5ef7b1d6f2ad2108cad088b6d44b55ffee Mon Sep 17 00:00:00 2001 From: dengqichen Date: Fri, 13 Dec 2024 12:34:17 +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 | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/frontend/src/pages/Workflow/Definition/Design/index.tsx b/frontend/src/pages/Workflow/Definition/Design/index.tsx index 6076e032..1899e59f 100644 --- a/frontend/src/pages/Workflow/Definition/Design/index.tsx +++ b/frontend/src/pages/Workflow/Definition/Design/index.tsx @@ -235,43 +235,45 @@ const WorkflowDesign: React.FC = () => { const node = JSON.parse(nodeData); const { clientX, clientY } = e; const point = graph.clientToLocal({ x: clientX, y: clientY }); - + console.log('Node Config:', node); + console.log('Ports Config:', node.graphConfig.uiSchema.ports); + console.log('Converted Ports:', convertPortConfig(node.graphConfig.uiSchema.ports)); const nodeConfig = { - shape: node.graphConfig.uiSchema.shape, + inherit: node.graphConfig.uiSchema.shape === 'circle' ? 'circle' : + node.graphConfig.uiSchema.shape === 'polygon' ? 'polygon' : + node.graphConfig.uiSchema.shape === 'diamond' ? 'polygon' : 'rect', width: node.graphConfig.uiSchema.size.width, height: node.graphConfig.uiSchema.size.height, attrs: { - body: { - fill: node.graphConfig.uiSchema.style.fill, - stroke: node.graphConfig.uiSchema.style.stroke, - strokeWidth: node.graphConfig.uiSchema.style.strokeWidth, + body: { + ...node.graphConfig.uiSchema.style, + // 如果是菱形,添加 refPoints + ...(node.graphConfig.uiSchema.shape === 'diamond' ? { + refPoints: '50,0 100,50 50,100 0,50' + } : {}) }, label: { text: node.name, fill: '#000000', fontSize: 12, - }, - }, - ports: { - groups: generatePortGroups(), - items: generatePortItems(), + } }, + // ports: convertPortConfig(node.graphConfig.uiSchema.ports) }; + // 注册节点类型 + Graph.registerNode(node.code, nodeConfig, true); // 创建节点时设置完整的属性 graph.addNode({ ...nodeConfig, + shape: node.graphConfig.uiSchema.shape, x: point.x, y: point.y, // 保存完整的节点信息 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 - }, + // ports: nodeConfig.ports, + ports: convertPortConfig(node.graphConfig.uiSchema.ports), // 保存节点定义,用于后续编辑 nodeDefinition: node, });