fix(custom): 修复页面卸载时音频不停止的bug
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import Lottie from 'lottie-web'
|
||||
import * as dayjs from 'dayjs'
|
||||
@@ -250,6 +250,7 @@ const startRun = (name: string) => {
|
||||
setTimeout(() => {
|
||||
bgUrl.value = wu
|
||||
getUserInfo()
|
||||
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/3.mp3', true)
|
||||
}, 2000)
|
||||
}, rotateSpeed * 1000)
|
||||
}
|
||||
@@ -364,6 +365,18 @@ const getBetJl = () => {
|
||||
getBetList()
|
||||
getList()
|
||||
}
|
||||
|
||||
Taro.useDidHide(() => {
|
||||
clearInterval(timeId.value)
|
||||
clearInterval(time_i.value)
|
||||
innerAudioContext.stop()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
clearInterval(timeId.value)
|
||||
clearInterval(time_i.value)
|
||||
innerAudioContext.stop()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -307,6 +307,7 @@ const startRun = (name: string) => {
|
||||
setTimeout(() => {
|
||||
getList()
|
||||
getUserInfo()
|
||||
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/3.mp3', true)
|
||||
}, 2000)
|
||||
}, rotateSpeed * 1000)
|
||||
}
|
||||
@@ -416,10 +417,12 @@ const getBetJl = () => {
|
||||
|
||||
Taro.useDidHide(() => {
|
||||
ws.value?.close()
|
||||
innerAudioContext.stop()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
ws.value?.close()
|
||||
innerAudioContext.stop()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user