新增播放自动换源功能

This commit is contained in:
lyswhut
2021-01-09 00:45:15 +08:00
parent 6b7d2ea657
commit 9a1a537bfd
21 changed files with 90 additions and 8 deletions
+2 -1
View File
@@ -28,7 +28,7 @@ const getters = {
// actions
const actions = {
getUrl({ commit, state }, { musicInfo, type, isRefresh }) {
getUrl({ commit, state }, { musicInfo, originMusic, type, isRefresh }) {
if (!musicInfo._types[type]) {
// 兼容旧版酷我源搜索列表过滤128k音质的bug
if (!(musicInfo.source == 'kw' && type == '128k')) return Promise.reject(new Error('该歌曲没有可播放的音频'))
@@ -39,6 +39,7 @@ const actions = {
if (musicInfo.typeUrl[type] && !isRefresh) return Promise.resolve()
urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type)
return urlRequest.promise.then(result => {
if (originMusic) commit('setUrl', { musicInfo: originMusic, url: result.url, type })
commit('setUrl', { musicInfo, url: result.url, type })
urlRequest = null
}).catch(err => {