linkmore-design 1.1.34 → 1.1.36

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.
@@ -20,7 +20,7 @@ var LmUploadList = function LmUploadList(_ref) {
20
20
  var _a;
21
21
 
22
22
  return (_a = getFileList()) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) {
23
- return a.seq - b.seq;
23
+ return (a === null || a === void 0 ? void 0 : a.seq) - (b === null || b === void 0 ? void 0 : b.seq);
24
24
  });
25
25
  }, [getFileList]);
26
26
 
@@ -13,7 +13,7 @@ var Preview = function Preview(_ref) {
13
13
  var _a;
14
14
 
15
15
  return (_a = getFileList()) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) {
16
- return a.seq - b.seq;
16
+ return (a === null || a === void 0 ? void 0 : a.seq) - (b === null || b === void 0 ? void 0 : b.seq);
17
17
  });
18
18
  }, [getFileList]);
19
19
  var config = useMemo(function () {
@@ -119,29 +119,47 @@ var useCoreOptions = function useCoreOptions(_ref) {
119
119
  }, [getFileList, props]); // 上传成功事件: File, fileParams
120
120
 
121
121
  var uploadSuccess = useCallback(function (file, params, ossCallBack) {
122
- var _a;
122
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
123
+ var _a, _b, fileList, res;
123
124
 
124
- var fileList = [].concat(_toConsumableArray(Array.isArray(params) ? params : [params]), _toConsumableArray(getFileList()));
125
- dispatch({
126
- type: 'changeFileList',
127
- fileList: fileList
128
- });
129
- dispatch({
130
- type: 'changePercent',
131
- percent: null
132
- }); // 上传事件:抛出 file: 文件 filelist: 文件列表 event: 上传进度信息
125
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
126
+ while (1) {
127
+ switch (_context.prev = _context.next) {
128
+ case 0:
129
+ fileList = [].concat(_toConsumableArray(Array.isArray(params) ? params : [params]), _toConsumableArray(getFileList()));
130
+ dispatch({
131
+ type: 'changeFileList',
132
+ fileList: fileList
133
+ });
134
+ dispatch({
135
+ type: 'changePercent',
136
+ percent: null
137
+ }); // 上传事件:抛出 file: 文件 filelist: 文件列表 event: 上传进度信息
133
138
 
134
- (_a = props.onSuccess) === null || _a === void 0 ? void 0 : _a.call(props, {
135
- file: file,
136
- fileList: fileList
137
- });
138
- onChange === null || onChange === void 0 ? void 0 : onChange({
139
- file: file,
140
- fileList: fileList
141
- });
142
- ossCallBack === null || ossCallBack === void 0 ? void 0 : ossCallBack(params);
143
- doneFileUploadLen.current = [];
144
- }, [getFileList, props.onSuccess, onChange, dispatch, doneFileUploadLen.current]); // 上传进度事件
139
+ (_a = props.onSuccess) === null || _a === void 0 ? void 0 : _a.call(props, {
140
+ file: file,
141
+ fileList: fileList
142
+ });
143
+ onChange === null || onChange === void 0 ? void 0 : onChange({
144
+ file: file,
145
+ fileList: fileList
146
+ });
147
+ doneFileUploadLen.current = [];
148
+ _context.next = 8;
149
+ return ossCallBack === null || ossCallBack === void 0 ? void 0 : ossCallBack(params);
150
+
151
+ case 8:
152
+ res = _context.sent;
153
+ (_b = props.onCallBack) === null || _b === void 0 ? void 0 : _b.call(props, res);
154
+
155
+ case 10:
156
+ case "end":
157
+ return _context.stop();
158
+ }
159
+ }
160
+ }, _callee);
161
+ }));
162
+ }, [getFileList, props.onSuccess, props.onCallBack, onChange, dispatch, doneFileUploadLen.current]); // 上传进度事件
145
163
 
