@@ -134,8 +134,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { onLoad, onUnload } from '@dcloudio/uni-app'
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { onHide, onLoad, onUnload } from '@dcloudio/uni-app'
|
||||
import GuidePageFrame from '@/components/navigation/GuidePageFrame.vue'
|
||||
import type { AudioItem } from '@/components/audio/AudioPlayer.vue'
|
||||
import { useGlobalAudioPlayer } from '@/composables/useGlobalAudioPlayer'
|
||||
@@ -305,6 +305,14 @@ const isCurrentDetailAudioTarget = computed(() => {
|
||||
&& source.targetId === targetId
|
||||
)
|
||||
})
|
||||
let detailAudioClosedOnExit = false
|
||||
|
||||
const closeDetailAudioOnExit = () => {
|
||||
if (detailAudioClosedOnExit || !isCurrentDetailAudioTarget.value) return
|
||||
|
||||
detailAudioClosedOnExit = true
|
||||
globalAudioPlayer.close()
|
||||
}
|
||||
const audioDockTitle = computed(() => displayTitle.value || '讲解内容')
|
||||
const formatDetailAudioTime = (seconds?: number) => {
|
||||
const normalizedSeconds = Number.isFinite(seconds || 0)
|
||||
@@ -482,6 +490,7 @@ const loadExplainDetail = async (
|
||||
}
|
||||
|
||||
onLoad(async (options: any = {}) => {
|
||||
detailAudioClosedOnExit = false
|
||||
const tab = Array.isArray(options.tab) ? options.tab[0] : options.tab
|
||||
if (isGuideTopTab(tab)) {
|
||||
activeTopTab.value = tab
|
||||
@@ -525,9 +534,10 @@ onLoad(async (options: any = {}) => {
|
||||
}
|
||||
})
|
||||
|
||||
onUnload(() => {
|
||||
globalAudioPlayer.close()
|
||||
})
|
||||
// iOS H5 may hide a uni page before its route is fully unloaded.
|
||||
onHide(closeDetailAudioOnExit)
|
||||
onUnload(closeDetailAudioOnExit)
|
||||
onBeforeUnmount(closeDetailAudioOnExit)
|
||||
|
||||
const detailTextFor = (lang: AudioLanguage) => {
|
||||
return detailTextByLanguage.value[lang] || fallbackTextForLanguage(lang)
|
||||
@@ -908,6 +918,7 @@ const fallbackToExplainObjectList = () => {
|
||||
}
|
||||
|
||||
const returnToExplainObjectList = () => {
|
||||
closeDetailAudioOnExit()
|
||||
const pages = getCurrentPages()
|
||||
const previousPage = pages[pages.length - 2] as ExplainDetailPageStackEntry | undefined
|
||||
if (previousPage?.route === 'pages/explain/guide-stop-list') {
|
||||
|
||||
Reference in New Issue
Block a user