@sl-material/sl-import 1.1.0-beta2 → 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 +196 -47
- 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() {
|
|
@@ -3054,6 +3117,10 @@ class ChunkedUploader {
|
|
|
3054
3117
|
}
|
|
3055
3118
|
/**
|
|
3056
3119
|
* 上传单个文件(分片方式)
|
|
3120
|
+
* 完整流程:初始化 → 分片上传 → 合并 → 返回结果
|
|
3121
|
+
*
|
|
3122
|
+
* @param fileItem 文件项
|
|
3123
|
+
* @returns 合并后的结果
|
|
3057
3124
|
*/
|
|
3058
3125
|
upload(fileItem) {
|
|
3059
3126
|
return __async$2(this, null, function* () {
|
|
@@ -3075,6 +3142,7 @@ class ChunkedUploader {
|
|
|
3075
3142
|
}
|
|
3076
3143
|
/**
|
|
3077
3144
|
* 等待上传完成
|
|
3145
|
+
* 返回一个 Promise,在 fileSuccess 事件触发并完成合并后 resolve
|
|
3078
3146
|
*/
|
|
3079
3147
|
waitForUploadComplete() {
|
|
3080
3148
|
return new Promise((resolve, reject) => {
|
|
@@ -3083,7 +3151,7 @@ class ChunkedUploader {
|
|
|
3083
3151
|
});
|
|
3084
3152
|
}
|
|
3085
3153
|
/**
|
|
3086
|
-
* 初始化Resumable实例
|
|
3154
|
+
* 初始化 Resumable 实例
|
|
3087
3155
|
*/
|
|
3088
3156
|
initResumable(initResult) {
|
|
3089
3157
|
if (this.resumable) {
|
|
@@ -3108,7 +3176,7 @@ class ChunkedUploader {
|
|
|
3108
3176
|
this.bindResumableEvents();
|
|
3109
3177
|
}
|
|
3110
3178
|
/**
|
|
3111
|
-
* 绑定Resumable事件监听器
|
|
3179
|
+
* 绑定 Resumable 事件监听器
|
|
3112
3180
|
*/
|
|
3113
3181
|
bindResumableEvents() {
|
|
3114
3182
|
this.resumable.on("progress", () => {
|
|
@@ -3276,7 +3344,7 @@ class ImportDialogUploader {
|
|
|
3276
3344
|
},
|
|
3277
3345
|
onUpdate: () => {
|
|
3278
3346
|
var _a, _b;
|
|
3279
|
-
|
|
3347
|
+
(_b = (_a = this.callbacks).onUpdate) == null ? void 0 : _b.call(_a);
|
|
3280
3348
|
}
|
|
3281
3349
|
});
|
|
3282
3350
|
}
|
|
@@ -3305,14 +3373,63 @@ class ImportDialogUploader {
|
|
|
3305
3373
|
this.uploadMessage = "";
|
|
3306
3374
|
this.uploadMessageType = "info";
|
|
3307
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
|
+
}
|
|
3308
3425
|
/**
|
|
3309
3426
|
* 文件上传之前的校验 选择文件时调用
|
|
3310
3427
|
*/
|
|
3311
3428
|
beforeUpload(files) {
|
|
3312
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3429
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
3313
3430
|
const fileArray = Array.isArray(files) ? files : [files];
|
|
3314
3431
|
if (!fileArray.length) {
|
|
3315
|
-
(_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");
|
|
3316
3433
|
return false;
|
|
3317
3434
|
}
|
|
3318
3435
|
if (this.config.multiple) {
|
|
@@ -3320,17 +3437,37 @@ class ImportDialogUploader {
|
|
|
3320
3437
|
if (totalFiles > this.config.maxFiles) {
|
|
3321
3438
|
(_d = (_c = this.callbacks).onMessage) == null ? void 0 : _d.call(
|
|
3322
3439
|
_c,
|
|
3323
|
-
|
|
3440
|
+
t("maxFilesLimit", { max: this.config.maxFiles }),
|
|
3324
3441
|
"warning"
|
|
3325
3442
|
);
|
|
3326
3443
|
return false;
|
|
3327
3444
|
}
|
|
3328
3445
|
}
|
|
3329
3446
|
for (const file of fileArray) {
|
|
3330
|
-
if (file
|
|
3447
|
+
if (!this.isValidFileType(file, this.config.acceptTypes)) {
|
|
3448
|
+
const acceptTypes = this.config.acceptTypes || "";
|
|
3331
3449
|
(_f = (_e = this.callbacks).onMessage) == null ? void 0 : _f.call(
|
|
3332
3450
|
_e,
|
|
3333
|
-
|
|
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
|
+
}),
|
|
3334
3471
|
"warning"
|
|
3335
3472
|
);
|
|
3336
3473
|
return false;
|
|
@@ -3353,12 +3490,10 @@ class ImportDialogUploader {
|
|
|
3353
3490
|
this.fileList = [file];
|
|
3354
3491
|
}
|
|
3355
3492
|
}
|
|
3356
|
-
(
|
|
3357
|
-
(
|
|
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);
|
|
3358
3495
|
if (this.shouldUseChunkedUpload()) {
|
|
3359
|
-
|
|
3360
|
-
this.processChunkedUpload();
|
|
3361
|
-
}
|
|
3496
|
+
this.processChunkedUpload();
|
|
3362
3497
|
} else {
|
|
3363
3498
|
this.processFilesWithCustomUpload();
|
|
3364
3499
|
}
|
|
@@ -3366,15 +3501,20 @@ class ImportDialogUploader {
|
|
|
3366
3501
|
}
|
|
3367
3502
|
/**
|
|
3368
3503
|
* 处理分片上传
|
|
3369
|
-
*
|
|
3504
|
+
* 根据 autoUpload 配置决定是否立即上传
|
|
3505
|
+
* - autoUpload: true → 立即开始上传
|
|
3506
|
+
* - autoUpload: false/undefined → 等待用户点击确认后上传
|
|
3370
3507
|
*/
|
|
3371
3508
|
processChunkedUpload() {
|
|
3372
3509
|
return __async$1(this, null, function* () {
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3510
|
+
var _a;
|
|
3511
|
+
if (((_a = this.config.uploadConfig) == null ? void 0 : _a.autoUpload) === true) {
|
|
3512
|
+
const pendingFiles = this.uploadFileList.filter(
|
|
3513
|
+
(f) => f.status === "pending"
|
|
3514
|
+
);
|
|
3515
|
+
for (const fileItem of pendingFiles) {
|
|
3516
|
+
yield this.uploadSingleFile(fileItem);
|
|
3517
|
+
}
|
|
3378
3518
|
}
|
|
3379
3519
|
});
|
|
3380
3520
|
}
|
|
@@ -3433,7 +3573,7 @@ class ImportDialogUploader {
|
|
|
3433
3573
|
(_e = (_d = this.callbacks).onUploadSuccess) == null ? void 0 : _e.call(_d, fileItem, fileItem.response);
|
|
3434
3574
|
} catch (error) {
|
|
3435
3575
|
fileItem.status = "error";
|
|
3436
|
-
fileItem.errorMessage = error instanceof Error ? error.message : "
|
|
3576
|
+
fileItem.errorMessage = error instanceof Error ? error.message : t("processingFailed");
|
|
3437
3577
|
(_g = (_f = this.callbacks).onUploadError) == null ? void 0 : _g.call(_f, fileItem, error);
|
|
3438
3578
|
}
|
|
3439
3579
|
this.isUploading = this.uploadFileList.some(
|
|
@@ -3457,7 +3597,7 @@ class ImportDialogUploader {
|
|
|
3457
3597
|
if (index !== void 0 && index >= 0 && index < this.uploadFileList.length) {
|
|
3458
3598
|
const fileItem = this.uploadFileList[index];
|
|
3459
3599
|
if (needCheckStatus && fileItem.status === "uploading") {
|
|
3460
|
-
(_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");
|
|
3461
3601
|
return false;
|
|
3462
3602
|
}
|
|
3463
3603
|
this.uploadFileList.splice(index, 1);
|
|
@@ -3468,7 +3608,7 @@ class ImportDialogUploader {
|
|
|
3468
3608
|
(f) => f.status === "uploading"
|
|
3469
3609
|
);
|
|
3470
3610
|
if (hasUploading) {
|
|
3471
|
-
(_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");
|
|
3472
3612
|
return false;
|
|
3473
3613
|
}
|
|
3474
3614
|
}
|
|
@@ -3491,7 +3631,7 @@ class ImportDialogUploader {
|
|
|
3491
3631
|
*/
|
|
3492
3632
|
uploadSingleFile(fileItem) {
|
|
3493
3633
|
return __async$1(this, null, function* () {
|
|
3494
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3634
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3495
3635
|
fileItem.status = "uploading";
|
|
3496
3636
|
fileItem.progress = 0;
|
|
3497
3637
|
this.isUploading = true;
|
|
@@ -3504,9 +3644,15 @@ class ImportDialogUploader {
|
|
|
3504
3644
|
return fileItem.response;
|
|
3505
3645
|
} catch (error) {
|
|
3506
3646
|
fileItem.status = "error";
|
|
3507
|
-
fileItem.errorMessage = error instanceof Error ? error.message : "
|
|
3647
|
+
fileItem.errorMessage = error instanceof Error ? error.message : t("uploadFailed");
|
|
3508
3648
|
(_f = (_e = this.callbacks).onUploadError) == null ? void 0 : _f.call(_e, fileItem, error);
|
|
3509
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();
|
|
3510
3656
|
}
|
|
3511
3657
|
});
|
|
3512
3658
|
}
|
|
@@ -3516,7 +3662,7 @@ class ImportDialogUploader {
|
|
|
3516
3662
|
uploadFileChunked(fileItem) {
|
|
3517
3663
|
return __async$1(this, null, function* () {
|
|
3518
3664
|
if (!this.chunkedUploader) {
|
|
3519
|
-
throw new Error("
|
|
3665
|
+
throw new Error(t("chunkedUploadConfigRequired"));
|
|
3520
3666
|
}
|
|
3521
3667
|
return yield this.chunkedUploader.upload(fileItem);
|
|
3522
3668
|
});
|
|
@@ -3754,7 +3900,8 @@ const _ImportDialog = class _ImportDialog2 {
|
|
|
3754
3900
|
{
|
|
3755
3901
|
multiple: false,
|
|
3756
3902
|
maxFiles: 10,
|
|
3757
|
-
maxFileSize: 100
|
|
3903
|
+
maxFileSize: 100,
|
|
3904
|
+
maxFileSizeUnit: "MB"
|
|
3758
3905
|
},
|
|
3759
3906
|
{
|
|
3760
3907
|
onUpdate: () => this.updateModal(),
|
|
@@ -4156,7 +4303,7 @@ const _ImportDialog = class _ImportDialog2 {
|
|
|
4156
4303
|
return;
|
|
4157
4304
|
}
|
|
4158
4305
|
if (this.uploader.hasUploadingFiles()) {
|
|
4159
|
-
this.showMessage("
|
|
4306
|
+
this.showMessage(t("filesUploading"), "warning");
|
|
4160
4307
|
return;
|
|
4161
4308
|
}
|
|
4162
4309
|
if (this.uploader.hasPendingFiles()) {
|
|
@@ -4168,7 +4315,7 @@ const _ImportDialog = class _ImportDialog2 {
|
|
|
4168
4315
|
try {
|
|
4169
4316
|
const chunkResult = yield this.uploader.startUpload();
|
|
4170
4317
|
} catch (error) {
|
|
4171
|
-
this.showMessage("
|
|
4318
|
+
this.showMessage(t("uploadFailedRetry"), "error");
|
|
4172
4319
|
if (confirmLoadingEnabled2) {
|
|
4173
4320
|
this.confirmLoading = false;
|
|
4174
4321
|
this.updateModal();
|
|
@@ -4179,7 +4326,7 @@ const _ImportDialog = class _ImportDialog2 {
|
|
|
4179
4326
|
const failedFiles = this.uploader.getFailedFiles();
|
|
4180
4327
|
if (failedFiles.length > 0) {
|
|
4181
4328
|
this.showMessage(
|
|
4182
|
-
|
|
4329
|
+
t("filesUploadFailed", { count: failedFiles.length }),
|
|
4183
4330
|
"warning"
|
|
4184
4331
|
);
|
|
4185
4332
|
const confirmLoadingEnabled2 = ((_b = this.modalOptions.uploadConfig) == null ? void 0 : _b.confirmLoading) != null ? this.modalOptions.uploadConfig.confirmLoading : true;
|
|
@@ -4248,7 +4395,9 @@ const _ImportDialog = class _ImportDialog2 {
|
|
|
4248
4395
|
this.uploader.updateConfig({
|
|
4249
4396
|
multiple: (uploadConfig == null ? void 0 : uploadConfig.multiple) != null ? uploadConfig.multiple : false,
|
|
4250
4397
|
maxFiles: (uploadConfig == null ? void 0 : uploadConfig.maxFiles) != null ? uploadConfig.maxFiles : 10,
|
|
4251
|
-
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,
|
|
4252
4401
|
uploadConfig
|
|
4253
4402
|
});
|
|
4254
4403
|
this.activeTabIndex = (options == null ? void 0 : options.defaultActiveTab) || 0;
|