From 93bf86d931b04280af032add782fe074437b97be Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Fri, 3 Nov 2023 10:57:45 +0800 Subject: [PATCH] fix: create collection report error (#2953) --- .../src/client/GraphDrawPage.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-graph-collection-manager/src/client/GraphDrawPage.tsx b/packages/plugins/@nocobase/plugin-graph-collection-manager/src/client/GraphDrawPage.tsx index 5828fad6ea..2e16591234 100644 --- a/packages/plugins/@nocobase/plugin-graph-collection-manager/src/client/GraphDrawPage.tsx +++ b/packages/plugins/@nocobase/plugin-graph-collection-manager/src/client/GraphDrawPage.tsx @@ -77,7 +77,7 @@ const getGridData = (num, arr) => { }; //初始布局 -async function layout(createPositions) { +async function layout(createPositions, isSaveLayput) { const { positions } = targetGraph; let graphPositions = []; const nodes: any[] = targetGraph.getNodes(); @@ -126,7 +126,7 @@ async function layout(createPositions) { } else { targetGraph.positionCell(nodes[0], 'top-left', { padding: 100 }); } - if (graphPositions.length > 0) { + if (graphPositions.length > 0 && isSaveLayput) { await createPositions(graphPositions); graphPositions = []; } @@ -725,14 +725,14 @@ export const GraphDrawPage = React.memo(() => { m2mEdge && lightUp(m2mEdge); }; // 全量渲染 - const renderInitGraphCollection = (rawData) => { + const renderInitGraphCollection = (rawData, isSaveLayput = true) => { targetGraph.clearCells(); const { nodesData, edgesData, inheritEdges } = formatData(rawData); targetGraph.data = { nodes: nodesData, edges: edgesData }; targetGraph.fromJSON({ nodes: nodesData }); targetGraph.addEdges(edgesData); targetGraph.addEdges(inheritEdges); - layout(saveGraphPositionAction); + layout(saveGraphPositionAction, isSaveLayput); }; // 增量渲染 @@ -1073,11 +1073,11 @@ export const GraphDrawPage = React.memo(() => { if (selectedCollections && collectionList.length) { const selectKeys = selectedCollections?.split(','); const data = collectionList.filter((v) => selectKeys.includes(v.name)); - renderInitGraphCollection(data); + renderInitGraphCollection(data, false); handelResetLayout(true); targetGraph.selectedCollections = selectedCollections; } else { - !selectedCollections && renderInitGraphCollection(collections); + !selectedCollections && renderInitGraphCollection(collections, false); } return () => { cleanGraphContainer();