From 0380a4f8755b86c8bd008a9bde2dfdfe75c888c8 Mon Sep 17 00:00:00 2001 From: lyf <2514544224@qq.com> Date: Tue, 28 Jul 2026 20:16:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=B0=E5=9B=BE=E8=B5=B7?= =?UTF-8?q?=E7=82=B9=E7=A1=AE=E8=AE=A4=E5=BC=B9=E7=AA=97=E9=97=AA=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/map/ThreeMap.vue | 19 ++++++-- .../navigation/RoutePlannerPanel.vue | 44 +++++++++++++++++-- tests/unit/RoutePlannerPanel.spec.ts | 17 +++++++ 3 files changed, 73 insertions(+), 7 deletions(-) diff --git a/src/components/map/ThreeMap.vue b/src/components/map/ThreeMap.vue index d8e4cfa..6a31520 100644 --- a/src/components/map/ThreeMap.vue +++ b/src/components/map/ThreeMap.vue @@ -833,6 +833,7 @@ const emitFloorChange = (floorId: string, sceneRevision = props.sceneRevision) = } const currentFloor = ref(props.initialFloorId) const selectedPOI = ref(null) +let routeStartSelectionGeneration = 0 const activeFocusPoiId = ref('') const floorIndex = ref([]) const renderPackage = ref(null) @@ -8157,6 +8158,14 @@ const selectRouteStartCandidateNear = ( const handleSceneTap = async (event: PointerEvent) => { if (!camera || !renderer || !getContainerElement()) return + const routeStartSelectionActiveAtTap = props.routeStartSelectionActive + const routeStartSelectionGenerationAtTap = routeStartSelectionGeneration + const canResolveRouteStartForTap = () => ( + routeStartSelectionActiveAtTap + && props.routeStartSelectionActive + && routeStartSelectionGeneration === routeStartSelectionGenerationAtTap + ) + const rect = renderer.domElement.getBoundingClientRect() const pointer = new THREE.Vector2( ((event.clientX - rect.left) / rect.width) * 2 - 1, @@ -8215,7 +8224,8 @@ const handleSceneTap = async (event: PointerEvent) => { } const poi = findLoadedPoi(selectedPoi.id) || selectedPoi - if (props.routeStartSelectionActive) { + if (routeStartSelectionActiveAtTap) { + if (!canResolveRouteStartForTap()) return if (poi.positionGltf) { selectRouteStartCandidateNear( poi.floorId, @@ -8248,7 +8258,8 @@ const handleSceneTap = async (event: PointerEvent) => { : [] const matchedModelPoi = findPoiForModelHits(modelHits) - if (props.routeStartSelectionActive) { + if (routeStartSelectionActiveAtTap) { + if (!canResolveRouteStartForTap()) return if (matchedModelPoi?.poi.positionGltf) { selectRouteStartCandidateNear( matchedModelPoi.poi.floorId, @@ -9426,11 +9437,13 @@ watch(() => props.visiblePoiIds, () => { }) watch(() => props.routeStartSelectionActive, (isSelectingStart) => { + routeStartSelectionGeneration += 1 if (isSelectingStart) { clearMapSelection(false) } }, { - immediate: true + immediate: true, + flush: 'sync' }) watch(() => [props.routePreview, props.showRoute, props.routeNavigationActive], () => { diff --git a/src/components/navigation/RoutePlannerPanel.vue b/src/components/navigation/RoutePlannerPanel.vue index 6efddb2..c39524f 100644 --- a/src/components/navigation/RoutePlannerPanel.vue +++ b/src/components/navigation/RoutePlannerPanel.vue @@ -38,15 +38,15 @@ - + 确认选择 {{ normalizeVisitorPoiDisplayName(startCandidate.name) }} 为起点吗? - + 取消 - + 确定 @@ -56,7 +56,7 @@