增加工具栏提示。

This commit is contained in:
dengqichen 2024-12-13 09:40:28 +08:00
parent 56861d57e9
commit d2f67d060c

View File

@ -165,11 +165,20 @@ const WorkflowDesign: React.FC = () => {
}, },
}; };
// 创建节点时设置完整的属性
graph.addNode({ graph.addNode({
...nodeConfig, ...nodeConfig,
x: point.x, x: point.x,
y: point.y, 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, nodeDefinition: node,
}); });
@ -201,17 +210,20 @@ const WorkflowDesign: React.FC = () => {
try { try {
// 获取所有节点和边的数据 // 获取所有节点和边的数据
const nodes = graph.getNodes().map(node => { const nodes = graph.getNodes().map(node => {
const nodeDefinition = node.getProp('nodeDefinition');
const nodeType = node.getProp('type'); const nodeType = node.getProp('type');
const nodeDefinition = NODE_REGISTRY_CONFIG[nodeType];
return { return {
id: node.id, id: node.id,
code: node.getProp('code'), code: nodeType, // 设置 code 为节点的 type
type: nodeType, type: nodeType,
name: node.attr('label/text'), name: node.attr('label/text'),
graph: { graph: {
shape: nodeDefinition?.graphConfig.uiSchema.shape, shape: nodeDefinition?.graphConfig.uiSchema.shape,
size: node.size(), size: {
width: node.size().width,
height: node.size().height
},
style: nodeDefinition?.graphConfig.uiSchema.style, style: nodeDefinition?.graphConfig.uiSchema.style,
ports: nodeDefinition?.graphConfig.uiSchema.ports ports: nodeDefinition?.graphConfig.uiSchema.ports
}, },