linkmore-design 1.1.35 → 1.1.37

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.
@@ -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
 
@@ -9822,9 +9822,6 @@ p {
9822
9822
  .lm_editTable_warpper .lm_table_quickcopy .anticon {
9823
9823
  color: var(--text-color);
9824
9824
  }
9825
- .lm_editTable_warpper .ant-table-body {
9826
- scroll-behavior: smooth;
9827
- }
9828
9825
  .lm_editTable_warpper .icon_drag {
9829
9826
  color: var(--tip-text-color);
9830
9827
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkmore-design",
3
- "version": "1.1.35",
3
+ "version": "1.1.37",
4
4
  "author": {
5
5
  "name": "nowthen",
6
6
  "email": "rnlvwyx@gmail.com"