增加工具栏提示。

This commit is contained in:
dengqichen 2024-12-13 12:34:17 +08:00
parent fab609fdbb
commit 18725c5ef7

View File

@ -235,43 +235,45 @@ const WorkflowDesign: React.FC = () => {
const node = JSON.parse(nodeData); const node = JSON.parse(nodeData);
const { clientX, clientY } = e; const { clientX, clientY } = e;
const point = graph.clientToLocal({ x: clientX, y: clientY }); 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 = { 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, width: node.graphConfig.uiSchema.size.width,
height: node.graphConfig.uiSchema.size.height, height: node.graphConfig.uiSchema.size.height,
attrs: { attrs: {
body: { body: {
fill: node.graphConfig.uiSchema.style.fill, ...node.graphConfig.uiSchema.style,
stroke: node.graphConfig.uiSchema.style.stroke, // 如果是菱形,添加 refPoints
strokeWidth: node.graphConfig.uiSchema.style.strokeWidth, ...(node.graphConfig.uiSchema.shape === 'diamond' ? {
refPoints: '50,0 100,50 50,100 0,50'
} : {})
}, },
label: { label: {
text: node.name, text: node.name,
fill: '#000000', fill: '#000000',
fontSize: 12, fontSize: 12,
}
}, },
}, // ports: convertPortConfig(node.graphConfig.uiSchema.ports)
ports: {
groups: generatePortGroups(),
items: generatePortItems(),
},
}; };
// 注册节点类型
Graph.registerNode(node.code, nodeConfig, true);
// 创建节点时设置完整的属性 // 创建节点时设置完整的属性
graph.addNode({ graph.addNode({
...nodeConfig, ...nodeConfig,
shape: node.graphConfig.uiSchema.shape,
x: point.x, x: point.x,
y: point.y, y: point.y,
// 保存完整的节点信息 // 保存完整的节点信息
type: node.type, type: node.type,
code: node.code, code: node.code,
graph: { // ports: nodeConfig.ports,
shape: node.graphConfig.uiSchema.shape, ports: convertPortConfig(node.graphConfig.uiSchema.ports),
size: node.graphConfig.uiSchema.size,
style: node.graphConfig.uiSchema.style,
ports: node.graphConfig.uiSchema.ports
},
// 保存节点定义,用于后续编辑 // 保存节点定义,用于后续编辑
nodeDefinition: node, nodeDefinition: node,
}); });