调整馆内点位搜索状态流转
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-13 23:51:27 +08:00
parent 350491157a
commit 2a274aebcf
4 changed files with 186 additions and 6 deletions

View File

@@ -627,6 +627,12 @@ const resetSearchState = async () => {
emitResultsState()
}
// 从详情页返回时只清理搜索 UI 与分类 marker不参与地图目标焦点的复位。
const returnToCollapsedAfterDetail = async () => {
await resetSearchState()
uni.hideKeyboard()
}
const handleCancel = async () => {
await resetSearchState()
uni.hideKeyboard()
@@ -744,14 +750,27 @@ const handleSearchClear = async () => {
await focusSearchInput()
}
const searchShortcut = async (categoryInput: PoiCategoryDefinition | PoiCategoryId) => {
type SearchShortcutOptions = {
homeCategoryResults?: boolean
}
const searchShortcut = async (
categoryInput: PoiCategoryDefinition | PoiCategoryId,
options: SearchShortcutOptions = {}
) => {
const category = typeof categoryInput === 'string'
? getPoiCategoryById(categoryInput)
: categoryInput
if (!category) return
const requestSeq = ++searchRequestSeq
const useHomeResultList = props.variant === 'home' && !homeExpanded.value
const useHomeResultList = props.variant === 'home'
&& (options.homeCategoryResults ?? !homeExpanded.value)
if (useHomeResultList) {
homeExpanded.value = false
searchInputFocused.value = false
uni.hideKeyboard()
}
searchKeyword.value = category.label
searchDraftKeyword.value = category.label
activeCategoryId.value = category.id
@@ -778,7 +797,10 @@ const searchShortcut = async (categoryInput: PoiCategoryDefinition | PoiCategory
}
const handleFacilityShortcut = (category: PoiCategoryDefinition) => {
void searchShortcut(category)
void searchShortcut(category, {
// 快捷入口始终进入首页底部分类结果;关键词确认仍保留全屏搜索结果。
homeCategoryResults: props.variant === 'home'
})
}
const handleSearchConfirm = async (event?: any) => {
@@ -959,6 +981,7 @@ defineExpose({
expandHomePanel,
collapseHomePanel,
resetSearchState,
returnToCollapsedAfterDetail,
focusSearchInput,
searchShortcut,
retryCurrentSearch,

View File

@@ -416,6 +416,7 @@ const guideMapShellRef = ref<{
const homeSearchPanelRef = ref<{
collapseHomePanel?: () => void
resetSearchState?: () => void
returnToCollapsedAfterDetail?: () => Promise<void>
restoreResultListScroll?: () => Promise<void>
} | null>(null)
const homeSearchExpanded = ref(false)
@@ -423,6 +424,7 @@ const homeCategoryModeActive = ref(false)
const searchVisiblePoiIds = ref<string[] | null>(null)
const searchTargetFocusRequest = ref<TargetPoiFocusRequestViewModel | null>(null)
let searchTargetFocusRequestId = 0
let pendingCollapseSearchAfterDetail = false
let launchOverlayFallbackTimer: ReturnType<typeof setTimeout> | null = null
let launchOverlayFadeTimer: ReturnType<typeof setTimeout> | null = null
@@ -1350,6 +1352,15 @@ const closeHomeSearchDock = () => {
onShow(async () => {
await nextTick()
if (pendingCollapseSearchAfterDetail) {
pendingCollapseSearchAfterDetail = false
await homeSearchPanelRef.value?.returnToCollapsedAfterDetail?.()
homeSearchExpanded.value = false
homeCategoryModeActive.value = false
searchVisiblePoiIds.value = null
return
}
await homeSearchPanelRef.value?.restoreResultListScroll?.()
})
@@ -1462,11 +1473,13 @@ const handleHomeSearchResultTap = async (poi: MuseumPoi, context: PoiSearchConte
entrances: poi.entrances
}, searchTargetFocusRequestId)
// 先把楼层与目标请求交给地图,再进入详情页;返回时列表组件仍保持原状态
// 先把楼层与目标请求交给地图,再进入详情页;返回时仅收起搜索 UI不清焦点
await nextTick()
pendingCollapseSearchAfterDetail = true
uni.navigateTo({
url: createSearchDetailUrl(poi, context),
fail: () => {
pendingCollapseSearchAfterDetail = false
uni.showToast({
title: '点位详情打开失败,请重试',
icon: 'none'