From 6cec82235a1c13b47c8f9470ed7e71e1c61a9f86 Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 19 Jun 2026 21:00:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(map):=20=E8=8A=82=E7=82=B9=E5=8F=B3?= =?UTF-8?q?=E9=94=AE=E8=8F=9C=E5=8D=95=E4=B8=8D=E5=86=8D=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E7=A9=BA=E7=99=BD=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit leaflet 与自定义的 handleMapContextMenu 都挂在 mapEl 容器上,普通 stopPropagation 不能阻止同节点上的后续监听器。改用 stopImmediatePropagation 并显式重置 menuMap,确保右键 marker 只显示 节点菜单。 --- meshmap_frontend/src/components/MeshMap.vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/meshmap_frontend/src/components/MeshMap.vue b/meshmap_frontend/src/components/MeshMap.vue index 80f87d7..ba7c0a6 100644 --- a/meshmap_frontend/src/components/MeshMap.vue +++ b/meshmap_frontend/src/components/MeshMap.vue @@ -168,9 +168,15 @@ function nodeDetailHref(nodeId: string): string { } function openNodeMenu(node: MapNode, event: L.LeafletMouseEvent) { + // leaflet 的 contextmenu 监听和我们自己的 handleMapContextMenu 都挂在 mapEl 上, + // 普通 stopPropagation 不会阻止同一节点上的后续监听器,必须 stopImmediatePropagation + // 否则空白处的「删除所有显示的节点」菜单也会一起弹出来。 + event.originalEvent.preventDefault() + event.originalEvent.stopImmediatePropagation() L.DomEvent.stopPropagation(event) lastRaisedNodeId.value = node.node_id emit('select-node', node.node_id) + menuMap.value = false menuNode.value = node menuX.value = event.originalEvent.clientX menuY.value = event.originalEvent.clientY