146
164
  var uploadProgress = useCallback(function (file, _ref2) {
147
165
  var progress = _ref2.progress,
@@ -188,14 +206,14 @@ var useCoreOptions = function useCoreOptions(_ref) {
188
206
  }, [props.onError, getFileList, onChange, doneFileUploadLen.current]); // 上传至ali-oss
189
207
 
190
208
  var uploadOss = useCallback(function (file) {
191
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
209
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
192
210
  var _ossConfig, _ossConfig$dir, filePath, shortlink, _ossConfig$region, region, accessKeyId, accessKeySecret, stsToken, _ossConfig$bucket, bucket, ossCallBack, client, timestamp, fileName, pathName, url, params;
193
211
 
194
- return _regeneratorRuntime().wrap(function _callee$(_context) {
212
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
195
213
  while (1) {
196
- switch (_context.prev = _context.next) {
214
+ switch (_context2.prev = _context2.next) {
197
215
  case 0:
198
- _context.prev = 0;
216
+ _context2.prev = 0;
199
217
  _ossConfig = ossConfig(), _ossConfig$dir = _ossConfig.dir, filePath = _ossConfig$dir === void 0 ? '/BizFile/4595/Supplier/' : _ossConfig$dir, shortlink = _ossConfig.shortlink, _ossConfig$region = _ossConfig.region, region = _ossConfig$region === void 0 ? 'oss-cn-hangzhou' : _ossConfig$region, accessKeyId = _ossConfig.accessKeyId, accessKeySecret = _ossConfig.accessKeySecret, stsToken = _ossConfig.stsToken, _ossConfig$bucket = _ossConfig.bucket, bucket = _ossConfig$bucket === void 0 ? 'linkmore-scm-test' : _ossConfig$bucket, ossCallBack = _ossConfig.ossCallBack;
200
218
  client = new OSS({
201
219
  region: region,
@@ -208,7 +226,7 @@ var useCoreOptions = function useCoreOptions(_ref) {
208
226
  fileName = "".concat(timestamp, "-").concat(file.name);
209
227
  pathName = filePath.slice(-1) === '/' ? "".concat(filePath).concat(fileName) : "".concat(filePath, "/").concat(fileName);
210
228
  url = "".concat(shortlink).concat(pathName) || '';
211
- _context.next = 9;
229
+ _context2.next = 9;
212
230
  return client.multipartUpload(pathName, file, {
213
231
  // 获取分片上传进度、断点和返回值。
214
232
  progress: function progress(_progress, checkPoint, result) {
@@ -245,23 +263,23 @@ var useCoreOptions = function useCoreOptions(_ref) {
245
263
  }
246
264
  }
247
265
 
248
- _context.next = 17;
266
+ _context2.next = 17;
249
267
  break;
250
268
 
251
269
  case 14:
252
- _context.prev = 14;
253
- _context.t0 = _context["catch"](0);
270
+ _context2.prev = 14;
271
+ _context2.t0 = _context2["catch"](0);
254
272
  uploadError({
255
- error: _context.t0,
273
+ error: _context2.t0,
256
274
  file: file
257
275
  });
258
276
 
259
277
  case 17:
260
278
  case "end":
261
- return _context.stop();
279
+ return _context2.stop();
262
280
  }
263
281
  }
264
- }, _callee, null, [[0, 14]]);
282
+ }, _callee2, null, [[0, 14]]);
265
283
  }));
266
284
  }, [multiple, ossConfig, uploadProgress, props.fileConfig, uploadSuccess, uploadError, fileUploadLen.current, doneFileUploadLen.current]); // 自定义使用外部上传
267
285
 
@@ -281,53 +299,53 @@ var useCoreOptions = function useCoreOptions(_ref) {
281
299
  }, [enabledOss, uploadOss, customUpload]); // 检测完成, 执行外部 `beforeUpload` 事件
282
300
 
283
301
  var checkOver = useCallback(function (file) {
284
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
302
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
285
303
  var res, newFile;
286
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
304
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
287
305
  while (1) {
288
- switch (_context2.prev = _context2.next) {
306
+ switch (_context3.prev = _context3.next) {
289
307
  case 0:
290
308
  if (props === null || props === void 0 ? void 0 : props.beforeUpload) {
291
- _context2.next = 3;
309
+ _context3.next = 3;
292
310
  break;
293
311
  }
294
312
 
295
313
  uploadFile(file);
296
- return _context2.abrupt("return");
314
+ return _context3.abrupt("return");
297
315
 
298
316
  case 3:
299
317
  res = props.beforeUpload(file, getFileList()); // Promise
300
318
 
301
319
  if (!(res === null || res === void 0 ? void 0 : res.then)) {
302
- _context2.next = 16;
320
+ _context3.next = 16;
303
321
  break;
304
322
  }
305
323
 
306
- _context2.prev = 5;
307
- _context2.next = 8;
324
+ _context3.prev = 5;
325
+ _context3.next = 8;
308
326
  return res;
309
327
 
310
328
  case 8:
311
- newFile = _context2.sent;
329
+ newFile = _context3.sent;
312
330
  uploadFile(newFile);
313
- _context2.next = 15;
331
+ _context3.next = 15;
314
332
  break;
315
333
 
316
334
  case 12:
317
- _context2.prev = 12;
318
- _context2.t0 = _context2["catch"](5);
335
+ _context3.prev = 12;
336
+ _context3.t0 = _context3["catch"](5);
319
337
  console.log('上传失败!');
320
338
 
321
339
  case 15:
322
- return _context2.abrupt("return");
340
+ return _context3.abrupt("return");
323
341
 
324
342
  case 16:
325
343
  if (res) {
326
- _context2.next = 18;
344
+ _context3.next = 18;
327
345
  break;
328
346
  }
329
347
 
330
- return _context2.abrupt("return");
348
+ return _context3.abrupt("return");
331
349
 
332
350
  case 18:
333
351
  // () => true
@@ -335,10 +353,10 @@ var useCoreOptions = function useCoreOptions(_ref) {
335
353
 
336
354
  case 19:
337
355
  case "end":
338
- return _context2.stop();
356
+ return _context3.stop();
339
357
  }
340
358
  }
341
- }, _callee2, null, [[5, 12]]);
359
+ }, _callee3, null, [[5, 12]]);
342
360
  }));
