添加加载超时时尝试刷新URL

pull/733/head
lyswhut 2021-12-08 17:51:06 +08:00
parent eb0a61d35b
commit 2a64ead1c4
1 changed files with 12 additions and 1 deletions

View File

@ -10,6 +10,7 @@ export default ({
}) => { }) => {
const { t } = useI18n() const { t } = useI18n()
let retryNum = 0 let retryNum = 0
let prevTimeoutId = null
let loadingTimeout let loadingTimeout
let delayNextTimeout let delayNextTimeout
@ -17,7 +18,16 @@ export default ({
// console.log('start load timeout') // console.log('start load timeout')
clearLoadingTimeout() clearLoadingTimeout()
loadingTimeout = Math.random() loadingTimeout = Math.random()
wait(30000, loadingTimeout).then(playNext).catch(_ => _) wait(25000, loadingTimeout).then(() => {
// 如果加载超时则尝试刷新URL
if (prevTimeoutId == musicInfo.songmid) {
prevTimeoutId = null
playNext()
} else {
prevTimeoutId = musicInfo.songmid
setUrl(musicInfoItem.value, true)
}
}).catch(_ => _)
} }
const clearLoadingTimeout = () => { const clearLoadingTimeout = () => {
if (!loadingTimeout) return if (!loadingTimeout) return
@ -87,6 +97,7 @@ export default ({
const handleSetPlayInfo = () => { const handleSetPlayInfo = () => {
retryNum = 0 retryNum = 0
prevTimeoutId = null
clearDelayNextTimeout() clearDelayNextTimeout()
clearLoadingTimeout() clearLoadingTimeout()
} }