添加下载失败信息状态

This commit is contained in:
lyswhut
2023-02-10 08:58:24 +08:00
parent ef9427122e
commit 6048af99bc
6 changed files with 78 additions and 62 deletions
+56 -53
View File
@@ -1,66 +1,69 @@
import { type Message } from '@/lang'
// interface DownloadList {
// }
declare namespace LX {
namespace Download {
type DownloadTaskStatus = 'run'
| 'waiting'
| 'pause'
| 'error'
| 'completed'
declare global {
namespace LX {
namespace Download {
type DownloadTaskStatus = 'run'
| 'waiting'
| 'pause'
| 'error'
| 'completed'
type FileExt = 'mp3' | 'flac' | 'wav' | 'ape'
type FileExt = 'mp3' | 'flac' | 'wav' | 'ape'
interface ProgressInfo {
progress: number
speed: string
downloaded: number
total: number
}
interface DownloadTaskActionBase <A> {
action: A
}
interface DownloadTaskActionData<A, D> extends DownloadTaskActionBase<A> {
data: D
}
type DownloadTaskAction<A, D = undefined> = D extends undefined ? DownloadTaskActionBase<A> : DownloadTaskActionData<A, D>
type DownloadTaskActions = DownloadTaskAction<'start'>
| DownloadTaskAction<'complete'>
| DownloadTaskAction<'refreshUrl'>
| DownloadTaskAction<'statusText', string>
| DownloadTaskAction<'progress', ProgressInfo>
| DownloadTaskAction<'error', {
error?: string
message?: string
}>
interface ListItem {
id: string
isComplate: boolean
status: DownloadTaskStatus
statusText: string
downloaded: number
total: number
progress: number
speed: string
metadata: {
musicInfo: LX.Music.MusicInfoOnline
url: string | null
quality: LX.Quality
ext: FileExt
fileName: string
filePath: string
interface ProgressInfo {
progress: number
speed: string
downloaded: number
total: number
}
}
interface saveDownloadMusicInfo {
list: ListItem[]
addMusicLocationType: LX.AddMusicLocationType
interface DownloadTaskActionBase <A> {
action: A
}
interface DownloadTaskActionData<A, D> extends DownloadTaskActionBase<A> {
data: D
}
type DownloadTaskAction<A, D = undefined> = D extends undefined ? DownloadTaskActionBase<A> : DownloadTaskActionData<A, D>
type DownloadTaskActions = DownloadTaskAction<'start'>
| DownloadTaskAction<'complete'>
| DownloadTaskAction<'refreshUrl'>
| DownloadTaskAction<'statusText', string>
| DownloadTaskAction<'progress', ProgressInfo>
| DownloadTaskAction<'error', {
error?: keyof Message
message?: string
}>
interface ListItem {
id: string
isComplate: boolean
status: DownloadTaskStatus
statusText: string
downloaded: number
total: number
progress: number
speed: string
metadata: {
musicInfo: LX.Music.MusicInfoOnline
url: string | null
quality: LX.Quality
ext: FileExt
fileName: string
filePath: string
}
}
interface saveDownloadMusicInfo {
list: ListItem[]
addMusicLocationType: LX.AddMusicLocationType
}
}
}
}