@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user