Demo:修复一些未知情况下在根节点上点击鼠标右键会同时显示两个右键菜单的问题

This commit is contained in:
街角小林 2025-03-03 17:58:36 +08:00
parent 76b5f7d22a
commit ec9f55e068
2 changed files with 14 additions and 2 deletions

View File

@ -244,7 +244,8 @@ export default {
enableCopyToClipboardApi: navigator.clipboard, enableCopyToClipboardApi: navigator.clipboard,
numberType: '', numberType: '',
numberLevel: '', numberLevel: '',
subItemsShowLeft: false subItemsShowLeft: false,
isNodeMousedown: false
} }
}, },
computed: { computed: {
@ -344,6 +345,7 @@ export default {
this.$bus.$on('svg_mousedown', this.onMousedown) this.$bus.$on('svg_mousedown', this.onMousedown)
this.$bus.$on('mouseup', this.onMouseup) this.$bus.$on('mouseup', this.onMouseup)
this.$bus.$on('translate', this.hide) this.$bus.$on('translate', this.hide)
this.$bus.$on('node_mousedown', this.onNodeMousedown)
}, },
beforeDestroy() { beforeDestroy() {
this.$bus.$off('node_contextmenu', this.show) this.$bus.$off('node_contextmenu', this.show)
@ -353,6 +355,7 @@ export default {
this.$bus.$off('svg_mousedown', this.onMousedown) this.$bus.$off('svg_mousedown', this.onMousedown)
this.$bus.$off('mouseup', this.onMouseup) this.$bus.$off('mouseup', this.onMouseup)
this.$bus.$off('translate', this.hide) this.$bus.$off('translate', this.hide)
this.$bus.$off('node_mousedown', this.onNodeMousedown)
}, },
methods: { methods: {
...mapMutations(['setLocalConfig']), ...mapMutations(['setLocalConfig']),
@ -387,6 +390,10 @@ export default {
}) })
}, },
onNodeMousedown() {
this.isNodeMousedown = true
},
// //
onMousedown(e) { onMousedown(e) {
if (e.which !== 3) { if (e.which !== 3) {
@ -402,6 +409,10 @@ export default {
if (!this.isMousedown) { if (!this.isMousedown) {
return return
} }
if (this.isNodeMousedown) {
this.isNodeMousedown = false
return
}
this.isMousedown = false this.isMousedown = false
if ( if (
Math.abs(this.mosuedownX - e.clientX) > 3 || Math.abs(this.mosuedownX - e.clientX) > 3 ||

View File

@ -593,7 +593,8 @@ export default {
'node_attachmentContextmenu', 'node_attachmentContextmenu',
'demonstrate_jump', 'demonstrate_jump',
'exit_demonstrate', 'exit_demonstrate',
'node_note_dblclick' 'node_note_dblclick',
'node_mousedown'
].forEach(event => { ].forEach(event => {
this.mindMap.on(event, (...args) => { this.mindMap.on(event, (...args) => {
this.$bus.$emit(event, ...args) this.$bus.$emit(event, ...args)