From c8363560281126dc88400fb5d2c69e852dd8ed6c Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Fri, 15 Apr 2022 21:45:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B02.6.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- src/Graphin.tsx | 10 +++++++++- yarn.lock | 8 ++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 6fa9000..2e8f993 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "antv-graphin-vue", - "version": "2.6.0", + "version": "2.6.3", "description": "the vue toolkit for graph analysis based on g6, based on @antv/graphin", "scripts": { "prepare": "install-peers", @@ -22,7 +22,7 @@ "vue-class-component": "^8.0.0-rc.1" }, "dependencies": { - "@antv/graphin": "^2.6.0", + "@antv/graphin": "^2.6.3", "@antv/graphin-icons": "^1.0.0", "ant-design-vue": "^3.1.1" }, diff --git a/src/Graphin.tsx b/src/Graphin.tsx index a89a52d..a7d3870 100644 --- a/src/Graphin.tsx +++ b/src/Graphin.tsx @@ -255,6 +255,8 @@ const Graphin = defineComponent({ watch( () => props.data, (v) => { + let newDragNodes: IUserNode[]; + /** 数据变化 */ if (!deepEqual(toRaw(v), toRaw(self.data))) { initData(v); @@ -262,11 +264,16 @@ const Graphin = defineComponent({ if (self.isTree) { self.graph.changeData(self.data as TreeGraphData); } else { + // 若 dragNodes 中的节点已经不存在,则从数组中删去 + // @ts-ignore + newDragNodes = self.dragNodes.filter( + dNode => (self.data as GraphinData).nodes && (self.data as GraphinData).nodes.find(node => node.id === dNode.id), + ); // 更新拖拽后的节点的mass到data // @ts-ignore if (self.data.nodes && self.data.nodes.length > 0) { self.data.nodes.forEach(node => { - const dragNode = contextRef.dragNodes.find(item => item.id === node.id); + const dragNode = newDragNodes.find(item => item.id === node.id); if (dragNode) { const { force={} } = dragNode.layout || {} node.layout = { @@ -292,6 +299,7 @@ const Graphin = defineComponent({ initStatus(); contextRef.apis = ApiController(self.graph as IGraph); + contextRef.dragNodes = self.dragNodes = newDragNodes || self.dragNodes self.graph.emit('graphin:datachange'); } }, diff --git a/yarn.lock b/yarn.lock index 0e9e733..2770d51 100644 --- a/yarn.lock +++ b/yarn.lock @@ -239,10 +239,10 @@ resolved "https://registry.yarnpkg.com/@antv/graphin-icons/-/graphin-icons-1.0.0.tgz#86ba9e9ab6565bfe2ea1096e8678e76c279053f1" integrity sha512-2nogK6ZrDklnfIOJrqOAgD7iFLjfZIjLbA8pDUbeXN5c9b0Mu84oCfyqg8OmWwvi9Gt80eUzoplo73gKjZECJg== -"@antv/graphin@^2.6.0": - version "2.6.0" - resolved "https://registry.yarnpkg.com/@antv/graphin/-/graphin-2.6.0.tgz#5aa80858679fe5bd195469ce0bde1b44f1ecd553" - integrity sha512-0bD2aPSPYXxsPb5cmhmCCd5tgJqCaxF1DeM3LmszRp+KkE7utNw7tdR/+25Ta+K1dj1n5HI7QydagRQNTavxqw== +"@antv/graphin@^2.6.3": + version "2.6.3" + resolved "https://registry.yarnpkg.com/@antv/graphin/-/graphin-2.6.3.tgz#1ee3b6491aa7aada9bc9a8df77c84aab87b61000" + integrity sha512-go5xiIKtMhioS0yC2DSjBFsWih+69YTe3dALC6m7gRymLjUNW4SSdSy5GNDY8vZ7ZASfyGk8Nse1ILmlB8X+FA== dependencies: "@antv/g6" "^4.6.0-beta.3" "@antv/util" "^2.0.10"