diff --git a/publish/changeLog.md b/publish/changeLog.md index c5f0ed86..c1de1e19 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -11,6 +11,10 @@ - 优化其他界面细节 - 优化英语翻译,感谢 @CPCer +### 更变 + +- 下载列表的歌曲下载、播放将随设置中的保存路径改变而改变,不再固定指向其初始位置 + ### 修复 - 修复网易源某些歌曲提示没有可播放的音质的问题 diff --git a/src/renderer/components/core/Player.vue b/src/renderer/components/core/Player.vue index f0bab4b5..e51359bf 100644 --- a/src/renderer/components/core/Player.vue +++ b/src/renderer/components/core/Player.vue @@ -53,6 +53,7 @@ import { formatPlayTime2, getRandom, checkPath, setTitle, clipboardWriteText, de import { mapGetters, mapActions, mapMutations } from 'vuex' import { requestMsg } from '../../utils/message' import { isMac } from '../../../common/utils' +import path from 'path' export default { data() { @@ -305,15 +306,16 @@ export default { this.audioErrorTime = 0 if (this.listId == 'download') { - console.log(targetSong.filePath) - if (!checkPath(targetSong.filePath) || !targetSong.isComplate || /\.ape$/.test(targetSong.filePath)) { + const filePath = path.join(this.setting.download.savePath, targetSong.fileName) + // console.log(filePath) + if (!checkPath(filePath) || !targetSong.isComplate || /\.ape$/.test(filePath)) { return this.list.length == 1 ? null : this.handleNext() } this.musicInfo.songmid = targetSong.musicInfo.songmid this.musicInfo.singer = targetSong.musicInfo.singer this.musicInfo.name = targetSong.musicInfo.name - this.audio.src = targetSong.filePath - // console.log(targetSong.filePath) + this.audio.src = filePath + // console.log(filePath) this.setImg(targetSong.musicInfo) this.setLrc(targetSong.musicInfo) } else { @@ -343,7 +345,10 @@ export default { // if (this.list.listName === null) return let list if (this.listId == 'download') { - list = this.list.filter(s => !(!checkPath(s.filePath) || !s.isComplate || /\.ape$/.test(s.filePath))) + list = this.list.filter(s => { + const filePath = path.join(this.setting.download.savePath, s.fileName) + return !(!checkPath(filePath) || !s.isComplate || /\.ape$/.test(filePath)) + }) } else if (this.isAPITemp) { list = this.list.filter(s => s.source == 'kw') } else { diff --git a/src/renderer/store/modules/download.js b/src/renderer/store/modules/download.js index 995e1706..bb99d801 100644 --- a/src/renderer/store/modules/download.js +++ b/src/renderer/store/modules/download.js @@ -208,6 +208,10 @@ const actions = { let result = getStartTask(state.list, state.downloadStatus, rootState.setting.download.maxDownloadNum) if (!result) return if (!downloadInfo) downloadInfo = result + commit('updateFilePath', { + downloadInfo, + filePath: path.join(rootState.setting.download.savePath, downloadInfo.fileName), + }) // 开始任务 commit('onStart', downloadInfo) @@ -228,10 +232,9 @@ const actions = { // } commit('onCompleted', downloadInfo) _this.dispatch('download/startTask') - const filePath = path.join(options.path, options.fileName) - saveMeta(downloadInfo, filePath, rootState.setting.download.isEmbedPic) - if (rootState.setting.download.isDownloadLrc) downloadLyric(downloadInfo, filePath) + saveMeta(downloadInfo, downloadInfo.filePath, rootState.setting.download.isEmbedPic) + if (rootState.setting.download.isDownloadLrc) downloadLyric(downloadInfo, downloadInfo.filePath) console.log('on complate') }, onError(err) { @@ -405,6 +408,10 @@ const mutations = { updateUrl(state, { downloadInfo, url }) { downloadInfo.url = url }, + updateFilePath(state, { downloadInfo, filePath }) { + if (downloadInfo.filePath === filePath) return + downloadInfo.filePath = filePath + }, } export default { diff --git a/src/renderer/utils/download/Downloader.js b/src/renderer/utils/download/Downloader.js index 53ed77a1..bfe89ca2 100644 --- a/src/renderer/utils/download/Downloader.js +++ b/src/renderer/utils/download/Downloader.js @@ -59,6 +59,7 @@ class Task extends EventEmitter { __init() { this.status = STATUS.init const { path, startByte, endByte } = this.chunkInfo + this.progress.downloaded = 0 if (startByte != null) this.requestOptions.headers.range = `bytes=${startByte}-${endByte}` return new Promise((resolve, reject) => { if (!path) return resolve() @@ -323,6 +324,10 @@ class Task extends EventEmitter { refreshUrl(url) { this.downloadUrl = url } + + updateSaveInfo(filePath, fileName) { + this.chunkInfo.path = path.join(filePath, fileName) + } } export default Task diff --git a/src/renderer/views/Download.vue b/src/renderer/views/Download.vue index 34aa5a86..f1f73741 100644 --- a/src/renderer/views/Download.vue +++ b/src/renderer/views/Download.vue @@ -39,6 +39,8 @@ div(:class="$style.download")