@@ -159,7 +159,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { onHide, onLoad, onUnload } from '@dcloudio/uni-app'
|
||||
import { onBackPress, onHide, onLoad, onUnload } from '@dcloudio/uni-app'
|
||||
import GuidePageFrame from '@/components/navigation/GuidePageFrame.vue'
|
||||
import GuideFeedbackState from '@/components/navigation/GuideFeedbackState.vue'
|
||||
import GuideLoadingState from '@/components/navigation/GuideLoadingState.vue'
|
||||
@@ -188,6 +188,7 @@ import {
|
||||
} from '@/utils/placeholders'
|
||||
import { normalizeSameOriginPublicUrl } from '@/utils/publicUrl'
|
||||
import { isEmbeddedInWechatMiniProgram } from '@/utils/hostEnvironment'
|
||||
import { returnToWechatMiniProgram } from '@/services/WechatMiniProgramBridgeService'
|
||||
import { normalizeGuideAudioLanguage } from '@/data/adapters/guideStopInfoAdapter'
|
||||
import { explainGuideStopListUrl } from '@/utils/explainNavigation'
|
||||
import {
|
||||
@@ -355,6 +356,7 @@ const isCurrentDetailAudioTarget = computed(() => {
|
||||
)
|
||||
})
|
||||
let detailAudioClosedOnExit = false
|
||||
let returningToMiniProgram = false
|
||||
|
||||
const closeDetailAudioOnExit = () => {
|
||||
if (detailAudioClosedOnExit || !isCurrentDetailAudioTarget.value) return
|
||||
@@ -945,15 +947,42 @@ const fallbackToExplainObjectList = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const returnToExplainObjectList = () => {
|
||||
closeDetailAudioOnExit()
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: fallbackToExplainObjectList
|
||||
})
|
||||
const cameFromExplainObjectList = () => {
|
||||
const pages = getCurrentPages()
|
||||
const previousPage = pages[pages.length - 2] as { route?: string } | undefined
|
||||
return previousPage?.route === 'pages/explain/guide-stop-list'
|
||||
}
|
||||
|
||||
const handleBack = returnToExplainObjectList
|
||||
const returnToExplainObjectList = async () => {
|
||||
closeDetailAudioOnExit()
|
||||
if (cameFromExplainObjectList()) {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: fallbackToExplainObjectList
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (isEmbeddedInWechatMiniProgram()) {
|
||||
if (returningToMiniProgram) return
|
||||
returningToMiniProgram = true
|
||||
const result = await returnToWechatMiniProgram()
|
||||
if (result.status === 'returned') return
|
||||
|
||||
returningToMiniProgram = false
|
||||
uni.showToast({ title: '返回小程序失败,请重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
fallbackToExplainObjectList()
|
||||
}
|
||||
|
||||
const handleBack = () => { void returnToExplainObjectList() }
|
||||
|
||||
onBackPress(() => {
|
||||
void returnToExplainObjectList()
|
||||
return true
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user