From f4e7a5f1470c8fe617a2ea6cf2d1d3c10768a385 Mon Sep 17 00:00:00 2001 From: lyf <2514544224@qq.com> Date: Fri, 17 Jul 2026 18:46:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=B2=E8=A7=A3=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E8=BF=94=E5=9B=9E=E5=AF=B9=E8=B1=A1=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exhibit/detail.vue | 51 +++++++++++++++++----- tests/unit/ExhibitDetailAudioFirst.spec.ts | 33 +++++++++++++- 2 files changed, 73 insertions(+), 11 deletions(-) diff --git a/src/pages/exhibit/detail.vue b/src/pages/exhibit/detail.vue index 7f25712..24d1f96 100644 --- a/src/pages/exhibit/detail.vue +++ b/src/pages/exhibit/detail.vue @@ -164,6 +164,7 @@ import { } from '@/utils/placeholders' import { isEmbeddedInWechatMiniProgram } from '@/utils/hostEnvironment' import { normalizeGuideAudioLanguage } from '@/data/adapters/guideStopInfoAdapter' +import { explainGuideStopListUrl } from '@/utils/explainNavigation' const defaultDetail: ExplainDetailPageViewModel = { id: '', @@ -871,23 +872,53 @@ const handleNavigate = async () => { }) } -const fallbackToExplainHome = () => { +type ExplainDetailPageStackEntry = { + route?: string +} + +const decodeRouteParam = (value: string) => { + let decoded = value + // Hash route parameters can accumulate extra encoding layers across H5 transitions. + for (let index = 0; index < 8; index += 1) { + try { + const next = decodeURIComponent(decoded) + if (next === decoded) break + decoded = next + } catch { + break + } + } + + return decoded +} + +const fallbackToExplainObjectList = () => { + const hallId = detailEntryRequest.value?.hallId || exhibit.value.hallId + const hallName = decodeRouteParam(detailEntryRequest.value?.hallName || exhibit.value.hallName || '讲解') + const url = hallId + ? explainGuideStopListUrl(hallId, hallName) + : '/pages/explain/list' + uni.redirectTo({ - url: '/pages/index/index?tab=explain', + url, fail: () => { - uni.reLaunch({ - url: '/pages/index/index?tab=explain' - }) + uni.reLaunch({ url }) } }) } -const handleBack = () => { - uni.navigateBack({ - delta: 1, - fail: fallbackToExplainHome - }) +const returnToExplainObjectList = () => { + const pages = getCurrentPages() + const previousPage = pages[pages.length - 2] as ExplainDetailPageStackEntry | undefined + if (previousPage?.route === 'pages/explain/guide-stop-list') { + uni.navigateBack({ delta: 1, fail: fallbackToExplainObjectList }) + return + } + + fallbackToExplainObjectList() } + +const handleBack = returnToExplainObjectList