This commit is contained in:
@@ -327,7 +327,7 @@ import type {
|
||||
import {
|
||||
type TargetPoiFocusRequestViewModel
|
||||
} from '@/view-models/guideViewModels'
|
||||
import { useGuideModelState } from '@/composables/useGuideModelState'
|
||||
import { useGuideModelState, type PoiDetailReturnContext } from '@/composables/useGuideModelState'
|
||||
import {
|
||||
ARRIVAL_TARGETS_BY_TYPE,
|
||||
type ArrivalSearchTarget,
|
||||
@@ -418,6 +418,11 @@ const returningToOverview = ref(false)
|
||||
const guideMapShellRef = ref<{
|
||||
clearRoute?: () => void
|
||||
showOverview?: () => Promise<void> | void
|
||||
resetToViewBaseline?: (options: {
|
||||
view: 'overview' | 'floor'
|
||||
floorId?: string
|
||||
reason: 'poi-detail-close' | 'manual-reset' | 'floor-reset'
|
||||
}) => Promise<boolean> | boolean
|
||||
resetToInitialState?: () => Promise<boolean> | boolean
|
||||
} | null>(null)
|
||||
const homeSearchPanelRef = ref<{
|
||||
@@ -430,7 +435,7 @@ const homeSearchExpanded = ref(false)
|
||||
const homeCategoryModeActive = ref(false)
|
||||
const searchVisiblePoiIds = ref<string[] | null>(null)
|
||||
const searchTargetFocusRequest = ref<TargetPoiFocusRequestViewModel | null>(null)
|
||||
let pendingGuideModelResetUntilReady = false
|
||||
let pendingGuideModelResetUntilReady: PoiDetailReturnContext | null = null
|
||||
|
||||
type PoiSearchOverlayHistoryState = {
|
||||
museumGuideOverlay?: 'poi-search'
|
||||
@@ -1036,8 +1041,9 @@ const handleInitialModelReady = (event: { view: GuideIndoorView; floorId?: strin
|
||||
guideModelState.initializeModel(event.floorId || activeGuideFloor.value)
|
||||
settleLaunchOverlayByModel('ready', event)
|
||||
if (pendingGuideModelResetUntilReady) {
|
||||
pendingGuideModelResetUntilReady = false
|
||||
void resetGuideModelToInitial({ reason: 'queued-poi-detail-close' })
|
||||
const context = pendingGuideModelResetUntilReady
|
||||
pendingGuideModelResetUntilReady = null
|
||||
void resetGuideModelToInitial({ reason: 'queued-poi-detail-close', floorId: context.floorId })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1456,7 +1462,13 @@ const closeHomeSearchDock = () => {
|
||||
homeSearchExpanded.value = false
|
||||
}
|
||||
|
||||
const resetGuideModelToInitial = async ({ reason }: { reason: 'poi-detail-close' | 'queued-poi-detail-close' }) => {
|
||||
const resetGuideModelToInitial = async ({
|
||||
reason,
|
||||
floorId
|
||||
}: {
|
||||
reason: 'poi-detail-close' | 'queued-poi-detail-close'
|
||||
floorId: string
|
||||
}) => {
|
||||
const initial = guideModelState.initialState.value
|
||||
guideModelState.invalidatePendingRequests()
|
||||
searchTargetFocusRequest.value = null
|
||||
@@ -1476,25 +1488,34 @@ const resetGuideModelToInitial = async ({ reason }: { reason: 'poi-detail-close'
|
||||
failedFloorId.value = ''
|
||||
is3DMode.value = true
|
||||
guideOutdoorState.value = 'home'
|
||||
indoorView.value = initial.indoorView
|
||||
activeGuideFloor.value = initial.defaultActiveFloorId || activeGuideFloor.value
|
||||
renderedFloorId.value = initial.loadedFloorId || activeGuideFloor.value
|
||||
indoorView.value = 'floor'
|
||||
activeGuideFloor.value = floorId || initial.defaultActiveFloorId || activeGuideFloor.value
|
||||
renderedFloorId.value = activeGuideFloor.value
|
||||
closeArrivalPanel()
|
||||
await homeSearchPanelRef.value?.resetSearchState?.()
|
||||
closeHomeSearchDock()
|
||||
|
||||
const resetApplied = await guideMapShellRef.value?.resetToInitialState?.()
|
||||
const resetApplied = await guideMapShellRef.value?.resetToViewBaseline?.({
|
||||
view: 'floor',
|
||||
floorId: activeGuideFloor.value,
|
||||
reason: 'poi-detail-close'
|
||||
})
|
||||
if (!resetApplied) {
|
||||
// The renderer is still becoming ready; retain only the latest requested reset.
|
||||
pendingGuideModelResetUntilReady = true
|
||||
pendingGuideModelResetUntilReady = Object.freeze({
|
||||
floorId: activeGuideFloor.value,
|
||||
resetMode: 'floor-baseline',
|
||||
requestId: guideModelState.invalidatePendingRequests()
|
||||
})
|
||||
}
|
||||
console.info('馆内三维模型已恢复统一初始状态:', { reason })
|
||||
}
|
||||
|
||||
onShow(async () => {
|
||||
await nextTick()
|
||||
if (guideModelState.consumePoiDetailReturn()) {
|
||||
await resetGuideModelToInitial({ reason: 'poi-detail-close' })
|
||||
const detailReturnContext = guideModelState.consumePoiDetailReturn()
|
||||
if (detailReturnContext) {
|
||||
await resetGuideModelToInitial({ reason: 'poi-detail-close', floorId: detailReturnContext.floorId })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1596,7 +1617,7 @@ const createSearchDetailUrl = (poi: MuseumPoi, context: PoiSearchContext) => {
|
||||
const handleHomeSearchResultTap = async (poi: MuseumPoi, context: PoiSearchContext) => {
|
||||
// The homepage keeps its renderer mounted; detail close is consumed by onShow once.
|
||||
searchTargetFocusRequest.value = null
|
||||
guideModelState.beginPoiDetailReturn()
|
||||
guideModelState.beginPoiDetailReturn(poi.floorId)
|
||||
uni.navigateTo({
|
||||
url: createSearchDetailUrl(poi, context),
|
||||
fail: () => {
|
||||
|
||||
Reference in New Issue
Block a user