343
361
  }, [props.beforeUpload, getFileList, uploadFile]); // 单个文件异步校验
344
362
 
@@ -400,19 +418,19 @@ var useCoreOptions = function useCoreOptions(_ref) {
400
418
  */
401
419
 
402
420
  var beforeUpload = useCallback(function (e) {
403
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
421
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
404
422
  var files, res;
405
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
423
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
406
424
  while (1) {
407
- switch (_context3.prev = _context3.next) {
425
+ switch (_context4.prev = _context4.next) {
408
426
  case 0:
409
427
  files = Array.from(e.target.files);
410
- _context3.prev = 1;
411
- _context3.next = 4;
428
+ _context4.prev = 1;
429
+ _context4.next = 4;
412
430
  return filesLoopCheck(files);
413
431
 
414
432
  case 4:
415
- res = _context3.sent;
433
+ res = _context4.sent;
416
434
  fileUploadLen.current = res.length; // 仅单文件上传时可剪裁
417
435
 
418
436
  if (enableCrop) {
@@ -425,40 +443,40 @@ var useCoreOptions = function useCoreOptions(_ref) {
425
443
  res.forEach(checkOver);
426
444
  }
427
445
 
428
- _context3.next = 13;
446
+ _context4.next = 13;
429
447
  break;
430
448
 
431
449
  case 9:
432
- _context3.prev = 9;
433
- _context3.t0 = _context3["catch"](1);
434
- console.log('文件校验未通过!', _context3.t0.message);
435
- message.warning(_context3.t0.message, 1.5);
450
+ _context4.prev = 9;
451
+ _context4.t0 = _context4["catch"](1);
452
+ console.log('文件校验未通过!', _context4.t0.message);
453
+ message.warning(_context4.t0.message, 1.5);
436
454
 
437
455
  case 13:
438
456
  case "end":
439
- return _context3.stop();
457
+ return _context4.stop();
440
458
  }
441
459
  }
442
- }, _callee3, null, [[1, 9]]);
460
+ }, _callee4, null, [[1, 9]]);
443
461
  }));
