添加没有写入权限的提示

pull/389/head
lyswhut 2020-08-30 12:25:02 +08:00
parent 86478c0268
commit 04c810e292
3 changed files with 16 additions and 10 deletions

View File

@ -16,6 +16,7 @@
- 桌面歌词当前播放行改为上下居中
- 为区分静音状态,静音时音量条会变淡,调整音量条时将会取消静音
- 优化随机播放机制,现在通过`下一曲`切换歌曲时,直到播放完整个列表之前将不会再随机到之前播放过的歌曲,并且通过`上一曲`可以正确播放上一首歌曲
- 当下载目录没有写入权限时将显示没有写入权限的提示
### 移除

View File

@ -218,13 +218,13 @@ const refreshUrl = function(commit, downloadInfo) {
if (!dl) return
dl.refreshUrl(result.url)
dl.start().catch(err => {
commit('onError', downloadInfo)
commit('onError', { downloadInfo, errorMsg: err.message })
commit('setStatusText', { downloadInfo, text: err.message })
this.dispatch('download/startTask')
})
}).catch(err => {
// console.log(err)
commit('onError', downloadInfo)
commit('onError', { downloadInfo, errorMsg: err.message })
commit('setStatusText', { downloadInfo, text: err.message })
this.dispatch('download/startTask')
})
@ -299,7 +299,7 @@ const actions = {
try {
await checkPath(rootState.setting.download.savePath)
} catch (error) {
commit('onError', downloadInfo)
commit('onError', { downloadInfo, errorMsg: error.message })
commit('setStatusText', '检查下载目录出错: ' + error.message)
await dispatch('startTask')
return
@ -324,9 +324,14 @@ const actions = {
console.log('on complate')
},
onError(err) {
// console.log(err)
if (err.code == 'EPERM') {
commit('onError', { downloadInfo, errorMsg: '歌曲下载目录没有写入权限,请尝试更改歌曲保存路径' })
return
}
// console.log(tryNum[downloadInfo.key])
if (++tryNum[downloadInfo.key] > 2) {
commit('onError', downloadInfo)
commit('onError', { downloadInfo, errorMsg: err.message })
dispatch('startTask')
return
}
@ -375,7 +380,7 @@ const actions = {
dls[downloadInfo.key] = download(options)
}).catch(err => {
// console.log(err.message)
commit('onError', downloadInfo)
commit('onError', { downloadInfo, errorMsg: err.message })
commit('setStatusText', { downloadInfo, text: err.message })
dispatch('startTask')
})
@ -437,7 +442,7 @@ const actions = {
try {
await dl.start()
} catch (error) {
commit('onError', downloadInfo)
commit('onError', { downloadInfo, errorMsg: error.message })
commit('setStatusText', error.message)
await dispatch('startTask')
}
@ -448,7 +453,7 @@ const actions = {
startTasks(store, list) {
if (isRuningActionTask) return
isRuningActionTask = true
return startTasks(store, [...list]).finally(() => {
return startTasks(store, list.filter(item => !(item.isComplate || item.status == state.downloadStatus.RUN || item.status == state.downloadStatus.WAITING))).finally(() => {
isRuningActionTask = false
})
},
@ -522,9 +527,9 @@ const mutations = {
downloadInfo.status = state.downloadStatus.COMPLETED
downloadInfo.statusText = '下载完成'
},
onError(state, downloadInfo) {
onError(state, { downloadInfo, errorMsg }) {
downloadInfo.status = state.downloadStatus.ERROR
downloadInfo.statusText = '任务出错'
downloadInfo.statusText = errorMsg || '任务出错'
},
onStart(state, downloadInfo) {
downloadInfo.status = state.downloadStatus.RUN

View File

@ -172,7 +172,7 @@ class Task extends EventEmitter {
this.chunkInfo.startByte = 0
this.resumeLastChunk = null
this.progress.downloaded = 0
if (unlinkErr) this.__handleError(unlinkErr)
if (unlinkErr && unlinkErr.code !== 'ENOENT') this.__handleError(unlinkErr)
})
})
}