Closed gaoyakang closed 2 hours ago
online_logisim/src/core/nodes
// 序列化节点数据 function saveTreeToLocalStorage(treeData: { lf?: LogicFlow; treeNode: TreeNode[]; }) { // ... const edgesArray = getEdgesFromTree(treeData.treeNode); // 从树结构中提取边的信息 // ... } // 从树结构中提取边的信息 function getEdgesFromTree(treeNodes: TreeNode[], parent?: TreeNode): any[] { return treeNodes.reduce((edges:EdgeType[], node) => { if (parent) { edges.push({ sourceNodeId: node.id, targetNodeId: parent.id, type: "bezier" }); } node.children.forEach((child: TreeNode) => { edges = edges.concat(getEdgesFromTree([child], node)); }); return edges; }, []); }
以上代码会下面这种case中的edge丢失
可以在buildTree时直接将整体edges传过来,不用再从nodes中解析边了
已修复:https://github.com/gaoyakang/online_logisim/commit/baedaf2db4cc1978aac1e94c341b0793396190db
online_logisim/src/core/nodes
以上代码会下面这种case中的edge丢失