fileuploadsdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.esm.js +2 -0
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/index.cjs.js +11 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +378 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +11 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +11 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/constants/errmsg.d.ts +6 -0
- package/dist/types/core/parallel-uploader.d.ts +16 -0
- package/dist/types/core/slice-uploader.d.ts +38 -0
- package/dist/types/core/upload.d.ts +21 -0
- package/dist/types/core/web-worker-helper.d.ts +16 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/react/components/Progress.d.ts +9 -0
- package/dist/types/react/components/Upload.d.ts +13 -0
- package/dist/types/react/components/UploadList.d.ts +11 -0
- package/dist/types/react/hooks/useUpload.d.ts +14 -0
- package/dist/types/react/index.d.ts +6 -0
- package/dist/types/types/index.d.ts +224 -0
- package/dist/types/utils/file.d.ts +52 -0
- package/dist/types/vue/components/Progress.vue.d.ts +17 -0
- package/dist/types/vue/components/Upload.vue.d.ts +232 -0
- package/dist/types/vue/components/UploadList.vue.d.ts +26 -0
- package/dist/types/vue/composables/useUpload.d.ts +90 -0
- package/dist/types/vue/index.d.ts +6 -0
- package/dist/umd/index.d.ts +3 -0
- package/dist/umd/index.d.ts.map +1 -0
- package/dist/umd/index.umd.js +2 -0
- package/dist/umd/index.umd.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { UploadConfig } from '../../types/index';
|
|
3
|
+
import './UploadStyles.css';
|
|
4
|
+
interface UploadProps extends UploadConfig {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
drag?: boolean;
|
|
9
|
+
showFileList?: boolean;
|
|
10
|
+
listType?: 'text' | 'picture' | 'picture-card';
|
|
11
|
+
}
|
|
12
|
+
declare const Upload: React.FC<UploadProps>;
|
|
13
|
+
export default Upload;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { UploadFile } from '../../types/index';
|
|
3
|
+
interface UploadListProps {
|
|
4
|
+
fileList: UploadFile[];
|
|
5
|
+
listType: 'text' | 'picture' | 'picture-card';
|
|
6
|
+
onCancel: (uid: string) => void;
|
|
7
|
+
onRetry: (uid: string) => void;
|
|
8
|
+
onRemove: (uid: string) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const UploadList: React.FC<UploadListProps>;
|
|
11
|
+
export default UploadList;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UploadConfig, UploadFile } from '../../types/index';
|
|
2
|
+
import { SliceUploader } from '../../core/slice-uploader';
|
|
3
|
+
import { ParallelUploader } from '../../core/parallel-uploader';
|
|
4
|
+
export declare const useUpload: (config: UploadConfig) => {
|
|
5
|
+
fileList: UploadFile[];
|
|
6
|
+
uploading: boolean;
|
|
7
|
+
handleFileSelect: (files: FileList | File[]) => void;
|
|
8
|
+
uploadAll: () => Promise<void>;
|
|
9
|
+
cancelUpload: (uid: string) => void;
|
|
10
|
+
retryUpload: (uid: string) => Promise<void>;
|
|
11
|
+
removeFile: (uid: string) => void;
|
|
12
|
+
clearFiles: () => void;
|
|
13
|
+
uploader: SliceUploader | ParallelUploader | null;
|
|
14
|
+
};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
export interface UploadConfig {
|
|
2
|
+
/**
|
|
3
|
+
* 上传接口地址
|
|
4
|
+
*/
|
|
5
|
+
url: string;
|
|
6
|
+
/**
|
|
7
|
+
* 上传方法
|
|
8
|
+
*/
|
|
9
|
+
method?: 'POST' | 'PUT' | 'PATCH';
|
|
10
|
+
/**
|
|
11
|
+
* 请求头
|
|
12
|
+
*/
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* 超时时间
|
|
16
|
+
*/
|
|
17
|
+
timeout?: number;
|
|
18
|
+
/**
|
|
19
|
+
* 是否跨域
|
|
20
|
+
*/
|
|
21
|
+
withCredentials?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 最大重试次数
|
|
24
|
+
*/
|
|
25
|
+
maxRetries?: number;
|
|
26
|
+
/**
|
|
27
|
+
* 重试延迟时间
|
|
28
|
+
*/
|
|
29
|
+
retryDelay?: number;
|
|
30
|
+
/**
|
|
31
|
+
* 分片大小
|
|
32
|
+
*/
|
|
33
|
+
chunkSize?: number;
|
|
34
|
+
/**
|
|
35
|
+
* 分片重试次数
|
|
36
|
+
*/
|
|
37
|
+
chunkRetry?: number;
|
|
38
|
+
/**
|
|
39
|
+
* 并发数
|
|
40
|
+
*/
|
|
41
|
+
concurrency?: number;
|
|
42
|
+
/**
|
|
43
|
+
* 是否自动上传
|
|
44
|
+
*/
|
|
45
|
+
autoUpload?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* 是否多选
|
|
48
|
+
*/
|
|
49
|
+
multiple?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* 接受的文件类型
|
|
52
|
+
*/
|
|
53
|
+
accept?: string;
|
|
54
|
+
/**
|
|
55
|
+
* 最大文件大小
|
|
56
|
+
*/
|
|
57
|
+
maxSize?: number;
|
|
58
|
+
/**
|
|
59
|
+
* 最小文件大小
|
|
60
|
+
*/
|
|
61
|
+
minSize?: number;
|
|
62
|
+
/**
|
|
63
|
+
* 上传进度回调
|
|
64
|
+
*/
|
|
65
|
+
onProgress?: (progress: ProgressEvent) => void;
|
|
66
|
+
/**
|
|
67
|
+
* 上传成功回调
|
|
68
|
+
*/
|
|
69
|
+
onSuccess?: (response: any, file: UploadFile) => void;
|
|
70
|
+
/**
|
|
71
|
+
* 上传失败回调
|
|
72
|
+
*/
|
|
73
|
+
onError?: (error: Error, file: UploadFile) => void;
|
|
74
|
+
/**
|
|
75
|
+
* 上传取消回调
|
|
76
|
+
*/
|
|
77
|
+
onCancel?: (file: UploadFile) => void;
|
|
78
|
+
beforeUpload?: (file: File) => boolean | Promise<boolean>;
|
|
79
|
+
/**
|
|
80
|
+
* 文件列表改变回调
|
|
81
|
+
*/
|
|
82
|
+
onFileListChange?: (fileList: UploadFile[]) => void;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 上传文件对象
|
|
86
|
+
*/
|
|
87
|
+
export interface UploadFile {
|
|
88
|
+
/**
|
|
89
|
+
* 文件唯一标识
|
|
90
|
+
*/
|
|
91
|
+
uid: string;
|
|
92
|
+
/**
|
|
93
|
+
* 文件对象
|
|
94
|
+
*/
|
|
95
|
+
file: File;
|
|
96
|
+
/**
|
|
97
|
+
* 文件名
|
|
98
|
+
*/
|
|
99
|
+
name: string;
|
|
100
|
+
/**
|
|
101
|
+
* 文件大小
|
|
102
|
+
*/
|
|
103
|
+
size: number;
|
|
104
|
+
/**
|
|
105
|
+
* 文件类型
|
|
106
|
+
*/
|
|
107
|
+
type: string;
|
|
108
|
+
/**
|
|
109
|
+
* 上传状态
|
|
110
|
+
*/
|
|
111
|
+
status: 'pending' | 'uploading' | 'success' | 'error' | 'canceled';
|
|
112
|
+
/**
|
|
113
|
+
* 上传进度
|
|
114
|
+
*/
|
|
115
|
+
percent: number;
|
|
116
|
+
/**
|
|
117
|
+
* 上传响应
|
|
118
|
+
*/
|
|
119
|
+
response?: any;
|
|
120
|
+
/**
|
|
121
|
+
* 上传错误
|
|
122
|
+
*/
|
|
123
|
+
error?: Error;
|
|
124
|
+
/**
|
|
125
|
+
* 文件分片列表
|
|
126
|
+
*/
|
|
127
|
+
chunkList?: FileChunk[];
|
|
128
|
+
/**
|
|
129
|
+
* 文件哈希值
|
|
130
|
+
*/
|
|
131
|
+
hash?: string;
|
|
132
|
+
/**
|
|
133
|
+
* 已上传大小
|
|
134
|
+
*/
|
|
135
|
+
uploadedSize: number;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 文件分片对象
|
|
139
|
+
*/
|
|
140
|
+
export interface FileChunk {
|
|
141
|
+
/**
|
|
142
|
+
* 分片索引
|
|
143
|
+
*/
|
|
144
|
+
index: number;
|
|
145
|
+
/**
|
|
146
|
+
* 分片对象
|
|
147
|
+
*/
|
|
148
|
+
chunk: Blob;
|
|
149
|
+
/**
|
|
150
|
+
* 分片哈希值
|
|
151
|
+
*/
|
|
152
|
+
hash: string;
|
|
153
|
+
/**
|
|
154
|
+
* 分片大小
|
|
155
|
+
*/
|
|
156
|
+
size: number;
|
|
157
|
+
/**
|
|
158
|
+
* 分片上传进度
|
|
159
|
+
*/
|
|
160
|
+
progress: number;
|
|
161
|
+
/**
|
|
162
|
+
* 分片上传状态
|
|
163
|
+
*/
|
|
164
|
+
status: 'pending' | 'uploading' | 'success' | 'error';
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 秒传检查结果对象
|
|
168
|
+
*/
|
|
169
|
+
export interface CheckResult {
|
|
170
|
+
/**
|
|
171
|
+
* 是否需要上传
|
|
172
|
+
*/
|
|
173
|
+
shouldUpload: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* 已上传分片索引列表
|
|
176
|
+
*/
|
|
177
|
+
uploadedList?: string[];
|
|
178
|
+
/**
|
|
179
|
+
* 是否文件已存在
|
|
180
|
+
*/
|
|
181
|
+
fileExists?: boolean;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* 上传参数对象
|
|
185
|
+
*/
|
|
186
|
+
export interface UploadParams {
|
|
187
|
+
/**
|
|
188
|
+
* 文件对象
|
|
189
|
+
*/
|
|
190
|
+
file: File;
|
|
191
|
+
/**
|
|
192
|
+
* 分片索引
|
|
193
|
+
*/
|
|
194
|
+
chunkIndex?: number;
|
|
195
|
+
/**
|
|
196
|
+
* 总分片数
|
|
197
|
+
*/
|
|
198
|
+
totalChunks?: number;
|
|
199
|
+
/**
|
|
200
|
+
* 分片哈希值
|
|
201
|
+
*/
|
|
202
|
+
chunkHash?: string;
|
|
203
|
+
/**
|
|
204
|
+
* 文件哈希值
|
|
205
|
+
*/
|
|
206
|
+
fileHash?: string;
|
|
207
|
+
/**
|
|
208
|
+
* 文件名
|
|
209
|
+
*/
|
|
210
|
+
fileName?: string;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Web Worker 消息对象
|
|
214
|
+
*/
|
|
215
|
+
export interface WorkerMessage {
|
|
216
|
+
/**
|
|
217
|
+
* 消息类型
|
|
218
|
+
*/
|
|
219
|
+
type: 'hash' | 'slice';
|
|
220
|
+
/**
|
|
221
|
+
* 消息数据
|
|
222
|
+
*/
|
|
223
|
+
data: unknown;
|
|
224
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 生成文件哈希值
|
|
3
|
+
* @param file 文件对象
|
|
4
|
+
* @returns 文件哈希值
|
|
5
|
+
*/
|
|
6
|
+
export declare const generateFileId: (file: File) => string;
|
|
7
|
+
/**
|
|
8
|
+
* 获取文件扩展名
|
|
9
|
+
* @param filename 文件名
|
|
10
|
+
* @returns 文件扩展名
|
|
11
|
+
*/
|
|
12
|
+
export declare const getFileExtension: (filename: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* 验证文件类型是否符合要求
|
|
15
|
+
* @param file 文件对象
|
|
16
|
+
* @param accept 接受的文件类型
|
|
17
|
+
* @returns 是否符合要求
|
|
18
|
+
*/
|
|
19
|
+
export declare const validateFileType: (file: File, accept?: string) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 验证文件大小是否符合要求
|
|
22
|
+
* @param file 文件对象
|
|
23
|
+
* @param maxSize 最大文件大小
|
|
24
|
+
* @param minSize 最小文件大小
|
|
25
|
+
* @returns 是否符合要求
|
|
26
|
+
*/
|
|
27
|
+
export declare const validateFileSize: (file: File, maxSize?: number, minSize?: number) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 创建文件分片
|
|
30
|
+
* @param file 文件对象
|
|
31
|
+
* @param chunkSize 分片大小
|
|
32
|
+
* @returns 文件分片列表
|
|
33
|
+
*/
|
|
34
|
+
export declare const createFileChunks: (file: File, chunkSize: number) => Blob[];
|
|
35
|
+
/**
|
|
36
|
+
* 计算文件哈希值
|
|
37
|
+
* @param file 文件对象
|
|
38
|
+
* @returns 文件哈希值
|
|
39
|
+
*/
|
|
40
|
+
export declare const calculateFileHash: (file: File) => Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* 计算文件分片大小
|
|
43
|
+
* @param fileSize 文件大小
|
|
44
|
+
* @returns 分片大小
|
|
45
|
+
*/
|
|
46
|
+
export declare const calculateChunkSize: (fileSize: number) => number;
|
|
47
|
+
/**
|
|
48
|
+
* 格式化文件大小
|
|
49
|
+
* @param bytes 文件大小
|
|
50
|
+
* @returns 格式化后的文件大小
|
|
51
|
+
*/
|
|
52
|
+
export declare const formatFileSize: (bytes: number) => string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
fileList: {
|
|
3
|
+
type: ArrayConstructor;
|
|
4
|
+
required: true;
|
|
5
|
+
};
|
|
6
|
+
}>, (_ctx: any, _cache: any) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("upload-all" | "clear")[], "upload-all" | "clear", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
+
fileList: {
|
|
10
|
+
type: ArrayConstructor;
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
}>> & Readonly<{
|
|
14
|
+
"onUpload-all"?: ((...args: any[]) => any) | undefined;
|
|
15
|
+
onClear?: ((...args: any[]) => any) | undefined;
|
|
16
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
className: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
required: false;
|
|
5
|
+
};
|
|
6
|
+
style: {
|
|
7
|
+
type: ObjectConstructor;
|
|
8
|
+
required: false;
|
|
9
|
+
};
|
|
10
|
+
drag: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
required: false;
|
|
13
|
+
default: boolean;
|
|
14
|
+
};
|
|
15
|
+
showFileList: {
|
|
16
|
+
type: BooleanConstructor;
|
|
17
|
+
required: false;
|
|
18
|
+
default: boolean;
|
|
19
|
+
};
|
|
20
|
+
listType: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
required: false;
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
url: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
required: true;
|
|
28
|
+
};
|
|
29
|
+
method: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
required: false;
|
|
32
|
+
default: string;
|
|
33
|
+
};
|
|
34
|
+
headers: {
|
|
35
|
+
type: ObjectConstructor;
|
|
36
|
+
required: false;
|
|
37
|
+
};
|
|
38
|
+
timeout: {
|
|
39
|
+
type: NumberConstructor;
|
|
40
|
+
required: false;
|
|
41
|
+
default: number;
|
|
42
|
+
};
|
|
43
|
+
withCredentials: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
required: false;
|
|
46
|
+
default: boolean;
|
|
47
|
+
};
|
|
48
|
+
chunkSize: {
|
|
49
|
+
type: NumberConstructor;
|
|
50
|
+
required: false;
|
|
51
|
+
default: number;
|
|
52
|
+
};
|
|
53
|
+
chunkRetry: {
|
|
54
|
+
type: NumberConstructor;
|
|
55
|
+
required: false;
|
|
56
|
+
default: number;
|
|
57
|
+
};
|
|
58
|
+
concurrent: {
|
|
59
|
+
type: NumberConstructor;
|
|
60
|
+
required: false;
|
|
61
|
+
default: number;
|
|
62
|
+
};
|
|
63
|
+
autoUpload: {
|
|
64
|
+
type: BooleanConstructor;
|
|
65
|
+
required: false;
|
|
66
|
+
default: boolean;
|
|
67
|
+
};
|
|
68
|
+
multiple: {
|
|
69
|
+
type: BooleanConstructor;
|
|
70
|
+
required: false;
|
|
71
|
+
default: boolean;
|
|
72
|
+
};
|
|
73
|
+
accept: {
|
|
74
|
+
type: StringConstructor;
|
|
75
|
+
required: false;
|
|
76
|
+
};
|
|
77
|
+
maxSize: {
|
|
78
|
+
type: NumberConstructor;
|
|
79
|
+
required: false;
|
|
80
|
+
};
|
|
81
|
+
minSize: {
|
|
82
|
+
type: NumberConstructor;
|
|
83
|
+
required: false;
|
|
84
|
+
};
|
|
85
|
+
onProgress: {
|
|
86
|
+
type: FunctionConstructor;
|
|
87
|
+
required: false;
|
|
88
|
+
};
|
|
89
|
+
onSuccess: {
|
|
90
|
+
type: FunctionConstructor;
|
|
91
|
+
required: false;
|
|
92
|
+
};
|
|
93
|
+
onError: {
|
|
94
|
+
type: FunctionConstructor;
|
|
95
|
+
required: false;
|
|
96
|
+
};
|
|
97
|
+
onCancel: {
|
|
98
|
+
type: FunctionConstructor;
|
|
99
|
+
required: false;
|
|
100
|
+
};
|
|
101
|
+
beforeUpload: {
|
|
102
|
+
type: FunctionConstructor;
|
|
103
|
+
required: false;
|
|
104
|
+
};
|
|
105
|
+
onFileListChange: {
|
|
106
|
+
type: FunctionConstructor;
|
|
107
|
+
required: false;
|
|
108
|
+
};
|
|
109
|
+
}>, (_ctx: any, _cache: any) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
110
|
+
[key: string]: any;
|
|
111
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
112
|
+
className: {
|
|
113
|
+
type: StringConstructor;
|
|
114
|
+
required: false;
|
|
115
|
+
};
|
|
116
|
+
style: {
|
|
117
|
+
type: ObjectConstructor;
|
|
118
|
+
required: false;
|
|
119
|
+
};
|
|
120
|
+
drag: {
|
|
121
|
+
type: BooleanConstructor;
|
|
122
|
+
required: false;
|
|
123
|
+
default: boolean;
|
|
124
|
+
};
|
|
125
|
+
showFileList: {
|
|
126
|
+
type: BooleanConstructor;
|
|
127
|
+
required: false;
|
|
128
|
+
default: boolean;
|
|
129
|
+
};
|
|
130
|
+
listType: {
|
|
131
|
+
type: StringConstructor;
|
|
132
|
+
required: false;
|
|
133
|
+
default: string;
|
|
134
|
+
};
|
|
135
|
+
url: {
|
|
136
|
+
type: StringConstructor;
|
|
137
|
+
required: true;
|
|
138
|
+
};
|
|
139
|
+
method: {
|
|
140
|
+
type: StringConstructor;
|
|
141
|
+
required: false;
|
|
142
|
+
default: string;
|
|
143
|
+
};
|
|
144
|
+
headers: {
|
|
145
|
+
type: ObjectConstructor;
|
|
146
|
+
required: false;
|
|
147
|
+
};
|
|
148
|
+
timeout: {
|
|
149
|
+
type: NumberConstructor;
|
|
150
|
+
required: false;
|
|
151
|
+
default: number;
|
|
152
|
+
};
|
|
153
|
+
withCredentials: {
|
|
154
|
+
type: BooleanConstructor;
|
|
155
|
+
required: false;
|
|
156
|
+
default: boolean;
|
|
157
|
+
};
|
|
158
|
+
chunkSize: {
|
|
159
|
+
type: NumberConstructor;
|
|
160
|
+
required: false;
|
|
161
|
+
default: number;
|
|
162
|
+
};
|
|
163
|
+
chunkRetry: {
|
|
164
|
+
type: NumberConstructor;
|
|
165
|
+
required: false;
|
|
166
|
+
default: number;
|
|
167
|
+
};
|
|
168
|
+
concurrent: {
|
|
169
|
+
type: NumberConstructor;
|
|
170
|
+
required: false;
|
|
171
|
+
default: number;
|
|
172
|
+
};
|
|
173
|
+
autoUpload: {
|
|
174
|
+
type: BooleanConstructor;
|
|
175
|
+
required: false;
|
|
176
|
+
default: boolean;
|
|
177
|
+
};
|
|
178
|
+
multiple: {
|
|
179
|
+
type: BooleanConstructor;
|
|
180
|
+
required: false;
|
|
181
|
+
default: boolean;
|
|
182
|
+
};
|
|
183
|
+
accept: {
|
|
184
|
+
type: StringConstructor;
|
|
185
|
+
required: false;
|
|
186
|
+
};
|
|
187
|
+
maxSize: {
|
|
188
|
+
type: NumberConstructor;
|
|
189
|
+
required: false;
|
|
190
|
+
};
|
|
191
|
+
minSize: {
|
|
192
|
+
type: NumberConstructor;
|
|
193
|
+
required: false;
|
|
194
|
+
};
|
|
195
|
+
onProgress: {
|
|
196
|
+
type: FunctionConstructor;
|
|
197
|
+
required: false;
|
|
198
|
+
};
|
|
199
|
+
onSuccess: {
|
|
200
|
+
type: FunctionConstructor;
|
|
201
|
+
required: false;
|
|
202
|
+
};
|
|
203
|
+
onError: {
|
|
204
|
+
type: FunctionConstructor;
|
|
205
|
+
required: false;
|
|
206
|
+
};
|
|
207
|
+
onCancel: {
|
|
208
|
+
type: FunctionConstructor;
|
|
209
|
+
required: false;
|
|
210
|
+
};
|
|
211
|
+
beforeUpload: {
|
|
212
|
+
type: FunctionConstructor;
|
|
213
|
+
required: false;
|
|
214
|
+
};
|
|
215
|
+
onFileListChange: {
|
|
216
|
+
type: FunctionConstructor;
|
|
217
|
+
required: false;
|
|
218
|
+
};
|
|
219
|
+
}>> & Readonly<{}>, {
|
|
220
|
+
multiple: boolean;
|
|
221
|
+
drag: boolean;
|
|
222
|
+
showFileList: boolean;
|
|
223
|
+
listType: string;
|
|
224
|
+
method: string;
|
|
225
|
+
timeout: number;
|
|
226
|
+
withCredentials: boolean;
|
|
227
|
+
chunkSize: number;
|
|
228
|
+
chunkRetry: number;
|
|
229
|
+
concurrent: number;
|
|
230
|
+
autoUpload: boolean;
|
|
231
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
232
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
fileList: {
|
|
3
|
+
type: ArrayConstructor;
|
|
4
|
+
required: true;
|
|
5
|
+
};
|
|
6
|
+
listType: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
10
|
+
}>, (_ctx: any, _cache: any) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("cancel" | "retry" | "remove")[], "cancel" | "retry" | "remove", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
13
|
+
fileList: {
|
|
14
|
+
type: ArrayConstructor;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
listType: {
|
|
18
|
+
type: StringConstructor;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
}>> & Readonly<{
|
|
22
|
+
onCancel?: ((...args: any[]) => any) | undefined;
|
|
23
|
+
onRetry?: ((...args: any[]) => any) | undefined;
|
|
24
|
+
onRemove?: ((...args: any[]) => any) | undefined;
|
|
25
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { UploadConfig, UploadFile } from '../../types/index';
|
|
2
|
+
export declare const useUpload: (config: UploadConfig) => {
|
|
3
|
+
fileList: import("vue").Ref<{
|
|
4
|
+
uid: string;
|
|
5
|
+
file: {
|
|
6
|
+
readonly lastModified: number;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly webkitRelativePath: string;
|
|
9
|
+
readonly size: number;
|
|
10
|
+
readonly type: string;
|
|
11
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
12
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
13
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
14
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
15
|
+
text: () => Promise<string>;
|
|
16
|
+
};
|
|
17
|
+
name: string;
|
|
18
|
+
size: number;
|
|
19
|
+
type: string;
|
|
20
|
+
status: "pending" | "uploading" | "success" | "error" | "canceled";
|
|
21
|
+
percent: number;
|
|
22
|
+
response?: any;
|
|
23
|
+
error?: Error | undefined;
|
|
24
|
+
chunkList?: {
|
|
25
|
+
index: number;
|
|
26
|
+
chunk: {
|
|
27
|
+
readonly size: number;
|
|
28
|
+
readonly type: string;
|
|
29
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
30
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
31
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
32
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
33
|
+
text: () => Promise<string>;
|
|
34
|
+
};
|
|
35
|
+
hash: string;
|
|
36
|
+
size: number;
|
|
37
|
+
progress: number;
|
|
38
|
+
status: "pending" | "uploading" | "success" | "error";
|
|
39
|
+
}[] | undefined;
|
|
40
|
+
hash?: string | undefined;
|
|
41
|
+
uploadedSize: number;
|
|
42
|
+
}[], UploadFile[] | {
|
|
43
|
+
uid: string;
|
|
44
|
+
file: {
|
|
45
|
+
readonly lastModified: number;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly webkitRelativePath: string;
|
|
48
|
+
readonly size: number;
|
|
49
|
+
readonly type: string;
|
|
50
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
51
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
52
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
53
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
54
|
+
text: () => Promise<string>;
|
|
55
|
+
};
|
|
56
|
+
name: string;
|
|
57
|
+
size: number;
|
|
58
|
+
type: string;
|
|
59
|
+
status: "pending" | "uploading" | "success" | "error" | "canceled";
|
|
60
|
+
percent: number;
|
|
61
|
+
response?: any;
|
|
62
|
+
error?: Error | undefined;
|
|
63
|
+
chunkList?: {
|
|
64
|
+
index: number;
|
|
65
|
+
chunk: {
|
|
66
|
+
readonly size: number;
|
|
67
|
+
readonly type: string;
|
|
68
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
69
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
70
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
71
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
72
|
+
text: () => Promise<string>;
|
|
73
|
+
};
|
|
74
|
+
hash: string;
|
|
75
|
+
size: number;
|
|
76
|
+
progress: number;
|
|
77
|
+
status: "pending" | "uploading" | "success" | "error";
|
|
78
|
+
}[] | undefined;
|
|
79
|
+
hash?: string | undefined;
|
|
80
|
+
uploadedSize: number;
|
|
81
|
+
}[]>;
|
|
82
|
+
uploading: import("vue").Ref<boolean, boolean>;
|
|
83
|
+
handleFileSelect: (files: FileList | File[]) => void;
|
|
84
|
+
uploadAll: () => Promise<void>;
|
|
85
|
+
cancelUpload: (uid: string) => void;
|
|
86
|
+
retryUpload: (uid: string) => Promise<void>;
|
|
87
|
+
removeFile: (uid: string) => void;
|
|
88
|
+
clearFiles: () => void;
|
|
89
|
+
uploader: null;
|
|
90
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Upload from './components/Upload.vue';
|
|
2
|
+
import UploadList from './components/UploadList.vue';
|
|
3
|
+
import Progress from './components/Progress.vue';
|
|
4
|
+
export { Upload, UploadList, Progress, };
|
|
5
|
+
export { useUpload } from './composables/useUpload';
|
|
6
|
+
export default Upload;
|