From 4691b78a59624964d6c769b81163baefe82cb23b Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Mon, 25 Sep 2023 21:05:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=E5=9B=BE=E5=89=8D=E8=BF=9B=E3=80=81=E5=90=8E?= =?UTF-8?q?=E9=80=80=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/entityExplorer/EntityGraph.vue | 31 +++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/views/entityExplorer/EntityGraph.vue b/src/views/entityExplorer/EntityGraph.vue index a5188059..aa5ae031 100644 --- a/src/views/entityExplorer/EntityGraph.vue +++ b/src/views/entityExplorer/EntityGraph.vue @@ -85,7 +85,9 @@ export default { /* 自己实现stack操作 */ stackData: { undo: [], // 后退 - redo: [] // 前进 + justUndo: false, // 是否刚后退了 + redo: [], // 前进 + justRedo: false // 是否刚前进了 }, center: {}, initialData: null // 初始化数据,用于重置 @@ -676,6 +678,15 @@ export default { // 手动高亮listNode const _listNode = _this.graph.findById(listNode.id) _this.graph.emit('node:click', { item: _listNode, target: _listNode.getKeyShape() }) + console.info(_this.stackData) + if (_this.stackData.justUndo) { + _this.stackData.justUndo = false + _this.stackData.redo = [] + } + if (_this.stackData.justRedo) { + _this.stackData.justRedo = false + _this.stackData.redo = [] + } } }) this.graph.on('node:mouseenter', function (e) { @@ -917,6 +928,7 @@ export default { handleClick: (code, graph) => { if (code === 'undo') { const data = this.stackData.undo.pop() + this.stackData.justUndo = true data.nodes.forEach(n => { if (n.type === nodeType.listNode) { const listNode = this.graph.findById(n.id) @@ -932,13 +944,20 @@ export default { this.graph.removeItem(e.id) }) this.stackData.redo.push(data) + if (this.stackData.justRedo) { + this.stackData.justRedo = false + } this.cleanTempNodesAndTempEdges() this.graph.layout() this.onCloseBlock() } else if (code === 'redo') { const data = this.stackData.redo.pop() - this.addItems(data.nodes, data.edges, false) - this.stackData.undo.push(data) + this.stackData.justRedo = true + this.addItems(data.nodes, data.edges) + // this.stackData.undo.push(data) + if (this.stackData.justUndo) { + this.stackData.justUndo = false + } this.cleanTempNodesAndTempEdges() this.graph.layout() this.onCloseBlock() @@ -954,6 +973,12 @@ export default { this.graph.clear() this.graph.data(this.initialData) this.graph.render() + this.stackData = { + undo: [], + redo: [], + justUndo: false, + justRedo: false + } const rootNode = this.graph.findById(this.entity.entityName) this.graph.emit('node:click', { item: rootNode, target: rootNode.getKeyShape() }) // 手动触发rootNode的点击事件 }