diff --git a/publish/changeLog.md b/publish/changeLog.md index 5a2e19fa..f1cb27b4 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -9,3 +9,4 @@ ### 修复 - 修复kg源的歌单链接无法打开的问题 +- 修复同一首歌的URL、歌词等同时需要换源时的处理问题 diff --git a/src/renderer/store/modules/list.js b/src/renderer/store/modules/list.js index 8fd2c3fe..12c124f2 100644 --- a/src/renderer/store/modules/list.js +++ b/src/renderer/store/modules/list.js @@ -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 }, }