修复地图起点确认弹窗闪退
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-28 20:16:28 +08:00
parent 93bfb7e778
commit 0380a4f875
3 changed files with 73 additions and 7 deletions

View File

@@ -38,15 +38,15 @@
</view>
</view>
<view v-if="startCandidate" class="route-confirm-mask" @tap.stop="emit('cancelStart')">
<view v-if="startCandidate" class="route-confirm-mask" @tap.stop="handleCancelStart">
<view class="route-confirm-card" @tap.stop>
<text class="route-confirm-title">确认选择</text>
<text class="route-confirm-message">{{ normalizeVisitorPoiDisplayName(startCandidate.name) }} 为起点吗</text>
<view class="route-confirm-actions">
<view class="route-confirm-action secondary" @tap="emit('cancelStart')">
<view class="route-confirm-action secondary" @tap.stop="handleCancelStart">
<text class="route-confirm-action-text">取消</text>
</view>
<view class="route-confirm-action primary" @tap="emit('confirmStart', startCandidate)">
<view class="route-confirm-action primary" @tap.stop="handleConfirmStart">
<text class="route-confirm-action-text">确定</text>
</view>
</view>
@@ -56,7 +56,7 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { computed, onBeforeUnmount, ref, watch } from 'vue'
import type { RoutePointOption } from '@/components/navigation/RoutePointPicker.vue'
import { normalizeVisitorPoiDisplayName } from '@/view-models/visitorPoiPresentation'
@@ -87,6 +87,42 @@ const emit = defineEmits<{
back: []
}>()
const confirmationInteractive = ref(false)
let confirmationInteractiveTimer: ReturnType<typeof window.setTimeout> | null = null
const confirmationInteractionGuardMs = 350
const clearConfirmationInteractiveTimer = () => {
if (confirmationInteractiveTimer === null) return
window.clearTimeout(confirmationInteractiveTimer)
confirmationInteractiveTimer = null
}
watch(() => props.startCandidate, (candidate) => {
clearConfirmationInteractiveTimer()
confirmationInteractive.value = false
if (!candidate) return
confirmationInteractiveTimer = window.setTimeout(() => {
confirmationInteractiveTimer = null
confirmationInteractive.value = Boolean(props.startCandidate)
}, confirmationInteractionGuardMs)
}, {
immediate: true,
flush: 'sync'
})
onBeforeUnmount(clearConfirmationInteractiveTimer)
const handleCancelStart = () => {
if (!confirmationInteractive.value) return
emit('cancelStart')
}
const handleConfirmStart = () => {
if (!confirmationInteractive.value || !props.startCandidate) return
emit('confirmStart', props.startCandidate)
}
const pointMeta = (point: RoutePointOption) => (
point.categoryLabel ? `${point.floorLabel} · ${point.categoryLabel}` : point.floorLabel
)