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, });