@sl-material/sl-import 1.1.0-beta3 → 1.1.0-beta4

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 CHANGED
@@ -157,18 +157,19 @@ ImportDialog.open({
157
157
  title: "大文件上传",
158
158
  templateType: TemplateTypeEnum.BASE,
159
159
  uploadConfig: {
160
- autoUpload: false,
161
- maxFileSize: 500 * 1024 * 1024, // 500MB
160
+ autoUpload: true, // 选择文件后立即开始上传
161
+ maxFileSize: 500,
162
+ maxFileSizeUnit: "MB",
162
163
  chunkedUpload: {
163
- initUpload: async (params) => {
164
+ initUpload: async (fileName, fileSize) => {
164
165
  const response = await fetch("/api/upload/init", {
165
166
  method: "POST",
166
167
  headers: { "Content-Type": "application/json" },
167
- body: JSON.stringify(params),
168
+ body: JSON.stringify({ fileName, fileSize }),
168
169
  });
169
170
  return response.json();
170
171
  },
171
- getResumableOptions: (initResult) => ({
172
+ getResumableConfig: (initResult) => ({
172
173
  target: "/api/upload/chunk",
173
174
  headers: {
174
175
  Authorization: `Bearer ${token}`,
@@ -296,15 +297,27 @@ ImportDialog.open({
296
297
 
297
298
  所有上传相关配置统一放在 `uploadConfig` 对象中:
298
299
 
299
- | 参数 | 类型 | 默认值 | 说明 |
300
- | ---------------- | ----------------------------------------------- | ----------- | ----------------------- |
301
- | `autoUpload` | `boolean` | `false` | 是否立即上传文件 |
302
- | `multiple` | `boolean` | `false` | 是否支持多文件上传 |
303
- | `maxFiles` | `number` | `10` | 最大文件数量 |
304
- | `maxFileSize` | `number` | `104857600` | 单文件最大大小(100MB) |
305
- | `customUpload` | `(file, context?, onProgress?) => Promise<any>` | - | 自定义上传函数 |
306
- | `chunkedUpload` | `ChunkUploadStrategy` | - | 分片上传策略配置 |
307
- | `confirmLoading` | `boolean` | `true` | 确定按钮 loading 控制 |
300
+ | 参数 | 类型 | 默认值 | 说明 |
301
+ | ----------------- | ----------------------------------------------- | ------- | ---------------------- |
302
+ | `autoUpload` | `boolean` | `false` | 是否立即上传文件 |
303
+ | `multiple` | `boolean` | `false` | 是否支持多文件上传 |
304
+ | `maxFiles` | `number` | `10` | 最大文件数量 |
305
+ | `maxFileSize` | `number` | `100` | 单文件最大大小(数值) |
306
+ | `maxFileSizeUnit` | `'KB' \| 'MB' \| 'GB'` | `'MB'` | 文件大小单位 |
307
+ | `customUpload` | `(file, context?, onProgress?) => Promise<any>` | - | 自定义上传函数 |
308
+ | `chunkedUpload` | `ChunkUploadStrategy` | - | 分片上传策略配置 |
309
+ | `confirmLoading` | `boolean` | `true` | 确定按钮 loading 控制 |
310
+ | `onFileChange` | `(files: FileUploadItem[]) => void` | - | 文件列表变化回调 |
311
+ | `onProgress` | `(file, progress) => void` | - | 上传进度回调 |
312
+ | `onSuccess` | `(file, response) => void` | - | 上传成功回调 |
313
+ | `onError` | `(file, error) => void` | - | 上传失败回调 |
314
+
315
+ **文件大小配置说明**:
316
+
317
+ - `maxFileSize` 和 `maxFileSizeUnit` 组合使用来限制文件大小
318
+ - 例如:`maxFileSize: 10, maxFileSizeUnit: 'KB'` 表示最大 10KB
319
+ - 例如:`maxFileSize: 500, maxFileSizeUnit: 'MB'` 表示最大 500MB
320
+ - 默认为 100MB
308
321
 
309
322
  ##### 分片上传策略 (ChunkUploadStrategy)
310
323
 
package/index.d.ts CHANGED
@@ -60,6 +60,8 @@ export declare enum ExportTypeEnum {
60
60
  excel = "excel"
61
61
  }
62
62
 
63
+ declare type FileSizeUnit = "KB" | "MB" | "GB";
64
+
63
65
  export declare interface FileUploadItem {
64
66
  id: string;
65
67
  file: File;
@@ -89,11 +91,12 @@ export declare type I18nLocale = I18nLocaleEnum;
89
91
  * 支持的语言枚举
90
92
  */
91
93
  export declare enum I18nLocaleEnum {
92
- ZH_CN = "zh-CN",// 中文(简体)
93
- ZH_TW = "zh-TW",// 中文(繁体)
94
- JA = "ja",// 日语
95
- ID = "id",// 印尼语
96
- EN_US = "en-US"
94
+ ZH_CN = "zh_CN",// 简体中文
95
+ EN_US = "en_US",// 英语(美国)
96
+ JA_JP = "ja_JP",// 日语(日本)
97
+ ZH_HK = "zh_HK",// 繁體中文(香港)
98
+ ZH_TW = "zh_TW",// 繁體中文(臺灣)
99
+ ID = "id"
97
100
  }
98
101
 
99
102
  export declare interface ImageRatioOption {
@@ -282,11 +285,23 @@ export declare interface LocaleMessages {
282
285
  startDate: string;
283
286
  endDate: string;
284
287
  to: string;
288
+ pleaseSelectFile: string;
289
+ maxFilesLimit: string;
290
+ fileFormatNotSupported: string;
291
+ fileSizeExceeded: string;
285
292
  fileTypeError: string;
286
293
  fileSizeError: string;
287
294
  uploadFailed: string;
295
+ uploadFailedRetry: string;
288
296
  uploadSuccess: string;
289
297
  uploading: string;
298
+ processingFailed: string;
299
+ fileUploadingCannotDelete: string;
300
+ filesUploadingCannotClear: string;
301
+ filesUploading: string;
302
+ filesUploadFailed: string;
303
+ waitForUploadComplete: string;
304
+ chunkedUploadConfigRequired: string;
290
305
  uploadTitleBase: string;
291
306
  uploadTitleTemplate1: string;
292
307
  uploadTitleTemplate2: string;
@@ -414,6 +429,7 @@ declare namespace types {
414
429
  ImageRatioOption,
415
430
  ImportFormData,
416
431
  FileUploadStatus,
432
+ FileSizeUnit,
417
433
  FileUploadItem,
418
434
  ChunkUploadInitResult,
419
435
  ResumableConfig,
@@ -435,8 +451,10 @@ export declare interface UploadConfig {
435
451
  maxFiles?: number;
436
452
  /** 是否支持多文件上传,默认 false */
437
453
  multiple?: boolean;
438
- /** 单文件最大大小(字节),默认 100MB */
454
+ /** 单文件最大大小,默认 100 */
439
455
  maxFileSize?: number;
456
+ /** 文件大小单位,默认 'MB' */
457
+ maxFileSizeUnit?: FileSizeUnit;
440
458
  /**
441
459
  * 文件预处理函数
442
460
  * 在选择文件后立即调用,用于:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sl-material/sl-import",
3
- "version": "1.1.0-beta3",
3
+ "version": "1.1.0-beta4",
4
4
  "description": "导入组件 - 支持批量导入文件,提供多种模板配置",
5
5
  "main": "./sl-import.cjs.js",
6
6
  "module": "./sl-import.es.js",