优化任务下载状态显示

This commit is contained in:
lyswhut
2023-12-30 12:31:18 +08:00
parent 2337a3e8a3
commit 1de087eac7
11 changed files with 52 additions and 8 deletions
+10 -2
View File
@@ -82,10 +82,17 @@ const updateFilePath = (downloadInfo: LX.Download.ListItem, filePath: string) =>
}
const setProgress = (downloadInfo: LX.Download.ListItem, progress: LX.Download.ProgressInfo) => {
downloadInfo.progress = progress.progress
downloadInfo.total = progress.total
downloadInfo.downloaded = progress.downloaded
downloadInfo.speed = progress.speed
downloadInfo.writeQueue = progress.writeQueue
if (progress.progress == 100) {
downloadInfo.speed = ''
downloadInfo.progress = 99.99
setStatusText(downloadInfo, window.i18n.t('download_status_write_queue', { num: progress.writeQueue }))
} else {
downloadInfo.speed = progress.speed
downloadInfo.progress = progress.progress
}
throttleUpdateTask([downloadInfo])
}
@@ -248,6 +255,7 @@ const handleStartTask = async(downloadInfo: LX.Download.ListItem) => {
setStatus(downloadInfo, DOWNLOAD_STATUS.RUN)
break
case 'complete':
downloadInfo.progress = 100
saveMeta(downloadInfo)
downloadLyric(downloadInfo)
void window.lx.worker.download.removeTask(downloadInfo.id)
+1
View File
@@ -205,6 +205,7 @@ const createTask = async(downloadInfo: LX.Download.ListItem, savePath: string, s
downloadInfo.downloaded = status.downloaded
downloadInfo.progress = status.progress
downloadInfo.speed = status.speed
downloadInfo.writeQueue = status.writeQueue
sendAction(downloadInfo.id, { action: 'progress', data: status })
// console.log(status)
},
+1
View File
@@ -80,6 +80,7 @@ export const createDownloadInfo = (musicInfo: LX.Music.MusicInfoOnline, type: LX
total: 0,
progress: 0,
speed: '',
writeQueue: 0,
metadata: {
musicInfo,
url: null,