修复同一首歌的URL、歌词等同时需要换源时的处理问题

pull/733/head
lyswhut 2021-10-09 10:21:34 +08:00
parent 254b82cc60
commit 09f4d8ac0c
2 changed files with 10 additions and 1 deletions

View File

@ -9,3 +9,4 @@
### 修复
- 修复kg源的歌单链接无法打开的问题
- 修复同一首歌的URL、歌词等同时需要换源时的处理问题

View File

@ -53,13 +53,21 @@ const getters = {
allList: () => allList,
}
const getOtherSourcePromises = new Map()
// actions
const actions = {
getOtherSource({ state, commit }, musicInfo) {
return (musicInfo.otherSource && musicInfo.otherSource.length ? Promise.resolve(musicInfo.otherSource) : musicSdk.findMusic(musicInfo)).then(otherSource => {
if (musicInfo.otherSource?.length) return Promise.resolve(musicInfo.otherSource)
let key = `${musicInfo.source}_${musicInfo.songmid}`
if (getOtherSourcePromises.has(key)) return getOtherSourcePromises.get(key)
const promise = musicSdk.findMusic(musicInfo).then(otherSource => {
commit('setOtherSource', { musicInfo, otherSource })
if (getOtherSourcePromises.has(key)) getOtherSourcePromises.delete(key)
return otherSource
})
getOtherSourcePromises.set(key, promise)
return promise
},
}