From 09f4d8ac0c964a0e041984c34f1719fc33bdb96c Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 9 Oct 2021 10:21:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E4=B8=80=E9=A6=96?= =?UTF-8?q?=E6=AD=8C=E7=9A=84URL=E3=80=81=E6=AD=8C=E8=AF=8D=E7=AD=89?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E9=9C=80=E8=A6=81=E6=8D=A2=E6=BA=90=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + src/renderer/store/modules/list.js | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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 }, }