@sl-material/sl-import 1.0.0-beta18 → 1.0.0-beta20

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/sl-import.es.js CHANGED
@@ -3176,9 +3176,14 @@ class ImportDialogUploader {
3176
3176
  }
3177
3177
  /**
3178
3178
  * 使用 customUpload 预处理文件
3179
- * 在选择文件后立即调用,用于二次加工参数或自定义校验
3179
+ * 仅在配置了 customUpload 时才调用
3180
3180
  */
3181
3181
  async processFilesWithCustomUpload() {
3182
+ var _a;
3183
+ const customUpload = (_a = this.config.uploadConfig) == null ? void 0 : _a.customUpload;
3184
+ if (!customUpload) {
3185
+ return;
3186
+ }
3182
3187
  const pendingFiles = this.uploadFileList.filter(
3183
3188
  (f) => f.status === "pending"
3184
3189
  );
@@ -3187,22 +3192,18 @@ class ImportDialogUploader {
3187
3192
  }
3188
3193
  }
3189
3194
  /**
3190
- * 单个文件的预处理
3195
+ * 单个文件的预处理(仅在有 customUpload 时调用)
3191
3196
  */
3192
3197
  async processFileWithCustomUpload(fileItem) {
3193
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3198
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3194
3199
  const customUpload = (_a = this.config.uploadConfig) == null ? void 0 : _a.customUpload;
3195
3200
  if (!customUpload) {
3196
- fileItem.status = "success";
3197
- fileItem.progress = 100;
3198
- fileItem.response = fileItem.file;
3199
- (_c = (_b = this.callbacks).onUpdate) == null ? void 0 : _c.call(_b);
3200
3201
  return;
3201
3202
  }
3202
3203
  fileItem.status = "uploading";
3203
3204
  fileItem.progress = 0;
3204
3205
  this.isUploading = true;
3205
- (_e = (_d = this.callbacks).onUpdate) == null ? void 0 : _e.call(_d);
3206
+ (_c = (_b = this.callbacks).onUpdate) == null ? void 0 : _c.call(_b);
3206
3207
  try {
3207
3208
  const context = {
3208
3209
  fileList: [...this.uploadFileList],
@@ -3222,16 +3223,16 @@ class ImportDialogUploader {
3222
3223
  );
3223
3224
  fileItem.status = "success";
3224
3225
  fileItem.progress = 100;
3225
- (_g = (_f = this.callbacks).onUploadSuccess) == null ? void 0 : _g.call(_f, fileItem, fileItem.response);
3226
+ (_e = (_d = this.callbacks).onUploadSuccess) == null ? void 0 : _e.call(_d, fileItem, fileItem.response);
3226
3227
  } catch (error) {
3227
3228
  fileItem.status = "error";
3228
3229
  fileItem.errorMessage = error instanceof Error ? error.message : "处理失败";
3229
- (_i = (_h = this.callbacks).onUploadError) == null ? void 0 : _i.call(_h, fileItem, error);
3230
+ (_g = (_f = this.callbacks).onUploadError) == null ? void 0 : _g.call(_f, fileItem, error);
3230
3231
  }
3231
3232
  this.isUploading = this.uploadFileList.some(
3232
3233
  (f) => f.status === "uploading"
3233
3234
  );
3234
- (_k = (_j = this.callbacks).onUpdate) == null ? void 0 : _k.call(_j);
3235
+ (_i = (_h = this.callbacks).onUpdate) == null ? void 0 : _i.call(_h);
3235
3236
  this.updateOverallProgress();
3236
3237
  }
3237
3238
  /**
@@ -3239,16 +3240,16 @@ class ImportDialogUploader {
3239
3240
  * @param index 文件索引,不传则清空所有文件
3240
3241
  *
3241
3242
  * 删除权限:
3242
- * - pending 状态:可删除(还没开始上传)
3243
- * - uploading 状态:不可删除(正在上传/处理中)
3244
- * - success/error 状态:可删除(已完成)
3243
+ * - 实时分片上传场景:uploading 状态不可删除(真正的网络上传中)
3244
+ * - 其他场景(延迟分片、customUpload、无配置):任何状态都可删除
3245
3245
  */
3246
3246
  removeFile(index) {
3247
- var _a, _b, _c, _d, _e, _f, _g, _h;
3247
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3248
+ const needCheckStatus = this.shouldUseChunkedUpload() && ((_a = this.config.uploadConfig) == null ? void 0 : _a.autoUpload) !== false;
3248
3249
  if (index !== void 0 && index >= 0 && index < this.uploadFileList.length) {
3249
3250
  const fileItem = this.uploadFileList[index];
3250
- if (fileItem.status === "uploading") {
3251
- (_b = (_a = this.callbacks).onMessage) == null ? void 0 : _b.call(_a, "文件正在处理中,无法删除", "warning");
3251
+ if (needCheckStatus && fileItem.status === "uploading") {
3252
+ (_c = (_b = this.callbacks).onMessage) == null ? void 0 : _c.call(_b, "文件正在上传中,无法删除", "warning");
3252
3253
  return false;
3253
3254
  }
3254
3255
  const queueIndex = this.uploadQueue.findIndex(
@@ -3260,12 +3261,14 @@ class ImportDialogUploader {
3260
3261
  this.uploadFileList.splice(index, 1);
3261
3262
  this.fileList.splice(index, 1);
3262
3263
  } else {
3263
- const hasUploading = this.uploadFileList.some(
3264
- (f) => f.status === "uploading"
3265
- );
3266
- if (hasUploading) {
3267
- (_d = (_c = this.callbacks).onMessage) == null ? void 0 : _d.call(_c, "有文件正在处理中,无法清空", "warning");
3268
- return false;
3264
+ if (needCheckStatus) {
3265
+ const hasUploading = this.uploadFileList.some(
3266
+ (f) => f.status === "uploading"
3267
+ );
3268
+ if (hasUploading) {
3269
+ (_e = (_d = this.callbacks).onMessage) == null ? void 0 : _e.call(_d, "有文件正在上传中,无法清空", "warning");
3270
+ return false;
3271
+ }
3269
3272
  }
3270
3273
  this.uploadQueue = [];
3271
3274
  this.uploadFileList = [];
@@ -3277,8 +3280,8 @@ class ImportDialogUploader {
3277
3280
  this.isUploading = this.uploadFileList.some(
3278
3281
  (f) => f.status === "uploading"
3279
3282
  );
3280
- (_f = (_e = this.callbacks).onFileChange) == null ? void 0 : _f.call(_e, this.uploadFileList);
3281
- (_h = (_g = this.callbacks).onUpdate) == null ? void 0 : _h.call(_g);
3283
+ (_g = (_f = this.callbacks).onFileChange) == null ? void 0 : _g.call(_f, this.uploadFileList);
3284
+ (_i = (_h = this.callbacks).onUpdate) == null ? void 0 : _i.call(_h);
3282
3285
  return true;
3283
3286
  }
3284
3287
  /**