From 5585d2a4f76b151da3e806d5dc15e7a298c601c0 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Thu, 7 Sep 2023 18:45:02 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E8=8A=82=E7=82=B9=E6=AF=94?= =?UTF-8?q?=E5=AF=B9=E5=85=A8=E9=83=A8=E6=94=B9=E4=B8=BA=E9=80=9A=E8=BF=87?= =?UTF-8?q?uid=E5=AF=B9=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/core/render/Render.js | 16 ++++++++-------- simple-mind-map/src/core/render/node/Node.js | 8 ++++---- simple-mind-map/src/plugins/AssociativeLine.js | 4 ++-- simple-mind-map/src/plugins/Drag.js | 4 ++-- .../src/plugins/KeyboardNavigation.js | 6 +++--- simple-mind-map/src/plugins/NodeImgAdjust.js | 2 +- simple-mind-map/src/plugins/Painter.js | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/simple-mind-map/src/core/render/Render.js b/simple-mind-map/src/core/render/Render.js index 3aa2500e..230713cb 100644 --- a/simple-mind-map/src/core/render/Render.js +++ b/simple-mind-map/src/core/render/Render.js @@ -382,7 +382,7 @@ class Render { // 检索某个节点在激活列表里的索引 findActiveNodeIndex(node) { return this.activeNodeList.findIndex(item => { - return item === node + return item.uid === node.uid }) } @@ -390,7 +390,7 @@ class Render { getNodeIndex(node) { return node.parent ? node.parent.children.findIndex(item => { - return item === node + return item.uid === node.uid }) : 0 } @@ -553,7 +553,7 @@ class Render { let parent = node.parent let childList = parent.children let index = childList.findIndex(item => { - return item === node + return item.uid === node.uid }) if (index === -1 || index === 0) { return @@ -580,7 +580,7 @@ class Render { let parent = node.parent let childList = parent.children let index = childList.findIndex(item => { - return item === node + return item.uid === node.uid }) if (index === -1 || index === childList.length - 1) { return @@ -752,7 +752,7 @@ class Render { let nodeParent = node.parent let nodeBorthers = nodeParent.children let nodeIndex = nodeBorthers.findIndex(item => { - return item === node + return item.uid === node.uid }) if (nodeIndex === -1) { return @@ -764,7 +764,7 @@ class Render { let existParent = exist.parent let existBorthers = existParent.children let existIndex = existBorthers.findIndex(item => { - return item === exist + return item.uid === exist.uid }) if (existIndex === -1) { return @@ -791,7 +791,7 @@ class Render { let nodeParent = node.parent let nodeBorthers = nodeParent.children let nodeIndex = nodeBorthers.findIndex(item => { - return item === node + return item.uid === node.uid }) if (nodeIndex === -1) { return @@ -803,7 +803,7 @@ class Render { let existParent = exist.parent let existBorthers = existParent.children let existIndex = existBorthers.findIndex(item => { - return item === exist + return item.uid === exist.uid }) if (existIndex === -1) { return diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index 9bca88b9..43e3075b 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -794,12 +794,12 @@ class Node { // 检测当前节点是否是某个节点的祖先节点 isParent(node) { - if (this === node) { + if (this.uid === node.uid) { return false } let parent = node.parent while (parent) { - if (this === parent) { + if (this.uid === parent.uid) { return true } parent = parent.parent @@ -809,11 +809,11 @@ class Node { // 检测当前节点是否是某个节点的兄弟节点 isBrother(node) { - if (!this.parent || this === node) { + if (!this.parent || this.uid === node.uid) { return false } return this.parent.children.find(item => { - return item === node + return item.uid === node.uid }) } diff --git a/simple-mind-map/src/plugins/AssociativeLine.js b/simple-mind-map/src/plugins/AssociativeLine.js index 7f0ae128..5855c27b 100644 --- a/simple-mind-map/src/plugins/AssociativeLine.js +++ b/simple-mind-map/src/plugins/AssociativeLine.js @@ -362,7 +362,7 @@ class AssociativeLine { if (node.nodeData.data.isActive) { this.mindMap.renderer.setNodeActive(node, false) } - if (node === this.creatingStartNode || this.overlapNode) { + if (node.uid === this.creatingStartNode.uid || this.overlapNode) { return } let { left, top, width, height } = node @@ -379,7 +379,7 @@ class AssociativeLine { // 完成创建连接线 completeCreateLine(node) { - if (this.creatingStartNode === node) return + if (this.creatingStartNode.uid === node.uid) return this.addLine(this.creatingStartNode, node) if (this.overlapNode && this.overlapNode.nodeData.data.isActive) { this.mindMap.renderer.setNodeActive(this.overlapNode, false) diff --git a/simple-mind-map/src/plugins/Drag.js b/simple-mind-map/src/plugins/Drag.js index fd99c5bf..3b49a035 100644 --- a/simple-mind-map/src/plugins/Drag.js +++ b/simple-mind-map/src/plugins/Drag.js @@ -218,7 +218,7 @@ class Drag extends Base { if (node.nodeData.data.isActive) { this.mindMap.renderer.setNodeActive(node, false) } - if (node === this.node || this.node.isParent(node)) { + if (node.uid === this.node.uid) { return } if (this.overlapNode || (this.prevNode && this.nextNode)) { @@ -231,7 +231,7 @@ class Drag extends Base { return item !== this.node }) : [] let index = checkList.findIndex((item) => { - return item === node + return item.uid === node.uid }) let prevBrother = null let nextBrother = null diff --git a/simple-mind-map/src/plugins/KeyboardNavigation.js b/simple-mind-map/src/plugins/KeyboardNavigation.js index 5ed4b593..d38815d0 100644 --- a/simple-mind-map/src/plugins/KeyboardNavigation.js +++ b/simple-mind-map/src/plugins/KeyboardNavigation.js @@ -94,7 +94,7 @@ class KeyboardNavigation { // 遍历节点树 bfsWalk(this.mindMap.renderer.root, node => { // 跳过当前聚焦的节点 - if (node === currentActiveNode) return + if (node.uid === currentActiveNode.uid) return // 当前遍历到的节点的位置信息 let rect = this.getNodeRect(node) let { left, top, right, bottom } = rect @@ -131,7 +131,7 @@ class KeyboardNavigation { checkNodeDis }) { bfsWalk(this.mindMap.renderer.root, node => { - if (node === currentActiveNode) return + if (node.uid === currentActiveNode.uid) return let rect = this.getNodeRect(node) let { left, top, right, bottom } = rect let match = false @@ -173,7 +173,7 @@ class KeyboardNavigation { let cX = (currentActiveNodeRect.right + currentActiveNodeRect.left) / 2 let cY = (currentActiveNodeRect.bottom + currentActiveNodeRect.top) / 2 bfsWalk(this.mindMap.renderer.root, node => { - if (node === currentActiveNode) return + if (node.uid === currentActiveNode.uid) return let rect = this.getNodeRect(node) let { left, top, right, bottom } = rect // 遍历到的节点的中心点 diff --git a/simple-mind-map/src/plugins/NodeImgAdjust.js b/simple-mind-map/src/plugins/NodeImgAdjust.js index cdde7045..ff62cb56 100644 --- a/simple-mind-map/src/plugins/NodeImgAdjust.js +++ b/simple-mind-map/src/plugins/NodeImgAdjust.js @@ -49,7 +49,7 @@ class NodeImgAdjust { // 如果当前正在拖动调整中那么直接返回 if (this.isMousedown || this.isAdjusted || this.mindMap.opt.readonly) return // 如果在当前节点内移动,以及自定义元素已经是显示状态,那么直接返回 - if (this.node === node && this.isShowHandleEl) return + if ((this.node && this.node.uid === node.uid) && this.isShowHandleEl) return // 更新当前节点信息 this.node = node this.img = img diff --git a/simple-mind-map/src/plugins/Painter.js b/simple-mind-map/src/plugins/Painter.js index b9ef5cd3..ff395165 100644 --- a/simple-mind-map/src/plugins/Painter.js +++ b/simple-mind-map/src/plugins/Painter.js @@ -49,7 +49,7 @@ class Painter { !this.isInPainter || !this.painterNode || !node || - node === this.painterNode + node.uid === this.painterNode.uid ) return const style = {}