新增下载失败时显示搜索按钮

This commit is contained in:
lyswhut
2020-02-01 14:44:15 +08:00
parent 81985b0e31
commit 5edf51810d
3 changed files with 36 additions and 6 deletions
+18 -1
View File
@@ -134,6 +134,21 @@ const refreshUrl = function(commit, downloadInfo) {
})
}
/**
* 删除文件
* @param {*} path
*/
const deleteFile = path => new Promise((resolve, reject) => {
fs.access(path, fs.constants.F_OK, err => {
if (err) return reject(err)
fs.unlink(path, err => {
if (err) return reject(err)
resolve()
})
})
})
// actions
const actions = {
createDownload({ state, rootState, commit }, { musicInfo, type }) {
@@ -280,7 +295,9 @@ const actions = {
}
commit('removeTask', index)
if (dls[info.key]) delete dls[info.key]
this.dispatch('download/startTask')
;(info.status != state.downloadStatus.COMPLETED ? deleteFile(info.filePath) : Promise.resolve()).finally(() => {
this.dispatch('download/startTask')
})
},
removeTaskMultiple({ commit, rootState, state }, list) {
list.forEach(item => {