From c78811fe360d218fd495be7bb9002ce58eda135b Mon Sep 17 00:00:00 2001 From: lyswhut Date: Fri, 5 Feb 2021 23:06:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=99=BE=E7=B1=B3=E6=BA=90?= =?UTF-8?q?=EF=BC=8C=E5=85=81=E8=AE=B8=E6=92=AD=E6=94=BE=E9=99=A4=E4=BA=86?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=88=97=E8=A1=A8=E4=BB=A5=E5=A4=96=E7=9A=84?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=AD=8C=E6=9B=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 +- publish/changeLog.md | 8 +++ src/renderer/components/core/Player.vue | 11 ++- .../components/material/MusicComment.vue | 2 +- src/renderer/components/material/SongList.vue | 10 ++- src/renderer/store/modules/list.js | 12 +++- src/renderer/store/modules/player.js | 68 +++++++++++++++---- src/renderer/utils/music/api-source-info.js | 1 - src/renderer/utils/music/index.js | 2 +- src/renderer/utils/music/xm/index.js | 65 +++++++++++------- src/renderer/utils/music/xm/util.js | 2 +- src/renderer/views/List.vue | 10 +-- src/renderer/views/SongList.vue | 2 +- 13 files changed, 134 insertions(+), 65 deletions(-) diff --git a/package.json b/package.json index 4be9b8a8..5561cdd4 100644 --- a/package.json +++ b/package.json @@ -34,18 +34,20 @@ "publish:gh:linux": "node build-config/pack.js && npm run publish:linux", "publish:linux": "npm run publish:linux:deb && npm run publish:linux:appImage && npm run publish:linux:rpm && npm run publish:linux:pacman", "publish:linux:appImage": "cross-env ARCH=x64 electron-builder -l=AppImage -p onTagOrDraft", - "publish:linux:deb": "npm run publish:linux:deb:x64 && npm run publish:linux:deb:x86 && npm run publish:linux:deb:arm64", + "publish:linux:deb": "npm run publish:linux:deb:x64 && npm run publish:linux:deb:x86 && npm run publish:linux:deb:arm64 && npm run publish:linux:deb:armv7l", "publish:linux:deb:x64": "cross-env ARCH=x64 electron-builder -l=deb --x64 -p onTagOrDraft", "publish:linux:deb:x86": "cross-env ARCH=x86 electron-builder -l=deb --ia32 -p onTagOrDraft", "publish:linux:deb:arm64": "cross-env ARCH=arm64 electron-builder -l=deb --arm64 -p onTagOrDraft", + "publish:linux:deb:armv7l": "cross-env ARCH=armv7l electron-builder -l=deb --armv7l -p onTagOrDraft", "publish:linux:rpm": "cross-env ARCH=x64 electron-builder -l=rpm --x64 -p onTagOrDraft", "publish:linux:pacman": "cross-env ARCH=x64 electron-builder -l=pacman --x64 -p onTagOrDraft", "pack:linux": "node build-config/pack.js && npm run pack:linux:deb && npm run pack:linux:appImage && npm run pack:linux:rpm && npm run pack:linux:pacman", "pack:linux:appImage": "cross-env ARCH=x64 electron-builder -l=AppImage", - "pack:linux:deb": "npm run pack:linux:deb:x64 && npm run pack:linux:deb:x86 && npm run pack:linux:deb:arm64", + "pack:linux:deb": "npm run pack:linux:deb:x64 && npm run pack:linux:deb:x86 && npm run pack:linux:deb:arm64 && npm run pack:linux:deb:armv7l", "pack:linux:deb:x64": "cross-env ARCH=x64 electron-builder -l=deb --x64", "pack:linux:deb:x86": "cross-env ARCH=x86 electron-builder -l=deb --ia32", "pack:linux:deb:arm64": "cross-env ARCH=arm64 electron-builder -l=deb --arm64", + "pack:linux:deb:armv7l": "cross-env ARCH=armv7l electron-builder -l=deb --armv7l", "pack:linux:rpm": "cross-env ARCH=x64 electron-builder -l=rpm --x64", "pack:linux:pacman": "cross-env ARCH=x64 electron-builder -l=pacman --x64", "pack:mac": "node build-config/pack.js && electron-builder -m=dmg", diff --git a/publish/changeLog.md b/publish/changeLog.md index 69862234..d7f52fa0 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -2,6 +2,14 @@ - 新增设置-其他-列表缓存信息清理功能,注:此功能一般情况下不要使用 +### 优化 + +- 允许播放除了搜索列表以外的所有歌曲,即原来没有播放按钮或者灰色的歌曲都可以点击尝试去播放。注:该功能的原理是尝试自动切换到其他源播放,所以不一定会播放成功,特别是对于那些独家的资源 + +### 移除 + +- 移除虾米源。注:虽然已移除该源,但仍可尝试去播放之前添加的歌曲,虽然不一定会成功 + ### 修复 - 修复音乐搜索列表的稍后播放功能无效的问题 diff --git a/src/renderer/components/core/Player.vue b/src/renderer/components/core/Player.vue index 2fb13e46..e7847c55 100644 --- a/src/renderer/components/core/Player.vue +++ b/src/renderer/components/core/Player.vue @@ -91,7 +91,6 @@ import { formatPlayTime2, getRandom, checkPath, setTitle, clipboardWriteText, de import { mapGetters, mapActions, mapMutations } from 'vuex' import { requestMsg } from '../../utils/message' import { player as eventPlayerNames } from '../../../common/hotKey' -import musicSdk from '@renderer/utils/music' import path from 'path' let audio @@ -327,6 +326,7 @@ export default { }, methods: { ...mapActions('player', ['getUrl', 'getPic', 'getLrc', 'playPrev', 'playNext']), + ...mapActions('list', ['getOtherSource']), ...mapMutations('player', [ 'setPlayMusicInfo', 'setPlayIndex', @@ -492,7 +492,7 @@ export default { this.setImg(targetSong.musicInfo) this.setLrc(targetSong.musicInfo) } else { - if (!this.assertApiSupport(targetSong.source)) return this.playNext() + // if (!this.assertApiSupport(targetSong.source)) return this.playNext() this.musicInfo.songmid = targetSong.songmid this.musicInfo.singer = targetSong.singer this.musicInfo.name = targetSong.name @@ -573,7 +573,7 @@ export default { togglePlay() { if (!audio.src) { if (this.restorePlayTime != null) { - if (!this.assertApiSupport(this.targetSong.source)) return this.playNext() + // if (!this.assertApiSupport(this.targetSong.source)) return this.playNext() this.setUrl(this.targetSong) } return @@ -613,10 +613,7 @@ export default { this.status = this.statusText = 'Try toggle source...' - return (originMusic.otherSource && originMusic.otherSource.length ? Promise.resolve(originMusic.otherSource) : musicSdk.findMusic(originMusic)).then(res => { - this.updateMusicInfo({ id: this.listId, index: this.playIndex, data: { otherSource: res }, musicInfo: originMusic }) - return res - }).then(otherSource => { + return this.getOtherSource(originMusic).then(otherSource => { console.log('find otherSource', otherSource) if (otherSource.length) { for (const item of otherSource) { diff --git a/src/renderer/components/material/MusicComment.vue b/src/renderer/components/material/MusicComment.vue index 7b5c198e..f13c74bd 100644 --- a/src/renderer/components/material/MusicComment.vue +++ b/src/renderer/components/material/MusicComment.vue @@ -50,7 +50,7 @@ export default { singer: '', }, page: 1, - total: 10, + total: 0, maxPage: 1, limit: 20, isHotLoading: true, diff --git a/src/renderer/components/material/SongList.vue b/src/renderer/components/material/SongList.vue index 67c3c46a..afb4b7fc 100644 --- a/src/renderer/components/material/SongList.vue +++ b/src/renderer/components/material/SongList.vue @@ -31,8 +31,6 @@ div(:class="$style.songList") td(:style="{ width: rowWidth.r6 }" style="padding-left: 0; padding-right: 0;") material-list-buttons(:index="index" :class="$style.btns" :remove-btn="false" @btn-click="handleListBtnClick" - :listAdd-btn="assertApiSupport(item.source)" - :play-btn="assertApiSupport(item.source)" :download-btn="assertApiSupport(item.source)") //- button.btn-info(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k'] || item._types.flac" @click.stop='openDownloadModal(index)') 下载 //- button.btn-secondary(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k']" @click.stop='testPlay(index)') 试听 @@ -243,7 +241,7 @@ export default { this.clickIndex = index return } - this.emitEvent(this.assertApiSupport(this.source) ? 'testPlay' : 'search', index) + this.emitEvent('testPlay', index) this.clickTime = 0 this.clickIndex = -1 }, @@ -340,9 +338,9 @@ export default { }, handleListItemRigthClick(event, index) { this.listMenu.itemMenuControl.sourceDetail = !!musicSdk[this.list[index].source].getMusicDetailPageUrl - this.listMenu.itemMenuControl.play = - this.listMenu.itemMenuControl.playLater = - this.listMenu.itemMenuControl.download = + // this.listMenu.itemMenuControl.play = + // this.listMenu.itemMenuControl.playLater = + this.listMenu.itemMenuControl.download = this.assertApiSupport(this.list[index].source) let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected') if (dom_selected) dom_selected.classList.remove('selected') diff --git a/src/renderer/store/modules/list.js b/src/renderer/store/modules/list.js index d0bc5451..10af48b6 100644 --- a/src/renderer/store/modules/list.js +++ b/src/renderer/store/modules/list.js @@ -1,3 +1,5 @@ +import musicSdk from '../../utils/music' + let allList = {} window.allList = allList @@ -48,7 +50,12 @@ const getters = { // actions const actions = { - + getOtherSource({ state, commit }, musicInfo) { + return (musicInfo.otherSource && musicInfo.otherSource.length ? Promise.resolve(musicInfo.otherSource) : musicSdk.findMusic(musicInfo)).then(otherSource => { + commit('setOtherSource', { musicInfo, otherSource }) + return otherSource + }) + }, } // mitations @@ -217,6 +224,9 @@ const mutations = { } } }, + setOtherSource(state, { musicInfo, otherSource }) { + musicInfo.otherSource = otherSource + }, } export default { diff --git a/src/renderer/store/modules/player.js b/src/renderer/store/modules/player.js index a6a27bfc..d134f033 100644 --- a/src/renderer/store/modules/player.js +++ b/src/renderer/store/modules/player.js @@ -18,8 +18,8 @@ const state = { } let urlRequest -let picRequest -let lrcRequest +// let picRequest +// let lrcRequest const filterList = async({ playedList, listInfo, savePath, commit }) => { // if (this.list.listName === null) return @@ -44,7 +44,7 @@ const filterList = async({ playedList, listInfo, savePath, commit }) => { } } else { list = listInfo.list.filter(s => { - if (!assertApiSupport(s.source)) return false + // if (!assertApiSupport(s.source)) return false canPlayList.push(s) let index = filteredPlayedList.indexOf(s) @@ -62,6 +62,42 @@ const filterList = async({ playedList, listInfo, savePath, commit }) => { return list } +const getPic = function(musicInfo, retryedSource = [], originMusic) { + console.log(musicInfo.source) + return music[musicInfo.source].getPic(musicInfo).promise.catch(err => { + if (!retryedSource.includes(musicInfo.source)) retryedSource.push(musicInfo.source) + return this.dispatch('list/getOtherSource', musicInfo).then(otherSource => { + if (!originMusic) originMusic = musicInfo + console.log('find otherSource', otherSource) + if (otherSource.length) { + for (const item of otherSource) { + if (retryedSource.includes(item.source)) continue + console.log('try toggle to: ', item.source, item.name, item.singer, item.interval) + return getPic.call(this, item, retryedSource, originMusic) + } + } + return Promise.reject(err) + }) + }) +} +const getLyric = function(musicInfo, retryedSource = [], originMusic) { + return music[musicInfo.source].getLyric(musicInfo).promise.catch(err => { + if (!retryedSource.includes(musicInfo.source)) retryedSource.push(musicInfo.source) + return this.dispatch('list/getOtherSource', musicInfo).then(otherSource => { + if (!originMusic) originMusic = musicInfo + console.log('find otherSource', otherSource) + if (otherSource.length) { + for (const item of otherSource) { + if (retryedSource.includes(item.source)) continue + console.log('try toggle to: ', item.source, item.name, item.singer, item.interval) + return getLyric.call(this, item, retryedSource, originMusic) + } + } + return Promise.reject(err) + }) + }) +} + // getters const getters = { list: state => state.listInfo.list, @@ -120,7 +156,11 @@ const actions = { } if (urlRequest && urlRequest.cancelHttp) urlRequest.cancelHttp() if (musicInfo.typeUrl[type] && !isRefresh) return Promise.resolve(musicInfo.typeUrl[type]) - urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type) + try { + urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type) + } catch (err) { + return Promise.reject(err) + } return urlRequest.promise.then(({ url }) => { if (originMusic) commit('setUrl', { musicInfo: originMusic, url, type }) commit('setUrl', { musicInfo, url, type }) @@ -132,18 +172,18 @@ const actions = { }) }, getPic({ commit, state }, musicInfo) { - if (picRequest && picRequest.cancelHttp) picRequest.cancelHttp() - picRequest = music[musicInfo.source].getPic(musicInfo) - return picRequest.promise.then(url => { - picRequest = null + // if (picRequest && picRequest.cancelHttp) picRequest.cancelHttp() + // picRequest = music[musicInfo.source].getPic(musicInfo) + return getPic.call(this, musicInfo).then(url => { + // picRequest = null commit('getPic', { musicInfo, url }) }).catch(err => { - picRequest = null + // picRequest = null return Promise.reject(err) }) }, getLrc({ commit, state }, musicInfo) { - if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp() + // if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp() if (musicInfo.lrc && musicInfo.tlrc != null) { if (musicInfo.lrc.startsWith('\ufeff[id:$00000000]')) { let str = musicInfo.lrc.replace('\ufeff[id:$00000000]\n', '') @@ -153,12 +193,12 @@ const actions = { } - lrcRequest = music[musicInfo.source].getLyric(musicInfo) - return lrcRequest.promise.then(({ lyric, tlyric }) => { - lrcRequest = null + // lrcRequest = music[musicInfo.source].getLyric(musicInfo) + return getLyric.call(this, musicInfo).then(({ lyric, tlyric }) => { + // lrcRequest = null commit('setLrc', { musicInfo, lyric, tlyric }) }).catch(err => { - lrcRequest = null + // lrcRequest = null return Promise.reject(err) }) }, diff --git a/src/renderer/utils/music/api-source-info.js b/src/renderer/utils/music/api-source-info.js index 74379655..e3ea06f7 100644 --- a/src/renderer/utils/music/api-source-info.js +++ b/src/renderer/utils/music/api-source-info.js @@ -11,7 +11,6 @@ module.exports = [ tx: ['128k'], wy: ['128k'], mg: ['128k'], - xm: ['128k'], // bd: ['128k'], }, }, diff --git a/src/renderer/utils/music/index.js b/src/renderer/utils/music/index.js index 7ef844b3..c9821b02 100644 --- a/src/renderer/utils/music/index.js +++ b/src/renderer/utils/music/index.js @@ -87,7 +87,7 @@ export default { item.name = trimStr(item.name) item.lowerCaseName = String(item.name).toLowerCase() item.lowerCaseAlbumName = String(item.albumName).toLowerCase() - console.log(lowerCaseName, item.lowerCaseName) + // console.log(lowerCaseName, item.lowerCaseName) if ( ( item.sortedSinger === sortedSinger && diff --git a/src/renderer/utils/music/xm/index.js b/src/renderer/utils/music/xm/index.js index e586bf25..5142a0db 100644 --- a/src/renderer/utils/music/xm/index.js +++ b/src/renderer/utils/music/xm/index.js @@ -1,39 +1,54 @@ -import { apis } from '../api-source' -import leaderboard from './leaderboard' -import songList from './songList' -import musicSearch from './musicSearch' +// import { apis } from '../api-source' +// import leaderboard from './leaderboard' +// import songList from './songList' +// import musicSearch from './musicSearch' // import pic from './pic' -import lyric from './lyric' -import hotSearch from './hotSearch' -import comment from './comment' -import musicInfo from './musicInfo' -import { closeVerifyModal } from './util' +// import lyric from './lyric' +// import hotSearch from './hotSearch' +// import comment from './comment' +// import musicInfo from './musicInfo' +// import { closeVerifyModal } from './util' const xm = { - songList, - musicSearch, - leaderboard, - hotSearch, - closeVerifyModal, - comment, + // songList, + // musicSearch, + // leaderboard, + // hotSearch, + // closeVerifyModal, + comment: { + getComment() { + return Promise.reject(new Error('fail')) + }, + getHotComment() { + return Promise.reject(new Error('fail')) + }, + }, getMusicUrl(songInfo, type) { - return apis('xm').getMusicUrl(songInfo, type) + return { + promise: Promise.reject(new Error('fail')), + } + // return apis('xm').getMusicUrl(songInfo, type) }, getLyric(songInfo) { - return lyric.getLyric(songInfo) + return { + promise: Promise.reject(new Error('fail')), + } + // return lyric.getLyric(songInfo) }, getPic(songInfo) { - return Promise.reject(new Error('fail')) + return { + promise: Promise.reject(new Error('fail')), + } // return pic.getPic(songInfo) }, - getMusicDetailPageUrl(songInfo) { - if (songInfo.songStringId) return `https://www.xiami.com/song/${songInfo.songStringId}` + // getMusicDetailPageUrl(songInfo) { + // if (songInfo.songStringId) return `https://www.xiami.com/song/${songInfo.songStringId}` - musicInfo.getMusicInfo(songInfo).then(({ data }) => { - songInfo.songStringId = data.songStringId - }) - return `https://www.xiami.com/song/${songInfo.songmid}` - }, + // musicInfo.getMusicInfo(songInfo).then(({ data }) => { + // songInfo.songStringId = data.songStringId + // }) + // return `https://www.xiami.com/song/${songInfo.songmid}` + // }, // init() { // getToken() // }, diff --git a/src/renderer/utils/music/xm/util.js b/src/renderer/utils/music/xm/util.js index d8b30f08..e02aa2c3 100644 --- a/src/renderer/utils/music/xm/util.js +++ b/src/renderer/utils/music/xm/util.js @@ -68,7 +68,7 @@ export const xmRequest = (path, params = '') => { isCancelled: false, cancelHttp() { if (!this.isInited) this.isCancelled = true - this.requestObj.cancelHttp() + this.requestObj && this.requestObj.cancelHttp() }, } diff --git a/src/renderer/views/List.vue b/src/renderer/views/List.vue index 8703fd19..2759cad9 100644 --- a/src/renderer/views/List.vue +++ b/src/renderer/views/List.vue @@ -569,7 +569,7 @@ export default { } }, testPlay(index) { - if (!this.assertApiSupport(this.list[index].source)) return + // if (!this.assertApiSupport(this.list[index].source)) return this.setPlayList({ list: this.listData, index }) }, handleRemove(index) { @@ -579,7 +579,7 @@ export default { switch (info.action) { case 'download': { const minfo = this.list[info.index] - if (!this.assertApiSupport(minfo.source)) return + // if (!this.assertApiSupport(minfo.source)) return this.musicInfo = minfo this.$nextTick(() => { this.isShowDownload = true @@ -732,9 +732,9 @@ export default { }, handleListItemRigthClick(event, index) { this.listMenu.itemMenuControl.sourceDetail = !!musicSdk[this.list[index].source].getMusicDetailPageUrl - this.listMenu.itemMenuControl.play = - this.listMenu.itemMenuControl.playLater = - this.listMenu.itemMenuControl.download = + // this.listMenu.itemMenuControl.play = + // this.listMenu.itemMenuControl.playLater = + this.listMenu.itemMenuControl.download = this.assertApiSupport(this.list[index].source) let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected') if (dom_selected) dom_selected.classList.remove('selected') diff --git a/src/renderer/views/SongList.vue b/src/renderer/views/SongList.vue index e0dbac2f..dc272426 100644 --- a/src/renderer/views/SongList.vue +++ b/src/renderer/views/SongList.vue @@ -239,7 +239,7 @@ export default { break case 'play': if (this.selectedData.length) { - this.listAddMultiple({ id: 'default', list: this.filterList(this.selectedData) }) + this.listAddMultiple({ id: 'default', list: [...this.selectedData] }) this.resetSelect() } this.testPlay(info.index)