fix: 实体关系图优化问题修改:点击上一步、下一步操作时,清除临时节点

This commit is contained in:
hanyuxia
2024-06-24 17:24:15 +08:00
parent f0189ac633
commit b8d419772a

View File

@@ -675,7 +675,7 @@ export default {
links.splice(linksIndex,1) links.splice(linksIndex,1)
} }
}) })
this.cleanTempItems()
this.stackData.redo.push(data) this.stackData.redo.push(data)
if (this.stackData.justRedo) { if (this.stackData.justRedo) {
this.stackData.justRedo = false this.stackData.justRedo = false
@@ -687,6 +687,7 @@ export default {
if(data) { if(data) {
this.stackData.justRedo = true this.stackData.justRedo = true
this.addItems(data.nodes, data.links) this.addItems(data.nodes, data.links)
this.cleanTempItems()
if (this.stackData.justUndo) { if (this.stackData.justUndo) {
this.stackData.justUndo = false this.stackData.justUndo = false
} }
@@ -944,8 +945,8 @@ export default {
} }
} }
}, },
cleanTempItems (data) { cleanTempItems () {
const { nodes, links } = data ? data : this.graph.graphData() const { nodes, links } = this.graph.graphData()
const newNodes = nodes.filter(n => n.type !== nodeType.tempNode) const newNodes = nodes.filter(n => n.type !== nodeType.tempNode)
const newLinks = links.filter(l => l.type !== linkType.temp) const newLinks = links.filter(l => l.type !== linkType.temp)
if (newNodes.length !== nodes.length || newLinks.length !== links.length) { if (newNodes.length !== nodes.length || newLinks.length !== links.length) {