下载列表的歌曲下载、播放将随设置中的保存路径改变而改变
parent
cf42e1846e
commit
c318856534
|
@ -11,6 +11,10 @@
|
||||||
- 优化其他界面细节
|
- 优化其他界面细节
|
||||||
- 优化英语翻译,感谢 @CPCer
|
- 优化英语翻译,感谢 @CPCer
|
||||||
|
|
||||||
|
### 更变
|
||||||
|
|
||||||
|
- 下载列表的歌曲下载、播放将随设置中的保存路径改变而改变,不再固定指向其初始位置
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
- 修复网易源某些歌曲提示没有可播放的音质的问题
|
- 修复网易源某些歌曲提示没有可播放的音质的问题
|
||||||
|
|
|
@ -53,6 +53,7 @@ import { formatPlayTime2, getRandom, checkPath, setTitle, clipboardWriteText, de
|
||||||
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
||||||
import { requestMsg } from '../../utils/message'
|
import { requestMsg } from '../../utils/message'
|
||||||
import { isMac } from '../../../common/utils'
|
import { isMac } from '../../../common/utils'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -305,15 +306,16 @@ export default {
|
||||||
this.audioErrorTime = 0
|
this.audioErrorTime = 0
|
||||||
|
|
||||||
if (this.listId == 'download') {
|
if (this.listId == 'download') {
|
||||||
console.log(targetSong.filePath)
|
const filePath = path.join(this.setting.download.savePath, targetSong.fileName)
|
||||||
if (!checkPath(targetSong.filePath) || !targetSong.isComplate || /\.ape$/.test(targetSong.filePath)) {
|
// console.log(filePath)
|
||||||
|
if (!checkPath(filePath) || !targetSong.isComplate || /\.ape$/.test(filePath)) {
|
||||||
return this.list.length == 1 ? null : this.handleNext()
|
return this.list.length == 1 ? null : this.handleNext()
|
||||||
}
|
}
|
||||||
this.musicInfo.songmid = targetSong.musicInfo.songmid
|
this.musicInfo.songmid = targetSong.musicInfo.songmid
|
||||||
this.musicInfo.singer = targetSong.musicInfo.singer
|
this.musicInfo.singer = targetSong.musicInfo.singer
|
||||||
this.musicInfo.name = targetSong.musicInfo.name
|
this.musicInfo.name = targetSong.musicInfo.name
|
||||||
this.audio.src = targetSong.filePath
|
this.audio.src = filePath
|
||||||
// console.log(targetSong.filePath)
|
// console.log(filePath)
|
||||||
this.setImg(targetSong.musicInfo)
|
this.setImg(targetSong.musicInfo)
|
||||||
this.setLrc(targetSong.musicInfo)
|
this.setLrc(targetSong.musicInfo)
|
||||||
} else {
|
} else {
|
||||||
|
@ -343,7 +345,10 @@ export default {
|
||||||
// if (this.list.listName === null) return
|
// if (this.list.listName === null) return
|
||||||
let list
|
let list
|
||||||
if (this.listId == 'download') {
|
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) {
|
} else if (this.isAPITemp) {
|
||||||
list = this.list.filter(s => s.source == 'kw')
|
list = this.list.filter(s => s.source == 'kw')
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -208,6 +208,10 @@ const actions = {
|
||||||
let result = getStartTask(state.list, state.downloadStatus, rootState.setting.download.maxDownloadNum)
|
let result = getStartTask(state.list, state.downloadStatus, rootState.setting.download.maxDownloadNum)
|
||||||
if (!result) return
|
if (!result) return
|
||||||
if (!downloadInfo) downloadInfo = result
|
if (!downloadInfo) downloadInfo = result
|
||||||
|
commit('updateFilePath', {
|
||||||
|
downloadInfo,
|
||||||
|
filePath: path.join(rootState.setting.download.savePath, downloadInfo.fileName),
|
||||||
|
})
|
||||||
|
|
||||||
// 开始任务
|
// 开始任务
|
||||||
commit('onStart', downloadInfo)
|
commit('onStart', downloadInfo)
|
||||||
|
@ -228,10 +232,9 @@ const actions = {
|
||||||
// }
|
// }
|
||||||
commit('onCompleted', downloadInfo)
|
commit('onCompleted', downloadInfo)
|
||||||
_this.dispatch('download/startTask')
|
_this.dispatch('download/startTask')
|
||||||
const filePath = path.join(options.path, options.fileName)
|
|
||||||
|
|
||||||
saveMeta(downloadInfo, filePath, rootState.setting.download.isEmbedPic)
|
saveMeta(downloadInfo, downloadInfo.filePath, rootState.setting.download.isEmbedPic)
|
||||||
if (rootState.setting.download.isDownloadLrc) downloadLyric(downloadInfo, filePath)
|
if (rootState.setting.download.isDownloadLrc) downloadLyric(downloadInfo, downloadInfo.filePath)
|
||||||
console.log('on complate')
|
console.log('on complate')
|
||||||
},
|
},
|
||||||
onError(err) {
|
onError(err) {
|
||||||
|
@ -405,6 +408,10 @@ const mutations = {
|
||||||
updateUrl(state, { downloadInfo, url }) {
|
updateUrl(state, { downloadInfo, url }) {
|
||||||
downloadInfo.url = url
|
downloadInfo.url = url
|
||||||
},
|
},
|
||||||
|
updateFilePath(state, { downloadInfo, filePath }) {
|
||||||
|
if (downloadInfo.filePath === filePath) return
|
||||||
|
downloadInfo.filePath = filePath
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -59,6 +59,7 @@ class Task extends EventEmitter {
|
||||||
__init() {
|
__init() {
|
||||||
this.status = STATUS.init
|
this.status = STATUS.init
|
||||||
const { path, startByte, endByte } = this.chunkInfo
|
const { path, startByte, endByte } = this.chunkInfo
|
||||||
|
this.progress.downloaded = 0
|
||||||
if (startByte != null) this.requestOptions.headers.range = `bytes=${startByte}-${endByte}`
|
if (startByte != null) this.requestOptions.headers.range = `bytes=${startByte}-${endByte}`
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!path) return resolve()
|
if (!path) return resolve()
|
||||||
|
@ -323,6 +324,10 @@ class Task extends EventEmitter {
|
||||||
refreshUrl(url) {
|
refreshUrl(url) {
|
||||||
this.downloadUrl = url
|
this.downloadUrl = url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateSaveInfo(filePath, fileName) {
|
||||||
|
this.chunkInfo.path = path.join(filePath, fileName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Task
|
export default Task
|
||||||
|
|
|
@ -39,6 +39,8 @@ div(:class="$style.download")
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
||||||
import { checkPath, openDirInExplorer } from '../utils'
|
import { checkPath, openDirInExplorer } from '../utils'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Download',
|
name: 'Download',
|
||||||
data() {
|
data() {
|
||||||
|
@ -76,6 +78,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters(['setting']),
|
||||||
...mapGetters('download', ['list', 'dls', 'downloadStatus']),
|
...mapGetters('download', ['list', 'dls', 'downloadStatus']),
|
||||||
...mapGetters('player', ['listId', 'playIndex']),
|
...mapGetters('player', ['listId', 'playIndex']),
|
||||||
isPlayList() {
|
isPlayList() {
|
||||||
|
@ -122,7 +125,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('download', ['removeTask', 'removeTaskMultiple', 'startTask']),
|
...mapActions('download', ['removeTask', 'removeTaskMultiple', 'startTask']),
|
||||||
...mapMutations('player', ['setList']),
|
...mapMutations('player', ['setList']),
|
||||||
...mapMutations('download', ['pauseTask']),
|
...mapMutations('download', ['pauseTask', 'updateFilePath']),
|
||||||
handlePauseTask(index) {
|
handlePauseTask(index) {
|
||||||
let info = this.list[index]
|
let info = this.list[index]
|
||||||
let dl = this.dls[info.key]
|
let dl = this.dls[info.key]
|
||||||
|
@ -133,7 +136,16 @@ export default {
|
||||||
console.log('start')
|
console.log('start')
|
||||||
let info = this.list[index]
|
let info = this.list[index]
|
||||||
let dl = this.dls[info.key]
|
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) {
|
handleDoubleClick(event, index) {
|
||||||
if (event.target.classList.contains('select')) return
|
if (event.target.classList.contains('select')) return
|
||||||
|
@ -163,9 +175,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handlePlay(index) {
|
handlePlay(index) {
|
||||||
if (!checkPath(this.list[index].filePath)) return
|
const targetSong = this.list[index]
|
||||||
let path = this.list[index].filePath
|
if (!checkPath(path.join(this.setting.download.savePath, targetSong.fileName))) return
|
||||||
this.setList({ list: this.list, listId: 'download', index: this.list.findIndex(i => i.filePath === path) })
|
this.setList({ list: this.list, listId: 'download', index: this.list.findIndex(i => i.key === targetSong.key) })
|
||||||
},
|
},
|
||||||
handleListBtnClick(info) {
|
handleListBtnClick(info) {
|
||||||
const key = this.showList[info.index].key
|
const key = this.showList[info.index].key
|
||||||
|
|
Loading…
Reference in New Issue