444
462
  }, [filesLoopCheck, enableCrop, checkOver, fileUploadLen.current]); // 删除事件
445
463
 
446
464
  var remove = useCallback(function (file) {
447
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
448
- var _a, _b, res, fileList;
465
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
466
+ var _c, _d, res, fileList;
449
467
 
450
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
468
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
451
469
  while (1) {
452
- switch (_context4.prev = _context4.next) {
470
+ switch (_context5.prev = _context5.next) {
453
471
  case 0:
454
- _context4.next = 2;
455
- return (_a = props.onRemove) === null || _a === void 0 ? void 0 : _a.call(props, file);
472
+ _context5.next = 2;
473
+ return (_c = props.onRemove) === null || _c === void 0 ? void 0 : _c.call(props, file);
456
474
 
457
475
  case 2:
458
- res = _context4.sent;
476
+ res = _context5.sent;
459
477
 
460
478
  if (res) {
461
- fileList = (_b = getFileList()) === null || _b === void 0 ? void 0 : _b.filter(function (v) {
479
+ fileList = (_d = getFileList()) === null || _d === void 0 ? void 0 : _d.filter(function (v) {
462
480
  return !getHasEqual(v, file);
463
481
  });
464
482
  dispatch({
@@ -473,10 +491,10 @@ var useCoreOptions = function useCoreOptions(_ref) {
473
491
 
474
492
  case 4:
475
493
  case "end":
476
- return _context4.stop();
494
+ return _context5.stop();
477
495
  }
478
496
  }
479
- }, _callee4);
497
+ }, _callee5);
480
498
  }));
481
499
  }, [props.onRemove, getFileList, onChange, dispatch, getHasEqual]); // 点击文件链接或预览图标时的回调
482
500
 
@@ -34,7 +34,7 @@ var LmUploadList = function LmUploadList(_ref) {
34
34
  var _a;
35
35
 
36
36
  return (_a = getFileList()) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) {
37
- return a.seq - b.seq;
37
+ return (a === null || a === void 0 ? void 0 : a.seq) - (b === null || b === void 0 ? void 0 : b.seq);
38
38
  });
39
39
  }, [getFileList]);
40
40
 
@@ -23,7 +23,7 @@ var Preview = function Preview(_ref) {
23
23
  var _a;
24
24
 
25
25
  return (_a = getFileList()) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) {
26
- return a.seq - b.seq;
26
+ return (a === null || a === void 0 ? void 0 : a.seq) - (b === null || b === void 0 ? void 0 : b.seq);
27
27
  });
28
28
  }, [getFileList]);
