This commit is contained in:
@@ -583,17 +583,21 @@ const markFloorSwitchFailedIfUnrendered = (floorId: string, requestSeq: number)
|
||||
})
|
||||
}
|
||||
|
||||
const handleFloorChange = (floor: { id: string; label: string }) => {
|
||||
const requestFloorSwitch = (
|
||||
floor: { id: string; label: string },
|
||||
options: { force?: boolean } = {}
|
||||
) => {
|
||||
const floorId = floor.id
|
||||
if (!floorId || loadingFloorId.value) return
|
||||
if (!floorId) return Promise.resolve()
|
||||
if (loadingFloorId.value === floorId) return Promise.resolve()
|
||||
if (
|
||||
floorId === renderedFloorId.value
|
||||
!options.force && floorId === renderedFloorId.value
|
||||
&& activeFloorId.value === floorId
|
||||
&& props.indoorView === 'floor'
|
||||
&& props.layerMode !== 'multi'
|
||||
) {
|
||||
emit('floorChange', floorId)
|
||||
return
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
requestedFloorId.value = floorId
|
||||
@@ -607,7 +611,7 @@ const handleFloorChange = (floor: { id: string; label: string }) => {
|
||||
floorId,
|
||||
floorLabel: floor.label
|
||||
})
|
||||
Promise.resolve(indoorRendererRef.value?.switchFloor?.(floorId))
|
||||
return Promise.resolve(indoorRendererRef.value?.switchFloor?.(floorId))
|
||||
.then(() => {
|
||||
markFloorSwitchFailedIfUnrendered(floorId, requestSeq)
|
||||
})
|
||||
@@ -623,6 +627,10 @@ const handleFloorChange = (floor: { id: string; label: string }) => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleFloorChange = (floor: { id: string; label: string }) => {
|
||||
void requestFloorSwitch(floor)
|
||||
}
|
||||
|
||||
const handleLayerModeChange = (mode: LayerDisplayMode) => {
|
||||
// 手动切换展示层数时使用统一的短保护期。
|
||||
indoorRendererRef.value?.disableAutoSwitchTemporarily?.(manualAutoSwitchPauseMs)
|
||||
@@ -789,7 +797,11 @@ defineExpose({
|
||||
indoorRendererRef.value?.clearRoute?.()
|
||||
},
|
||||
// 仅发起切换;父级必须以 floor-change 作为已提交的唯一依据。
|
||||
switchFloor: (floorId: string) => indoorRendererRef.value?.switchFloor?.(floorId),
|
||||
switchFloor: (floorId: string) => {
|
||||
const floor = findFloorItemById(floorId)
|
||||
if (!floor) return Promise.resolve()
|
||||
return requestFloorSwitch(floor, { force: true })
|
||||
},
|
||||
showOverview: handleShowOverview,
|
||||
resetToViewBaseline: (options: {
|
||||
view: 'overview' | 'floor'
|
||||
|
||||
@@ -248,6 +248,7 @@ import type {
|
||||
PoiCategoryResultState,
|
||||
PoiSearchContext
|
||||
} from '@/domain/poiSearch'
|
||||
import { nextHomeSearchResultVersion } from './homeSearchResultVersion'
|
||||
import { isEmbeddedInWechatMiniProgram } from '@/utils/hostEnvironment'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
@@ -397,7 +398,8 @@ const emitResultsState = () => {
|
||||
emit('results-change', {
|
||||
...context,
|
||||
visiblePoiIds: active ? context.visiblePoiIds : [],
|
||||
active
|
||||
active,
|
||||
requestId: props.variant === 'home' ? nextHomeSearchResultVersion() : undefined
|
||||
})
|
||||
}
|
||||
|
||||
@@ -411,7 +413,8 @@ const emitPendingHomeSearchResults = (floor?: Pick<MuseumFloor, 'id' | 'label'>)
|
||||
floorLabel: floor?.label || context.floorLabel,
|
||||
visiblePoiIds: [],
|
||||
active: true,
|
||||
pending: true
|
||||
pending: true,
|
||||
requestId: nextHomeSearchResultVersion()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
7
src/components/search/homeSearchResultVersion.ts
Normal file
7
src/components/search/homeSearchResultVersion.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// This version survives a PoiSearchPanel remount, unlike its local request sequence.
|
||||
let latestHomeSearchResultVersion = 0
|
||||
|
||||
export const nextHomeSearchResultVersion = () => {
|
||||
latestHomeSearchResultVersion += 1
|
||||
return latestHomeSearchResultVersion
|
||||
}
|
||||
Reference in New Issue
Block a user