下载列表的歌曲下载、播放将随设置中的保存路径改变而改变
parent
cf42e1846e
commit
c318856534
|
@ -11,6 +11,10 @@
|
|||
- 优化其他界面细节
|
||||
- 优化英语翻译,感谢 @CPCer
|
||||
|
||||
### 更变
|
||||
|
||||
- 下载列表的歌曲下载、播放将随设置中的保存路径改变而改变,不再固定指向其初始位置
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复网易源某些歌曲提示没有可播放的音质的问题
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -39,6 +39,8 @@ div(:class="$style.download")
|
|||
<script>
|
||||
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
||||
import { checkPath, openDirInExplorer } from '../utils'
|
||||
import path from 'path'
|
||||
|
||||
export default {
|
||||
name: 'Download',
|
||||
data() {
|
||||
|
@ -76,6 +78,7 @@ export default {
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['setting']),
|
||||
...mapGetters('download', ['list', 'dls', 'downloadStatus']),
|
||||
...mapGetters('player', ['listId', 'playIndex']),
|
||||
isPlayList() {
|
||||
|
@ -122,7 +125,7 @@ export default {
|
|||
methods: {
|
||||
...mapActions('download', ['removeTask', 'removeTaskMultiple', 'startTask']),
|
||||
...mapMutations('player', ['setList']),
|
||||
...mapMutations('download', ['pauseTask']),
|
||||
...mapMutations('download', ['pauseTask', 'updateFilePath']),
|
||||
handlePauseTask(index) {
|
||||
let info = this.list[index]
|
||||
let dl = this.dls[info.key]
|
||||
|
@ -133,7 +136,16 @@ export default {
|
|||
console.log('start')
|
||||
let info = this.list[index]
|
||||
let dl = this.dls[info.key]
|
||||
dl ? dl.start() : this.startTask(info)
|
||||
if (dl) {
|
||||
this.updateFilePath({
|
||||
downloadInfo: info,
|
||||
filePath: path.join(this.setting.download.savePath, info.fileName),
|
||||
})
|
||||
dl.updateSaveInfo(this.setting.download.savePath, info.fileName)
|
||||
dl.start()
|
||||
} else {
|
||||
this.startTask(info)
|
||||
}
|
||||
},
|
||||
handleDoubleClick(event, index) {
|
||||
if (event.target.classList.contains('select')) return
|
||||
|
@ -163,9 +175,9 @@ export default {
|
|||
}
|
||||
},
|
||||
handlePlay(index) {
|
||||
if (!checkPath(this.list[index].filePath)) return
|
||||
let path = this.list[index].filePath
|
||||
this.setList({ list: this.list, listId: 'download', index: this.list.findIndex(i => i.filePath === path) })
|
||||
const targetSong = this.list[index]
|
||||
if (!checkPath(path.join(this.setting.download.savePath, targetSong.fileName))) return
|
||||
this.setList({ list: this.list, listId: 'download', index: this.list.findIndex(i => i.key === targetSong.key) })
|
||||
},
|
||||
handleListBtnClick(info) {
|
||||
const key = this.showList[info.index].key
|
||||
|
|
Loading…
Reference in New Issue