添加下载失败信息状态
parent
ef9427122e
commit
6048af99bc
|
@ -1,10 +1,12 @@
|
|||
import { type Message } from '@/lang'
|
||||
|
||||
// interface DownloadList {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
declare namespace LX {
|
||||
declare global {
|
||||
namespace LX {
|
||||
namespace Download {
|
||||
type DownloadTaskStatus = 'run'
|
||||
| 'waiting'
|
||||
|
@ -35,7 +37,7 @@ declare namespace LX {
|
|||
| DownloadTaskAction<'statusText', string>
|
||||
| DownloadTaskAction<'progress', ProgressInfo>
|
||||
| DownloadTaskAction<'error', {
|
||||
error?: string
|
||||
error?: keyof Message
|
||||
message?: string
|
||||
}>
|
||||
|
||||
|
@ -63,4 +65,5 @@ declare namespace LX {
|
|||
addMusicLocationType: LX.AddMusicLocationType
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
"download_status_error_check_path": "There is an error in checking the download path, please check whether the set download directory is normal",
|
||||
"download_status_error_check_path_exist": "A file with the same name exists, skip download",
|
||||
"download_status_error_refresh_url": "Link is dead, link is being refreshed",
|
||||
"download_status_error_response": "download failed:",
|
||||
"download_status_error_url_failed": "Failed to get music link",
|
||||
"download_status_error_write": "The song save location is occupied or does not have write permission, please try to change the song save directory or restart the software or restart the computer, the error details:",
|
||||
"download_status_start": "start download",
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
"download_status_error_check_path": "检查下载路径出错,请检查设置的下载目录是否正常",
|
||||
"download_status_error_check_path_exist": "存在同名文件,跳过下载",
|
||||
"download_status_error_refresh_url": "链接失效,正在刷新链接",
|
||||
"download_status_error_response": "下载失败:",
|
||||
"download_status_error_url_failed": "获取音乐链接失败",
|
||||
"download_status_error_write": "歌曲保存位置被占用或没有写入权限,请尝试更改歌曲保存目录或重启软件或重启电脑,错误详情:",
|
||||
"download_status_start": "开始下载",
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
"download_status_error_check_path": "檢查下載路徑出錯,請檢查設置的下載目錄是否正常",
|
||||
"download_status_error_check_path_exist": "存在同名文件,跳過下載",
|
||||
"download_status_error_refresh_url": "鏈接失效,正在刷新鏈接",
|
||||
"download_status_error_response": "下載失敗:",
|
||||
"download_status_error_url_failed": "獲取音樂鏈接失敗",
|
||||
"download_status_error_write": "歌曲保存位置被佔用或沒有寫入權限,請嘗試更改歌曲保存目錄或重啟軟件或重啟電腦,錯誤詳情:",
|
||||
"download_status_start": "開始下載",
|
||||
|
|
|
@ -260,10 +260,10 @@ const handleStartTask = async(downloadInfo: LX.Download.ListItem) => {
|
|||
setProgress(downloadInfo, event.data)
|
||||
break
|
||||
case 'error':
|
||||
handleError(downloadInfo, event.data.error == null
|
||||
? event.data.message ?? undefined
|
||||
// @ts-expect-error
|
||||
: window.i18n.t(event.data.error) + (event.data.message ?? ''))
|
||||
handleError(downloadInfo, event.data.error
|
||||
? window.i18n.t(event.data.error) + (event.data.message ?? '')
|
||||
: event.data.message,
|
||||
)
|
||||
break
|
||||
default:
|
||||
break
|
||||
|
|
|
@ -165,10 +165,20 @@ const createTask = async(downloadInfo: LX.Download.ListItem, savePath: string, s
|
|||
let retryNum = tryNum.get(downloadInfo.id) ?? 0
|
||||
tryNum.set(downloadInfo.id, ++retryNum)
|
||||
if (retryNum > 2) {
|
||||
if (response.statusCode) {
|
||||
sendAction(downloadInfo.id, {
|
||||
action: 'error',
|
||||
data: {
|
||||
error: 'download_status_error_response',
|
||||
message: String(response.statusCode),
|
||||
},
|
||||
})
|
||||
} else {
|
||||
sendAction(downloadInfo.id, {
|
||||
action: 'error',
|
||||
data: {},
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
switch (response.statusCode) {
|
||||
|
@ -187,7 +197,7 @@ const createTask = async(downloadInfo: LX.Download.ListItem, savePath: string, s
|
|||
}
|
||||
},
|
||||
onStart() {
|
||||
// sendAction(downloadInfo.id, { action: 'start' })
|
||||
sendAction(downloadInfo.id, { action: 'start' })
|
||||
console.log('on start')
|
||||
},
|
||||
onProgress(status) {
|
||||
|
|
Loading…
Reference in New Issue