@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 +27 -14
- package/index.d.ts +24 -6
- package/package.json +1 -1
- package/sl-import.cjs.js +1 -1
- package/sl-import.es.js +199 -67
- package/sl-import.umd.umd.js +38 -38
package/sl-import.es.js
CHANGED
|
@@ -16,14 +16,15 @@ var ExportTypeEnum = /* @__PURE__ */ ((ExportTypeEnum2) => {
|
|
|
16
16
|
return ExportTypeEnum2;
|
|
17
17
|
})(ExportTypeEnum || {});
|
|
18
18
|
var I18nLocaleEnum = /* @__PURE__ */ ((I18nLocaleEnum2) => {
|
|
19
|
-
I18nLocaleEnum2["ZH_CN"] = "
|
|
20
|
-
I18nLocaleEnum2["
|
|
21
|
-
I18nLocaleEnum2["
|
|
19
|
+
I18nLocaleEnum2["ZH_CN"] = "zh_CN";
|
|
20
|
+
I18nLocaleEnum2["EN_US"] = "en_US";
|
|
21
|
+
I18nLocaleEnum2["JA_JP"] = "ja_JP";
|
|
22
|
+
I18nLocaleEnum2["ZH_HK"] = "zh_HK";
|
|
23
|
+
I18nLocaleEnum2["ZH_TW"] = "zh_TW";
|
|
22
24
|
I18nLocaleEnum2["ID"] = "id";
|
|
23
|
-
I18nLocaleEnum2["EN_US"] = "en-US";
|
|
24
25
|
return I18nLocaleEnum2;
|
|
25
26
|
})(I18nLocaleEnum || {});
|
|
26
|
-
const DEFAULT_LOCALE = "
|
|
27
|
+
const DEFAULT_LOCALE = "zh_CN";
|
|
27
28
|
var __defProp$6 = Object.defineProperty;
|
|
28
29
|
var __defProps$2 = Object.defineProperties;
|
|
29
30
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
@@ -2195,12 +2196,24 @@ const zhCN = {
|
|
|
2195
2196
|
startDate: "开始日期",
|
|
2196
2197
|
endDate: "结束日期",
|
|
2197
2198
|
to: "至",
|
|
2198
|
-
//
|
|
2199
|
+
// 错误信息和提示
|
|
2200
|
+
pleaseSelectFile: "请选择文件",
|
|
2201
|
+
maxFilesLimit: "最多只能上传 {max} 个文件",
|
|
2202
|
+
fileFormatNotSupported: "文件 {name} 格式不支持,仅支持 {types}",
|
|
2203
|
+
fileSizeExceeded: "文件 {name} 超过最大限制 {size}{unit}",
|
|
2199
2204
|
fileTypeError: "请上传文件",
|
|
2200
2205
|
fileSizeError: "文件大小超出限制",
|
|
2201
2206
|
uploadFailed: "上传失败",
|
|
2207
|
+
uploadFailedRetry: "上传失败,请重试",
|
|
2202
2208
|
uploadSuccess: "上传成功",
|
|
2203
2209
|
uploading: "上传中...",
|
|
2210
|
+
processingFailed: "处理失败",
|
|
2211
|
+
fileUploadingCannotDelete: "文件正在上传中,无法删除",
|
|
2212
|
+
filesUploadingCannotClear: "有文件正在上传中,无法清空",
|
|
2213
|
+
filesUploading: "有文件正在上传中,请等待上传完成",
|
|
2214
|
+
filesUploadFailed: "有 {count} 个文件上传失败,请重新上传",
|
|
2215
|
+
waitForUploadComplete: "请等待所有文件上传完成",
|
|
2216
|
+
chunkedUploadConfigRequired: "分片上传需要配置 chunkedUpload",
|
|
2204
2217
|
// 模板配置 - 上传标题
|
|
2205
2218
|
uploadTitleBase: "上传文件",
|
|
2206
2219
|
uploadTitleTemplate1: "上传编辑好的文件",
|
|
@@ -2281,12 +2294,24 @@ const zhTW = {
|
|
|
2281
2294
|
startDate: "開始日期",
|
|
2282
2295
|
endDate: "結束日期",
|
|
2283
2296
|
to: "至",
|
|
2284
|
-
//
|
|
2285
|
-
|
|
2286
|
-
|
|
2297
|
+
// 錯誤信息和提示
|
|
2298
|
+
pleaseSelectFile: "請選擇文件",
|
|
2299
|
+
maxFilesLimit: "最多只能上傳 {max} 個文件",
|
|
2300
|
+
fileFormatNotSupported: "文件 {name} 格式不支持,僅支持 {types}",
|
|
2301
|
+
fileSizeExceeded: "文件 {name} 超過最大限制 {size}{unit}",
|
|
2302
|
+
fileTypeError: "請上傳文件",
|
|
2303
|
+
fileSizeError: "文件大小超出限制",
|
|
2287
2304
|
uploadFailed: "上傳失敗",
|
|
2305
|
+
uploadFailedRetry: "上傳失敗,請重試",
|
|
2288
2306
|
uploadSuccess: "上傳成功",
|
|
2289
2307
|
uploading: "上傳中...",
|
|
2308
|
+
processingFailed: "處理失敗",
|
|
2309
|
+
fileUploadingCannotDelete: "文件正在上傳中,無法刪除",
|
|
2310
|
+
filesUploadingCannotClear: "有文件正在上傳中,無法清空",
|
|
2311
|
+
filesUploading: "有文件正在上傳中,請等待上傳完成",
|
|
2312
|
+
filesUploadFailed: "有 {count} 個文件上傳失敗,請重新上傳",
|
|
2313
|
+
waitForUploadComplete: "請等待所有文件上傳完成",
|
|
2314
|
+
chunkedUploadConfigRequired: "分片上傳需要配置 chunkedUpload",
|
|
2290
2315
|
// 模板配置 - 上傳標題
|
|
2291
2316
|
uploadTitleBase: "上傳檔案",
|
|
2292
2317
|
uploadTitleTemplate1: "上傳編輯好的檔案",
|
|
@@ -2367,12 +2392,24 @@ const ja = {
|
|
|
2367
2392
|
startDate: "開始日",
|
|
2368
2393
|
endDate: "終了日",
|
|
2369
2394
|
to: "から",
|
|
2370
|
-
//
|
|
2395
|
+
// エラー情報と提示
|
|
2396
|
+
pleaseSelectFile: "ファイルを選択してください",
|
|
2397
|
+
maxFilesLimit: "最大 {max} ファイルまでアップロード可能",
|
|
2398
|
+
fileFormatNotSupported: "ファイル {name} の形式はサポートされていません。{types} のみ対応",
|
|
2399
|
+
fileSizeExceeded: "ファイル {name} が最大サイズ {size}{unit} を超えています",
|
|
2371
2400
|
fileTypeError: "ファイルをアップロードしてください",
|
|
2372
2401
|
fileSizeError: "ファイルサイズが制限を超えています",
|
|
2373
2402
|
uploadFailed: "アップロード失敗",
|
|
2403
|
+
uploadFailedRetry: "アップロードに失敗しました。再試行してください",
|
|
2374
2404
|
uploadSuccess: "アップロード成功",
|
|
2375
2405
|
uploading: "アップロード中...",
|
|
2406
|
+
processingFailed: "処理に失敗しました",
|
|
2407
|
+
fileUploadingCannotDelete: "ファイルをアップロード中のため削除できません",
|
|
2408
|
+
filesUploadingCannotClear: "ファイルをアップロード中のためクリアできません",
|
|
2409
|
+
filesUploading: "ファイルをアップロード中です。完了までお待ちください",
|
|
2410
|
+
filesUploadFailed: "{count} 個のファイルのアップロードに失敗しました。再アップロードしてください",
|
|
2411
|
+
waitForUploadComplete: "すべてのファイルのアップロードが完了するまでお待ちください",
|
|
2412
|
+
chunkedUploadConfigRequired: "チャンクアップロードには chunkedUpload の設定が必要です",
|
|
2376
2413
|
// テンプレート設定 - アップロードタイトル
|
|
2377
2414
|
uploadTitleBase: "ファイルをアップロード",
|
|
2378
2415
|
uploadTitleTemplate1: "編集済みファイルをアップロード",
|
|
@@ -2453,12 +2490,24 @@ const id = {
|
|
|
2453
2490
|
startDate: "Tanggal mulai",
|
|
2454
2491
|
endDate: "Tanggal akhir",
|
|
2455
2492
|
to: "hingga",
|
|
2456
|
-
// Informasi
|
|
2493
|
+
// Informasi kesalahan dan petunjuk
|
|
2494
|
+
pleaseSelectFile: "Silakan pilih file",
|
|
2495
|
+
maxFilesLimit: "Maksimal {max} file yang diizinkan",
|
|
2496
|
+
fileFormatNotSupported: "Format file {name} tidak didukung, hanya {types} yang diizinkan",
|
|
2497
|
+
fileSizeExceeded: "File {name} melebihi ukuran maksimal {size}{unit}",
|
|
2457
2498
|
fileTypeError: "Silakan unggah file",
|
|
2458
2499
|
fileSizeError: "Ukuran file melebihi batas",
|
|
2459
2500
|
uploadFailed: "Unggah gagal",
|
|
2501
|
+
uploadFailedRetry: "Unggah gagal, silakan coba lagi",
|
|
2460
2502
|
uploadSuccess: "Unggah berhasil",
|
|
2461
2503
|
uploading: "Mengunggah...",
|
|
2504
|
+
processingFailed: "Pemrosesan gagal",
|
|
2505
|
+
fileUploadingCannotDelete: "File sedang diunggah, tidak dapat dihapus",
|
|
2506
|
+
filesUploadingCannotClear: "File sedang diunggah, tidak dapat dikosongkan",
|
|
2507
|
+
filesUploading: "File sedang diunggah, harap tunggu hingga selesai",
|
|
2508
|
+
filesUploadFailed: "{count} file gagal diunggah, silakan unggah ulang",
|
|
2509
|
+
waitForUploadComplete: "Harap tunggu semua file selesai diunggah",
|
|
2510
|
+
chunkedUploadConfigRequired: "Unggah chunk memerlukan konfigurasi chunkedUpload",
|
|
2462
2511
|
// Konfigurasi template - Judul unggah
|
|
2463
2512
|
uploadTitleBase: "Unggah File",
|
|
2464
2513
|
uploadTitleTemplate1: "Unggah File yang Diedit",
|
|
@@ -2539,12 +2588,24 @@ const enUS = {
|
|
|
2539
2588
|
startDate: "Start date",
|
|
2540
2589
|
endDate: "End date",
|
|
2541
2590
|
to: "to",
|
|
2542
|
-
//
|
|
2591
|
+
// 错误信息和提示
|
|
2592
|
+
pleaseSelectFile: "Please select a file",
|
|
2593
|
+
maxFilesLimit: "Maximum {max} files allowed",
|
|
2594
|
+
fileFormatNotSupported: "File {name} format not supported, only {types} allowed",
|
|
2595
|
+
fileSizeExceeded: "File {name} exceeds maximum size {size}{unit}",
|
|
2543
2596
|
fileTypeError: "Please upload file",
|
|
2544
2597
|
fileSizeError: "File size exceeds limit",
|
|
2545
2598
|
uploadFailed: "Upload failed",
|
|
2599
|
+
uploadFailedRetry: "Upload failed, please retry",
|
|
2546
2600
|
uploadSuccess: "Upload successful",
|
|
2547
2601
|
uploading: "Uploading...",
|
|
2602
|
+
processingFailed: "Processing failed",
|
|
2603
|
+
fileUploadingCannotDelete: "File is uploading, cannot delete",
|
|
2604
|
+
filesUploadingCannotClear: "Files are uploading, cannot clear",
|
|
2605
|
+
filesUploading: "Files are uploading, please wait for completion",
|
|
2606
|
+
filesUploadFailed: "{count} file(s) failed to upload, please re-upload",
|
|
2607
|
+
waitForUploadComplete: "Please wait for all files to complete uploading",
|
|
2608
|
+
chunkedUploadConfigRequired: "Chunked upload requires chunkedUpload configuration",
|
|
2548
2609
|
// 模板配置 - 上传标题
|
|
2549
2610
|
uploadTitleBase: "Upload File",
|
|
2550
2611
|
uploadTitleTemplate1: "Upload Edited File",
|
|
@@ -2596,11 +2657,13 @@ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key,
|
|
|
2596
2657
|
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2597
2658
|
const defaultLocale = DEFAULT_LOCALE;
|
|
2598
2659
|
const locales = {
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
ja,
|
|
2602
|
-
|
|
2603
|
-
|
|
2660
|
+
zh_CN: zhCN,
|
|
2661
|
+
en_US: enUS,
|
|
2662
|
+
ja_JP: ja,
|
|
2663
|
+
zh_HK: zhTW,
|
|
2664
|
+
// 暂时使用繁体中文(台湾)的翻译
|
|
2665
|
+
zh_TW: zhTW,
|
|
2666
|
+
id
|
|
2604
2667
|
};
|
|
2605
2668
|
class I18n {
|
|
2606
2669
|
constructor() {
|
|
@@ -3042,20 +3105,22 @@ var __async$2 = (__this, __arguments, generator) => {
|
|
|
3042
3105
|
});
|
|
3043
3106
|
};
|
|
3044
3107
|
class ChunkedUploader {
|
|
3045
|
-
constructor(chunkedConfig, callbacks = {}
|
|
3108
|
+
constructor(chunkedConfig, callbacks = {}) {
|
|
3046
3109
|
__publicField$2(this, "resumable");
|
|
3047
3110
|
__publicField$2(this, "currentFileItem", null);
|
|
3048
3111
|
__publicField$2(this, "chunkedConfig");
|
|
3049
3112
|
__publicField$2(this, "callbacks");
|
|
3050
|
-
__publicField$2(this, "autoUpload");
|
|
3051
3113
|
__publicField$2(this, "uploadCompleteResolve");
|
|
3052
3114
|
__publicField$2(this, "uploadCompleteReject");
|
|
3053
3115
|
this.chunkedConfig = chunkedConfig;
|
|
3054
3116
|
this.callbacks = callbacks;
|
|
3055
|
-
this.autoUpload = autoUpload;
|
|
3056
3117
|
}
|
|
3057
3118
|
/**
|
|
3058
3119
|
* 上传单个文件(分片方式)
|
|
3120
|
+
* 完整流程:初始化 → 分片上传 → 合并 → 返回结果
|
|
3121
|
+
*
|
|
3122
|
+
* @param fileItem 文件项
|
|
3123
|
+
* @returns 合并后的结果
|
|
3059
3124
|
*/
|
|
3060
3125
|
upload(fileItem) {
|
|
3061
3126
|
return __async$2(this, null, function* () {
|
|
@@ -3068,14 +3133,7 @@ class ChunkedUploader {
|
|
|
3068
3133
|
this.currentFileItem = fileItem;
|
|
3069
3134
|
this.initResumable(initResult);
|
|
3070
3135
|
this.resumable.addFile(fileItem.file);
|
|
3071
|
-
|
|
3072
|
-
return yield this.waitForUploadComplete();
|
|
3073
|
-
} else {
|
|
3074
|
-
return {
|
|
3075
|
-
uploadSessionId: initResult.uploadSessionId,
|
|
3076
|
-
initialized: true
|
|
3077
|
-
};
|
|
3078
|
-
}
|
|
3136
|
+
return yield this.waitForUploadComplete();
|
|
3079
3137
|
} catch (error) {
|
|
3080
3138
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3081
3139
|
throw err;
|
|
@@ -3084,6 +3142,7 @@ class ChunkedUploader {
|
|
|
3084
3142
|
}
|
|
3085
3143
|
/**
|
|
3086
3144
|
* 等待上传完成
|
|
3145
|
+
* 返回一个 Promise,在 fileSuccess 事件触发并完成合并后 resolve
|
|
3087
3146
|
*/
|
|
3088
3147
|
waitForUploadComplete() {
|
|
3089
3148
|
return new Promise((resolve, reject) => {
|
|
@@ -3092,7 +3151,7 @@ class ChunkedUploader {
|
|
|
3092
3151
|
});
|
|
3093
3152
|
}
|
|
3094
3153
|
/**
|
|
3095
|
-
* 初始化Resumable实例
|
|
3154
|
+
* 初始化 Resumable 实例
|
|
3096
3155
|
*/
|
|
3097
3156
|
initResumable(initResult) {
|
|
3098
3157
|
if (this.resumable) {
|
|
@@ -3117,7 +3176,7 @@ class ChunkedUploader {
|
|
|
3117
3176
|
this.bindResumableEvents();
|
|
3118
3177
|
}
|
|
3119
3178
|
/**
|
|
3120
|
-
* 绑定Resumable事件监听器
|
|
3179
|
+
* 绑定 Resumable 事件监听器
|
|
3121
3180
|
*/
|
|
3122
3181
|
bindResumableEvents() {
|
|
3123
3182
|
this.resumable.on("progress", () => {
|
|
@@ -3140,9 +3199,7 @@ class ChunkedUploader {
|
|
|
3140
3199
|
this.handleResumableError(message);
|
|
3141
3200
|
});
|
|
3142
3201
|
this.resumable.on("fileAdded", () => {
|
|
3143
|
-
|
|
3144
|
-
this.resumable.upload();
|
|
3145
|
-
}
|
|
3202
|
+
this.resumable.upload();
|
|
3146
3203
|
});
|
|
3147
3204
|
}
|
|
3148
3205
|
/**
|
|
@@ -3279,22 +3336,17 @@ class ImportDialogUploader {
|
|
|
3279
3336
|
initUploaders() {
|
|
3280
3337
|
const uploadConfig = this.config.uploadConfig;
|
|
3281
3338
|
if ((uploadConfig == null ? void 0 : uploadConfig.chunkedUpload) && !this.config.multiple) {
|
|
3282
|
-
this.chunkedUploader = new ChunkedUploader(
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
(_b = (_a = this.callbacks).onUploadProgress) == null ? void 0 : _b.call(_a, fileItem, progress);
|
|
3288
|
-
(_d = (_c = this.callbacks).onUpdate) == null ? void 0 : _d.call(_c);
|
|
3289
|
-
},
|
|
3290
|
-
onUpdate: () => {
|
|
3291
|
-
var _a, _b;
|
|
3292
|
-
(_b = (_a = this.callbacks).onUpdate) == null ? void 0 : _b.call(_a);
|
|
3293
|
-
}
|
|
3339
|
+
this.chunkedUploader = new ChunkedUploader(uploadConfig.chunkedUpload, {
|
|
3340
|
+
onProgress: (fileItem, progress) => {
|
|
3341
|
+
var _a, _b, _c, _d;
|
|
3342
|
+
(_b = (_a = this.callbacks).onUploadProgress) == null ? void 0 : _b.call(_a, fileItem, progress);
|
|
3343
|
+
(_d = (_c = this.callbacks).onUpdate) == null ? void 0 : _d.call(_c);
|
|
3294
3344
|
},
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3345
|
+
onUpdate: () => {
|
|
3346
|
+
var _a, _b;
|
|
3347
|
+
(_b = (_a = this.callbacks).onUpdate) == null ? void 0 : _b.call(_a);
|
|
3348
|
+
}
|
|
3349
|
+
});
|
|
3298
3350
|
}
|
|
3299
3351
|
}
|
|
3300
3352
|
/**
|
|
@@ -3321,14 +3373,63 @@ class ImportDialogUploader {
|
|
|
3321
3373
|
this.uploadMessage = "";
|
|
3322
3374
|
this.uploadMessageType = "info";
|
|
3323
3375
|
}
|
|
3376
|
+
/**
|
|
3377
|
+
* 将文件大小转换为字节
|
|
3378
|
+
* @param size 大小数值
|
|
3379
|
+
* @param unit 单位
|
|
3380
|
+
* @returns 字节数
|
|
3381
|
+
*/
|
|
3382
|
+
convertToBytes(size, unit = "MB") {
|
|
3383
|
+
const units = {
|
|
3384
|
+
KB: 1024,
|
|
3385
|
+
MB: 1024 * 1024,
|
|
3386
|
+
GB: 1024 * 1024 * 1024
|
|
3387
|
+
};
|
|
3388
|
+
return size * units[unit];
|
|
3389
|
+
}
|
|
3390
|
+
/**
|
|
3391
|
+
* 格式化文件大小显示
|
|
3392
|
+
* @param bytes 字节数
|
|
3393
|
+
* @param unit 目标单位
|
|
3394
|
+
* @returns 格式化后的大小字符串
|
|
3395
|
+
*/
|
|
3396
|
+
formatFileSize(bytes, unit = "MB") {
|
|
3397
|
+
const size = bytes / this.convertToBytes(1, unit);
|
|
3398
|
+
return `${size.toFixed(2)}${unit}`;
|
|
3399
|
+
}
|
|
3400
|
+
/**
|
|
3401
|
+
* 检查文件格式是否符合要求
|
|
3402
|
+
* @param file 文件
|
|
3403
|
+
* @param acceptTypes 接受的文件类型,如 ".xls,.xlsx,.csv"
|
|
3404
|
+
* @returns 是否符合要求
|
|
3405
|
+
*/
|
|
3406
|
+
isValidFileType(file, acceptTypes) {
|
|
3407
|
+
if (!acceptTypes) return true;
|
|
3408
|
+
const fileName = file.name.toLowerCase();
|
|
3409
|
+
const fileExt = fileName.substring(fileName.lastIndexOf("."));
|
|
3410
|
+
const acceptList = acceptTypes.toLowerCase().split(",").map((ext) => ext.trim());
|
|
3411
|
+
return acceptList.some((accept) => {
|
|
3412
|
+
if (accept.startsWith(".")) {
|
|
3413
|
+
return fileExt === accept;
|
|
3414
|
+
}
|
|
3415
|
+
if (accept.includes("/")) {
|
|
3416
|
+
const [type, subtype] = accept.split("/");
|
|
3417
|
+
if (subtype === "*") {
|
|
3418
|
+
return file.type.startsWith(type + "/");
|
|
3419
|
+
}
|
|
3420
|
+
return file.type === accept;
|
|
3421
|
+
}
|
|
3422
|
+
return false;
|
|
3423
|
+
});
|
|
3424
|
+
}
|
|
3324
3425
|
/**
|
|
3325
3426
|
* 文件上传之前的校验 选择文件时调用
|
|
3326
3427
|
*/
|
|
3327
3428
|
beforeUpload(files) {
|
|
3328
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3429
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
3329
3430
|
const fileArray = Array.isArray(files) ? files : [files];
|
|
3330
3431
|
if (!fileArray.length) {
|
|
3331
|
-
(_b = (_a = this.callbacks).onMessage) == null ? void 0 : _b.call(_a, "
|
|
3432
|
+
(_b = (_a = this.callbacks).onMessage) == null ? void 0 : _b.call(_a, t("pleaseSelectFile"), "warning");
|
|
3332
3433
|
return false;
|
|
3333
3434
|
}
|
|
3334
3435
|
if (this.config.multiple) {
|
|
@@ -3336,17 +3437,37 @@ class ImportDialogUploader {
|
|
|
3336
3437
|
if (totalFiles > this.config.maxFiles) {
|
|
3337
3438
|
(_d = (_c = this.callbacks).onMessage) == null ? void 0 : _d.call(
|
|
3338
3439
|
_c,
|
|
3339
|
-
|
|
3440
|
+
t("maxFilesLimit", { max: this.config.maxFiles }),
|
|
3340
3441
|
"warning"
|
|
3341
3442
|
);
|
|
3342
3443
|
return false;
|
|
3343
3444
|
}
|
|
3344
3445
|
}
|
|
3345
3446
|
for (const file of fileArray) {
|
|
3346
|
-
if (file
|
|
3447
|
+
if (!this.isValidFileType(file, this.config.acceptTypes)) {
|
|
3448
|
+
const acceptTypes = this.config.acceptTypes || "";
|
|
3347
3449
|
(_f = (_e = this.callbacks).onMessage) == null ? void 0 : _f.call(
|
|
3348
3450
|
_e,
|
|
3349
|
-
|
|
3451
|
+
t("fileFormatNotSupported", { name: file.name, types: acceptTypes }),
|
|
3452
|
+
"warning"
|
|
3453
|
+
);
|
|
3454
|
+
return false;
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
const maxFileSizeUnit = this.config.maxFileSizeUnit || "MB";
|
|
3458
|
+
const maxFileSizeBytes = this.convertToBytes(
|
|
3459
|
+
this.config.maxFileSize,
|
|
3460
|
+
maxFileSizeUnit
|
|
3461
|
+
);
|
|
3462
|
+
for (const file of fileArray) {
|
|
3463
|
+
if (file.size > maxFileSizeBytes) {
|
|
3464
|
+
(_h = (_g = this.callbacks).onMessage) == null ? void 0 : _h.call(
|
|
3465
|
+
_g,
|
|
3466
|
+
t("fileSizeExceeded", {
|
|
3467
|
+
name: file.name,
|
|
3468
|
+
size: this.config.maxFileSize,
|
|
3469
|
+
unit: maxFileSizeUnit
|
|
3470
|
+
}),
|
|
3350
3471
|
"warning"
|
|
3351
3472
|
);
|
|
3352
3473
|
return false;
|
|
@@ -3369,8 +3490,8 @@ class ImportDialogUploader {
|
|
|
3369
3490
|
this.fileList = [file];
|
|
3370
3491
|
}
|
|
3371
3492
|
}
|
|
3372
|
-
(
|
|
3373
|
-
(
|
|
3493
|
+
(_j = (_i = this.callbacks).onUpdate) == null ? void 0 : _j.call(_i);
|
|
3494
|
+
(_l = (_k = this.callbacks).onFileChange) == null ? void 0 : _l.call(_k, this.uploadFileList);
|
|
3374
3495
|
if (this.shouldUseChunkedUpload()) {
|
|
3375
3496
|
this.processChunkedUpload();
|
|
3376
3497
|
} else {
|
|
@@ -3380,7 +3501,9 @@ class ImportDialogUploader {
|
|
|
3380
3501
|
}
|
|
3381
3502
|
/**
|
|
3382
3503
|
* 处理分片上传
|
|
3383
|
-
*
|
|
3504
|
+
* 根据 autoUpload 配置决定是否立即上传
|
|
3505
|
+
* - autoUpload: true → 立即开始上传
|
|
3506
|
+
* - autoUpload: false/undefined → 等待用户点击确认后上传
|
|
3384
3507
|
*/
|
|
3385
3508
|
processChunkedUpload() {
|
|
3386
3509
|
return __async$1(this, null, function* () {
|
|
@@ -3450,7 +3573,7 @@ class ImportDialogUploader {
|
|
|
3450
3573
|
(_e = (_d = this.callbacks).onUploadSuccess) == null ? void 0 : _e.call(_d, fileItem, fileItem.response);
|
|
3451
3574
|
} catch (error) {
|
|
3452
3575
|
fileItem.status = "error";
|
|
3453
|
-
fileItem.errorMessage = error instanceof Error ? error.message : "
|
|
3576
|
+
fileItem.errorMessage = error instanceof Error ? error.message : t("processingFailed");
|
|
3454
3577
|
(_g = (_f = this.callbacks).onUploadError) == null ? void 0 : _g.call(_f, fileItem, error);
|
|
3455
3578
|
}
|
|
3456
3579
|
this.isUploading = this.uploadFileList.some(
|
|
@@ -3474,7 +3597,7 @@ class ImportDialogUploader {
|
|
|
3474
3597
|
if (index !== void 0 && index >= 0 && index < this.uploadFileList.length) {
|
|
3475
3598
|
const fileItem = this.uploadFileList[index];
|
|
3476
3599
|
if (needCheckStatus && fileItem.status === "uploading") {
|
|
3477
|
-
(_c = (_b = this.callbacks).onMessage) == null ? void 0 : _c.call(_b, "
|
|
3600
|
+
(_c = (_b = this.callbacks).onMessage) == null ? void 0 : _c.call(_b, t("fileUploadingCannotDelete"), "warning");
|
|
3478
3601
|
return false;
|
|
3479
3602
|
}
|
|
3480
3603
|
this.uploadFileList.splice(index, 1);
|
|
@@ -3485,7 +3608,7 @@ class ImportDialogUploader {
|
|
|
3485
3608
|
(f) => f.status === "uploading"
|
|
3486
3609
|
);
|
|
3487
3610
|
if (hasUploading) {
|
|
3488
|
-
(_e = (_d = this.callbacks).onMessage) == null ? void 0 : _e.call(_d, "
|
|
3611
|
+
(_e = (_d = this.callbacks).onMessage) == null ? void 0 : _e.call(_d, t("filesUploadingCannotClear"), "warning");
|
|
3489
3612
|
return false;
|
|
3490
3613
|
}
|
|
3491
3614
|
}
|
|
@@ -3508,7 +3631,7 @@ class ImportDialogUploader {
|
|
|
3508
3631
|
*/
|
|
3509
3632
|
uploadSingleFile(fileItem) {
|
|
3510
3633
|
return __async$1(this, null, function* () {
|
|
3511
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3634
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3512
3635
|
fileItem.status = "uploading";
|
|
3513
3636
|
fileItem.progress = 0;
|
|
3514
3637
|
this.isUploading = true;
|
|
@@ -3521,9 +3644,15 @@ class ImportDialogUploader {
|
|
|
3521
3644
|
return fileItem.response;
|
|
3522
3645
|
} catch (error) {
|
|
3523
3646
|
fileItem.status = "error";
|
|
3524
|
-
fileItem.errorMessage = error instanceof Error ? error.message : "
|
|
3647
|
+
fileItem.errorMessage = error instanceof Error ? error.message : t("uploadFailed");
|
|
3525
3648
|
(_f = (_e = this.callbacks).onUploadError) == null ? void 0 : _f.call(_e, fileItem, error);
|
|
3526
3649
|
throw error;
|
|
3650
|
+
} finally {
|
|
3651
|
+
this.isUploading = this.uploadFileList.some(
|
|
3652
|
+
(f) => f.status === "uploading"
|
|
3653
|
+
);
|
|
3654
|
+
(_h = (_g = this.callbacks).onUpdate) == null ? void 0 : _h.call(_g);
|
|
3655
|
+
this.updateOverallProgress();
|
|
3527
3656
|
}
|
|
3528
3657
|
});
|
|
3529
3658
|
}
|
|
@@ -3533,7 +3662,7 @@ class ImportDialogUploader {
|
|
|
3533
3662
|
uploadFileChunked(fileItem) {
|
|
3534
3663
|
return __async$1(this, null, function* () {
|
|
3535
3664
|
if (!this.chunkedUploader) {
|
|
3536
|
-
throw new Error("
|
|
3665
|
+
throw new Error(t("chunkedUploadConfigRequired"));
|
|
3537
3666
|
}
|
|
3538
3667
|
return yield this.chunkedUploader.upload(fileItem);
|
|
3539
3668
|
});
|
|
@@ -3771,7 +3900,8 @@ const _ImportDialog = class _ImportDialog2 {
|
|
|
3771
3900
|
{
|
|
3772
3901
|
multiple: false,
|
|
3773
3902
|
maxFiles: 10,
|
|
3774
|
-
maxFileSize: 100
|
|
3903
|
+
maxFileSize: 100,
|
|
3904
|
+
maxFileSizeUnit: "MB"
|
|
3775
3905
|
},
|
|
3776
3906
|
{
|
|
3777
3907
|
onUpdate: () => this.updateModal(),
|
|
@@ -4173,7 +4303,7 @@ const _ImportDialog = class _ImportDialog2 {
|
|
|
4173
4303
|
return;
|
|
4174
4304
|
}
|
|
4175
4305
|
if (this.uploader.hasUploadingFiles()) {
|
|
4176
|
-
this.showMessage("
|
|
4306
|
+
this.showMessage(t("filesUploading"), "warning");
|
|
4177
4307
|
return;
|
|
4178
4308
|
}
|
|
4179
4309
|
if (this.uploader.hasPendingFiles()) {
|
|
@@ -4185,7 +4315,7 @@ const _ImportDialog = class _ImportDialog2 {
|
|
|
4185
4315
|
try {
|
|
4186
4316
|
const chunkResult = yield this.uploader.startUpload();
|
|
4187
4317
|
} catch (error) {
|
|
4188
|
-
this.showMessage("
|
|
4318
|
+
this.showMessage(t("uploadFailedRetry"), "error");
|
|
4189
4319
|
if (confirmLoadingEnabled2) {
|
|
4190
4320
|
this.confirmLoading = false;
|
|
4191
4321
|
this.updateModal();
|
|
@@ -4196,7 +4326,7 @@ const _ImportDialog = class _ImportDialog2 {
|
|
|
4196
4326
|
const failedFiles = this.uploader.getFailedFiles();
|
|
4197
4327
|
if (failedFiles.length > 0) {
|
|
4198
4328
|
this.showMessage(
|
|
4199
|
-
|
|
4329
|
+
t("filesUploadFailed", { count: failedFiles.length }),
|
|
4200
4330
|
"warning"
|
|
4201
4331
|
);
|
|
4202
4332
|
const confirmLoadingEnabled2 = ((_b = this.modalOptions.uploadConfig) == null ? void 0 : _b.confirmLoading) != null ? this.modalOptions.uploadConfig.confirmLoading : true;
|
|
@@ -4265,7 +4395,9 @@ const _ImportDialog = class _ImportDialog2 {
|
|
|
4265
4395
|
this.uploader.updateConfig({
|
|
4266
4396
|
multiple: (uploadConfig == null ? void 0 : uploadConfig.multiple) != null ? uploadConfig.multiple : false,
|
|
4267
4397
|
maxFiles: (uploadConfig == null ? void 0 : uploadConfig.maxFiles) != null ? uploadConfig.maxFiles : 10,
|
|
4268
|
-
maxFileSize: (uploadConfig == null ? void 0 : uploadConfig.maxFileSize) != null ? uploadConfig.maxFileSize : 100
|
|
4398
|
+
maxFileSize: (uploadConfig == null ? void 0 : uploadConfig.maxFileSize) != null ? uploadConfig.maxFileSize : 100,
|
|
4399
|
+
maxFileSizeUnit: (uploadConfig == null ? void 0 : uploadConfig.maxFileSizeUnit) != null ? uploadConfig.maxFileSizeUnit : "MB",
|
|
4400
|
+
acceptTypes: this.currentConfig.acceptTypes,
|
|
4269
4401
|
uploadConfig
|
|
4270
4402
|
});
|
|
4271
4403
|
this.activeTabIndex = (options == null ? void 0 : options.defaultActiveTab) || 0;
|