|
@@ -57,7 +57,7 @@ export const renderMindMap = ({
|
|
}
|
|
}
|
|
const offsetX = originPosition.x - result.x;
|
|
const offsetX = originPosition.x - result.x;
|
|
const offsetY = originPosition.y - result.y;
|
|
const offsetY = originPosition.y - result.y;
|
|
- const traverse = (hierarchyItem: HierarchyResult, parent?: Node) => {
|
|
|
|
|
|
+ const traverse = (hierarchyItem: HierarchyResult) => {
|
|
if (hierarchyItem) {
|
|
if (hierarchyItem) {
|
|
const { data, children, x, y } = hierarchyItem;
|
|
const { data, children, x, y } = hierarchyItem;
|
|
const id = data?.id || uuid();
|
|
const id = data?.id || uuid();
|
|
@@ -106,7 +106,6 @@ export const renderMindMap = ({
|
|
cells.push(...(summaryCells || []));
|
|
cells.push(...(summaryCells || []));
|
|
}
|
|
}
|
|
cells.push(node);
|
|
cells.push(node);
|
|
- parent && parent.addChild(node);
|
|
|
|
if (data?.links) {
|
|
if (data?.links) {
|
|
cells.push(...data.links.map((item) => graph.createEdge(item)));
|
|
cells.push(...data.links.map((item) => graph.createEdge(item)));
|
|
}
|
|
}
|
|
@@ -127,7 +126,7 @@ export const renderMindMap = ({
|
|
node.addChild(edge);
|
|
node.addChild(edge);
|
|
}
|
|
}
|
|
// 递归遍历
|
|
// 递归遍历
|
|
- traverse(item, node);
|
|
|
|
|
|
+ traverse(item);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -163,6 +162,17 @@ export const renderMindMap = ({
|
|
const edgeCells = cells.filter((cell) => cell.isEdge());
|
|
const edgeCells = cells.filter((cell) => cell.isEdge());
|
|
graph.removeCells(edgeCells);
|
|
graph.removeCells(edgeCells);
|
|
graph.addCell(edgeCells);
|
|
graph.addCell(edgeCells);
|
|
|
|
+ // 处理父子节点关系
|
|
|
|
+ cells.forEach((cell) => {
|
|
|
|
+ const data = cell.getData();
|
|
|
|
+ if (data?.parentId) {
|
|
|
|
+ const parent = graph.getCellById(data.parentId);
|
|
|
|
+ const child = graph.getCellById(cell.id);
|
|
|
|
+ if(parent && child) {
|
|
|
|
+ parent.addChild(child);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
};
|
|
};
|
|
|
|
|
|
// 渲染概要
|
|
// 渲染概要
|
|
@@ -325,13 +335,6 @@ export const addTopic = (
|
|
projectInfo.topics.push(topic);
|
|
projectInfo.topics.push(topic);
|
|
}
|
|
}
|
|
|
|
|
|
- // if(sessionStorage.getItem("projectId") && !topic.parentId) {
|
|
|
|
- // AddMindMapElement({
|
|
|
|
- // ...topic,
|
|
|
|
- // graphId: sessionStorage.getItem("projectId"),
|
|
|
|
- // });
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
setMindProjectInfo(projectInfo);
|
|
setMindProjectInfo(projectInfo);
|
|
|
|
|
|
return topic;
|
|
return topic;
|