29
29
  var config = (0, _react.useMemo)(function () {
@@ -131,29 +131,47 @@ var useCoreOptions = function useCoreOptions(_ref) {
131
131
  }, [getFileList, props]); // 上传成功事件: File, fileParams
132
132
 
133
133
  var uploadSuccess = (0, _react.useCallback)(function (file, params, ossCallBack) {
134
- var _a;
134
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
135
+ var _a, _b, fileList, res;
135
136
 
136
- var fileList = [].concat((0, _toConsumableArray2.default)(Array.isArray(params) ? params : [params]), (0, _toConsumableArray2.default)(getFileList()));
137
- dispatch({
138
- type: 'changeFileList',
139
- fileList: fileList
140
- });
141
- dispatch({
142
- type: 'changePercent',
143
- percent: null
144
- }); // 上传事件:抛出 file: 文件 filelist: 文件列表 event: 上传进度信息
137
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
138
+ while (1) {
139
+ switch (_context.prev = _context.next) {
140
+ case 0:
141
+ fileList = [].concat((0, _toConsumableArray2.default)(Array.isArray(params) ? params : [params]), (0, _toConsumableArray2.default)(getFileList()));
142
+ dispatch({
143
+ type: 'changeFileList',
144
+ fileList: fileList
145
+ });
146
+ dispatch({
147
+ type: 'changePercent',
148
+ percent: null
149
+ }); // 上传事件:抛出 file: 文件 filelist: 文件列表 event: 上传进度信息
145
150
 
146
- (_a = props.onSuccess) === null || _a === void 0 ? void 0 : _a.call(props, {
147
- file: file,
148
- fileList: fileList
149
- });
150
- onChange === null || onChange === void 0 ? void 0 : onChange({
151
- file: file,
152
- fileList: fileList
153
- });
154
- ossCallBack === null || ossCallBack === void 0 ? void 0 : ossCallBack(params);
155
- doneFileUploadLen.current = [];
156
- }, [getFileList, props.onSuccess, onChange, dispatch, doneFileUploadLen.current]); // 上传进度事件
151
+ (_a = props.onSuccess) === null || _a === void 0 ? void 0 : _a.call(props, {
152
+ file: file,
153
+ fileList: fileList
154
+ });
155
+ onChange === null || onChange === void 0 ? void 0 : onChange({
156
+ file: file,
157
+ fileList: fileList
158
+ });
159
+ doneFileUploadLen.current = [];
160
+ _context.next = 8;
161
+ return ossCallBack === null || ossCallBack === void 0 ? void 0 : ossCallBack(params);
162
+
163
+ case 8:
164
+ res = _context.sent;
165
+ (_b = props.onCallBack) === null || _b === void 0 ? void 0 : _b.call(props, res);
166
+
167
+ case 10:
168
+ case "end":
169
+ return _context.stop();
170
+ }
171
+ }
172
+ }, _callee);
173
+ }));
174
+ }, [getFileList, props.onSuccess, props.onCallBack, onChange, dispatch, doneFileUploadLen.current]); // 上传进度事件
157
175
 
158
176
  var uploadProgress = (0, _react.useCallback)(function (file, _ref2) {
159
177
  var progress = _ref2.progress,
@@ -200,14 +218,14 @@ var useCoreOptions = function useCoreOptions(_ref) {
200
218
  }, [props.onError, getFileList, onChange, doneFileUploadLen.current]); // 上传至ali-oss
201
219
 
202
220
  var uploadOss = (0, _react.useCallback)(function (file) {
203
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
221
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
204
222
  var _ossConfig, _ossConfig$dir, filePath, shortlink, _ossConfig$region, region, accessKeyId, accessKeySecret, stsToken, _ossConfig$bucket, bucket, ossCallBack, client, timestamp, fileName, pathName, url, params;
205
223
 
206
- return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
224
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
207
225
  while (1) {
208
- switch (_context.prev = _context.next) {
226
+ switch (_context2.prev = _context2.next) {
209
227
  case 0:
210
- _context.prev = 0;
228
+ _context2.prev = 0;
211
229
  _ossConfig = ossConfig(), _ossConfig$dir = _ossConfig.dir, filePath = _ossConfig$dir === void 0 ? '/BizFile/4595/Supplier/' : _ossConfig$dir, shortlink = _ossConfig.shortlink, _ossConfig$region = _ossConfig.region, region = _ossConfig$region === void 0 ? 'oss-cn-hangzhou' : _ossConfig$region, accessKeyId = _ossConfig.accessKeyId, accessKeySecret = _ossConfig.accessKeySecret, stsToken = _ossConfig.stsToken, _ossConfig$bucket = _ossConfig.bucket, bucket = _ossConfig$bucket === void 0 ? 'linkmore-scm-test' : _ossConfig$bucket, ossCallBack = _ossConfig.ossCallBack;
212
230
  client = new _aliOss.default({
213
231
  region: region,
@@ -220,7 +238,7 @@ var useCoreOptions = function useCoreOptions(_ref) {
220
238
  fileName = "".concat(timestamp, "-").concat(file.name);
221
239
  pathName = filePath.slice(-1) === '/' ? "".concat(filePath).concat(fileName) : "".concat(filePath, "/").concat(fileName);
222
240
  url = "".concat(shortlink).concat(pathName) || '';
223
- _context.next = 9;
241
+ _context2.next = 9;
224
242
  return client.multipartUpload(pathName, file, {
225
243
  // 获取分片上传进度、断点和返回值。
226
244
  progress: function progress(_progress, checkPoint, result) {
@@ -257,23 +275,23 @@ var useCoreOptions = function useCoreOptions(_ref) {
257
275
  }
258
276
  }
259
277
 
260
- _context.next = 17;
278
+ _context2.next = 17;
261
279
  break;
262
280
 
263
281
  case 14:
264
- _context.prev = 14;
265
- _context.t0 = _context["catch"](0);
282
+ _context2.prev = 14;
283
+ _context2.t0 = _context2["catch"](0);
266
284
  uploadError({
267
- error: _context.t0,
285
+ error: _context2.t0,
268
286
  file: file
269
287
  });
270
288
 
271
289
  case 17:
272
290
  case "end":
273
- return _context.stop();
291
+ return _context2.stop();
274
292
  }
275
293
  }
276
- }, _callee, null, [[0, 14]]);
294
+ }, _callee2, null, [[0, 14]]);
277
295
  }));
278
296
  }, [multiple, ossConfig, uploadProgress, props.fileConfig, uploadSuccess, uploadError, fileUploadLen.current, doneFileUploadLen.current]); // 自定义使用外部上传
