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