279
297
 
@@ -293,53 +311,53 @@ var useCoreOptions = function useCoreOptions(_ref) {
293
311
  }, [enabledOss, uploadOss, customUpload]); // 检测完成, 执行外部 `beforeUpload` 事件
294
312
 
295
313
  var checkOver = (0, _react.useCallback)(function (file) {
296
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
314
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3() {
297
315
  var res, newFile;
298
- return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
316
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
299
317
  while (1) {
300
- switch (_context2.prev = _context2.next) {
318
+ switch (_context3.prev = _context3.next) {
301
319
  case 0:
302
320
  if (props === null || props === void 0 ? void 0 : props.beforeUpload) {
303
- _context2.next = 3;
321
+ _context3.next = 3;
304
322
  break;
305
323
  }
306
324
 
307
325
  uploadFile(file);
308
- return _context2.abrupt("return");
326
+ return _context3.abrupt("return");
309
327
 
310
328
  case 3:
311
329
  res = props.beforeUpload(file, getFileList()); // Promise
312
330
 
313
331
  if (!(res === null || res === void 0 ? void 0 : res.then)) {
314
- _context2.next = 16;
332
+ _context3.next = 16;
315
333
  break;
316
334
  }
317
335
 
318
- _context2.prev = 5;
319
- _context2.next = 8;
336
+ _context3.prev = 5;
337
+ _context3.next = 8;
320
338
  return res;
321
339
 
322
340
  case 8:
323
- newFile = _context2.sent;
341
+ newFile = _context3.sent;
324
342
  uploadFile(newFile);
325
- _context2.next = 15;
343
+ _context3.next = 15;
326
344
  break;
327
345
 
328
346
  case 12:
329
- _context2.prev = 12;
330
- _context2.t0 = _context2["catch"](5);
347
+ _context3.prev = 12;
348
+ _context3.t0 = _context3["catch"](5);
331
349
  console.log('上传失败!');
332
350
 
333
351
  case 15:
334
- return _context2.abrupt("return");
352
+ return _context3.abrupt("return");
335
353
 
336
354
  case 16:
337
355
  if (res) {
338
- _context2.next = 18;
356
+ _context3.next = 18;
339
357
  break;
340
358
  }
341
359
 
342
- return _context2.abrupt("return");
360
+ return _context3.abrupt("return");
343
361
 
344
362
  case 18:
345
363
  // () => true
@@ -347,10 +365,10 @@ var useCoreOptions = function useCoreOptions(_ref) {
347
365
 
348
366
  case 19:
349
367
  case "end":
350
- return _context2.stop();
368
+ return _context3.stop();
351
369
  }
352
370
  }
353
- }, _callee2, null, [[5, 12]]);
371
+ }, _callee3, null, [[5, 12]]);
354
372
  }));
355
373
  }, [props.beforeUpload, getFileList, uploadFile]); // 单个文件异步校验
356
374
 
@@ -412,19 +430,19 @@ var useCoreOptions = function useCoreOptions(_ref) {
412
430
  */
413
431
 
414
432
  var beforeUpload = (0, _react.useCallback)(function (e) {
415
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3() {
433
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4() {
416
434
  var files, res;
417
- return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
435
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
418
436
  while (1) {
419
- switch (_context3.prev = _context3.next) {
437
+ switch (_context4.prev = _context4.next) {
420
438
  case 0:
421
439
  files = Array.from(e.target.files);
422
- _context3.prev = 1;
423
- _context3.next = 4;
440
+ _context4.prev = 1;
441
+ _context4.next = 4;
424
442
  return filesLoopCheck(files);
425
443
 
426
444
  case 4:
427
- res = _context3.sent;
445
+ res = _context4.sent;
428
446
  fileUploadLen.current = res.length; // 仅单文件上传时可剪裁
429
447
 
430
448
  if (enableCrop) {
@@ -437,41 +455,41 @@ var useCoreOptions = function useCoreOptions(_ref) {
437
455
  res.forEach(checkOver);
438
456
  }
439
457
 
440
- _context3.next = 13;
458
+ _context4.next = 13;
441
459
  break;
442
460
 
443
461
  case 9:
444
- _context3.prev = 9;
445
- _context3.t0 = _context3["catch"](1);
446
- console.log('文件校验未通过!', _context3.t0.message);
462
+ _context4.prev = 9;
463
+ _context4.t0 = _context4["catch"](1);
464
+ console.log('文件校验未通过!', _context4.t0.message);
447
465
 
448
- _linkmoreDesign.message.warning(_context3.t0.message, 1.5);
466
+ _linkmoreDesign.message.warning(_context4.t0.message, 1.5);
449
467
 
450
468
  case 13:
451
469
  case "end":
452
- return _context3.stop();
470
+ return _context4.stop();
453
471
  }
454
472
  }
455
- }, _callee3, null, [[1, 9]]);
473
+ }, _callee4, null, [[1, 9]]);
456
474
  }));
457
475
  }, [filesLoopCheck, enableCrop, checkOver, fileUploadLen.current]); // 删除事件
458
476
 
459
477
  var remove = (0, _react.useCallback)(function (file) {
460
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4() {
461
- var _a, _b, res, fileList;
478
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee5() {
479
+ var _c, _d, res, fileList;
462
480
 
463
- return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
481
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee5$(_context5) {
464
482
  while (1) {
465
- switch (_context4.prev = _context4.next) {
483
+ switch (_context5.prev = _context5.next) {
466
484
  case 0:
467
- _context4.next = 2;
468
- return (_a = props.onRemove) === null || _a === void 0 ? void 0 : _a.call(props, file);
485
+ _context5.next = 2;
486
+ return (_c = props.onRemove) === null || _c === void 0 ? void 0 : _c.call(props, file);
469
487
 
470
488
  case 2:
471
- res = _context4.sent;
489
+ res = _context5.sent;
472
490
 
473
491
  if (res) {
474
- fileList = (_b = getFileList()) === null || _b === void 0 ? void 0 : _b.filter(function (v) {
492
+ fileList = (_d = getFileList()) === null || _d === void 0 ? void 0 : _d.filter(function (v) {
475
493
  return !getHasEqual(v, file);
476
494
  });
477
495
  dispatch({
@@ -486,10 +504,10 @@ var useCoreOptions = function useCoreOptions(_ref) {
486
504
 
487
505
  case 4:
488
506
  case "end":
489
- return _context4.stop();
507
+ return _context5.stop();
490
508
  }
491
509
  }
492
- }, _callee4);
510
+ }, _callee5);
493
511
  }));
494
512
  }, [props.onRemove, getFileList, onChange, dispatch, getHasEqual]); // 点击文件链接或预览图标时的回调
495
513
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkmore-design",
3
- "version": "1.1.34",
3
+ "version": "1.1.36",
4
4
  "author": {
5
5
  "name": "nowthen",
6
6
  "email": "rnlvwyx@gmail.com"