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.
- package/dist/index.umd.js +110 -87
- package/dist/index.umd.min.js +1 -1
- package/es/LmUpload/UploadList/index.js +1 -1
- package/es/LmUpload/components/Preview.js +1 -1
- package/es/LmUpload/fns/index.js +90 -72
- package/lib/LmUpload/UploadList/index.js +1 -1
- package/lib/LmUpload/components/Preview.js +1 -1
- package/lib/LmUpload/fns/index.js +90 -72
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -187485,37 +187485,60 @@
|
|
|
187485
187485
|
return flag;
|
|
187486
187486
|
}, [getFileList, props]); // 上传成功事件: File, fileParams
|
|
187487
187487
|
|
|
187488
|
-
var uploadSuccess = React.useCallback(function (
|
|
187489
|
-
var
|
|
187488
|
+
var uploadSuccess = React.useCallback( /*#__PURE__*/function () {
|
|
187489
|
+
var _ref2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(file, params, ossCallBack) {
|
|
187490
|
+
var _props$onSuccess, _props$onCallBack;
|
|
187490
187491
|
|
|
187491
|
-
|
|
187492
|
-
|
|
187493
|
-
|
|
187494
|
-
|
|
187495
|
-
|
|
187496
|
-
|
|
187497
|
-
|
|
187498
|
-
|
|
187499
|
-
|
|
187492
|
+
var fileList, res;
|
|
187493
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
187494
|
+
while (1) {
|
|
187495
|
+
switch (_context.prev = _context.next) {
|
|
187496
|
+
case 0:
|
|
187497
|
+
fileList = [].concat(_toConsumableArray$1(Array.isArray(params) ? params : [params]), _toConsumableArray$1(getFileList()));
|
|
187498
|
+
dispatch({
|
|
187499
|
+
type: 'changeFileList',
|
|
187500
|
+
fileList: fileList
|
|
187501
|
+
});
|
|
187502
|
+
dispatch({
|
|
187503
|
+
type: 'changePercent',
|
|
187504
|
+
percent: null
|
|
187505
|
+
}); // 上传事件:抛出 file: 文件 filelist: 文件列表 event: 上传进度信息
|
|
187500
187506
|
|
|
187501
|
-
|
|
187502
|
-
|
|
187503
|
-
|
|
187504
|
-
|
|
187505
|
-
|
|
187506
|
-
|
|
187507
|
-
|
|
187508
|
-
|
|
187509
|
-
|
|
187510
|
-
|
|
187511
|
-
|
|
187507
|
+
(_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, {
|
|
187508
|
+
file: file,
|
|
187509
|
+
fileList: fileList
|
|
187510
|
+
});
|
|
187511
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
187512
|
+
file: file,
|
|
187513
|
+
fileList: fileList
|
|
187514
|
+
});
|
|
187515
|
+
doneFileUploadLen.current = [];
|
|
187516
|
+
_context.next = 8;
|
|
187517
|
+
return ossCallBack === null || ossCallBack === void 0 ? void 0 : ossCallBack(params);
|
|
187518
|
+
|
|
187519
|
+
case 8:
|
|
187520
|
+
res = _context.sent;
|
|
187521
|
+
(_props$onCallBack = props.onCallBack) === null || _props$onCallBack === void 0 ? void 0 : _props$onCallBack.call(props, res);
|
|
187512
187522
|
|
|
187513
|
-
|
|
187523
|
+
case 10:
|
|
187524
|
+
case "end":
|
|
187525
|
+
return _context.stop();
|
|
187526
|
+
}
|
|
187527
|
+
}
|
|
187528
|
+
}, _callee);
|
|
187529
|
+
}));
|
|
187530
|
+
|
|
187531
|
+
return function (_x, _x2, _x3) {
|
|
187532
|
+
return _ref2.apply(this, arguments);
|
|
187533
|
+
};
|
|
187534
|
+
}(), [getFileList, props.onSuccess, props.onCallBack, onChange, dispatch, doneFileUploadLen.current]); // 上传进度事件
|
|
187535
|
+
|
|
187536
|
+
var uploadProgress = React.useCallback(function (file, _ref3) {
|
|
187514
187537
|
var _props$onProgress;
|
|
187515
187538
|
|
|
187516
|
-
var progress =
|
|
187517
|
-
checkPoint =
|
|
187518
|
-
result =
|
|
187539
|
+
var progress = _ref3.progress,
|
|
187540
|
+
checkPoint = _ref3.checkPoint,
|
|
187541
|
+
result = _ref3.result;
|
|
187519
187542
|
var params = {
|
|
187520
187543
|
file: file,
|
|
187521
187544
|
fileList: getFileList(),
|
|
@@ -187534,9 +187557,9 @@
|
|
|
187534
187557
|
});
|
|
187535
187558
|
}, [getFileList, props.onProgress, onChange, dispatch]); // 上传失败事件
|
|
187536
187559
|
|
|
187537
|
-
var uploadError = React.useCallback(function (
|
|
187538
|
-
var error =
|
|
187539
|
-
file =
|
|
187560
|
+
var uploadError = React.useCallback(function (_ref4) {
|
|
187561
|
+
var error = _ref4.error,
|
|
187562
|
+
file = _ref4.file;
|
|
187540
187563
|
console.log('上传报错:', error);
|
|
187541
187564
|
props.onError ? props.onError({
|
|
187542
187565
|
error: error,
|
|
@@ -187554,14 +187577,14 @@
|
|
|
187554
187577
|
}, [props.onError, getFileList, onChange, doneFileUploadLen.current]); // 上传至ali-oss
|
|
187555
187578
|
|
|
187556
187579
|
var uploadOss = React.useCallback( /*#__PURE__*/function () {
|
|
187557
|
-
var
|
|
187580
|
+
var _ref5 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(file) {
|
|
187558
187581
|
var _ossConfig, _ossConfig$dir, filePath, shortlink, _ossConfig$region, region, accessKeyId, accessKeySecret, stsToken, _ossConfig$bucket, bucket, ossCallBack, client$1, timestamp, fileName, pathName, url, params;
|
|
187559
187582
|
|
|
187560
|
-
return _regeneratorRuntime$1().wrap(function
|
|
187583
|
+
return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
|
|
187561
187584
|
while (1) {
|
|
187562
|
-
switch (
|
|
187585
|
+
switch (_context2.prev = _context2.next) {
|
|
187563
187586
|
case 0:
|
|
187564
|
-
|
|
187587
|
+
_context2.prev = 0;
|
|
187565
187588
|
_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;
|
|
187566
187589
|
client$1 = new client({
|
|
187567
187590
|
region: region,
|
|
@@ -187574,7 +187597,7 @@
|
|
|
187574
187597
|
fileName = "".concat(timestamp, "-").concat(file.name);
|
|
187575
187598
|
pathName = filePath.slice(-1) === '/' ? "".concat(filePath).concat(fileName) : "".concat(filePath, "/").concat(fileName);
|
|
187576
187599
|
url = "".concat(shortlink).concat(pathName) || '';
|
|
187577
|
-
|
|
187600
|
+
_context2.next = 9;
|
|
187578
187601
|
return client$1.multipartUpload(pathName, file, {
|
|
187579
187602
|
// 获取分片上传进度、断点和返回值。
|
|
187580
187603
|
progress: function progress(_progress, checkPoint, result) {
|
|
@@ -187611,27 +187634,27 @@
|
|
|
187611
187634
|
}
|
|
187612
187635
|
}
|
|
187613
187636
|
|
|
187614
|
-
|
|
187637
|
+
_context2.next = 17;
|
|
187615
187638
|
break;
|
|
187616
187639
|
|
|
187617
187640
|
case 14:
|
|
187618
|
-
|
|
187619
|
-
|
|
187641
|
+
_context2.prev = 14;
|
|
187642
|
+
_context2.t0 = _context2["catch"](0);
|
|
187620
187643
|
uploadError({
|
|
187621
|
-
error:
|
|
187644
|
+
error: _context2.t0,
|
|
187622
187645
|
file: file
|
|
187623
187646
|
});
|
|
187624
187647
|
|
|
187625
187648
|
case 17:
|
|
187626
187649
|
case "end":
|
|
187627
|
-
return
|
|
187650
|
+
return _context2.stop();
|
|
187628
187651
|
}
|
|
187629
187652
|
}
|
|
187630
|
-
},
|
|
187653
|
+
}, _callee2, null, [[0, 14]]);
|
|
187631
187654
|
}));
|
|
187632
187655
|
|
|
187633
|
-
return function (
|
|
187634
|
-
return
|
|
187656
|
+
return function (_x4) {
|
|
187657
|
+
return _ref5.apply(this, arguments);
|
|
187635
187658
|
};
|
|
187636
187659
|
}(), [multiple, ossConfig, uploadProgress, props.fileConfig, uploadSuccess, uploadError, fileUploadLen.current, doneFileUploadLen.current]); // 自定义使用外部上传
|
|
187637
187660
|
|
|
@@ -187651,53 +187674,53 @@
|
|
|
187651
187674
|
}, [enabledOss, uploadOss, customUpload]); // 检测完成, 执行外部 `beforeUpload` 事件
|
|
187652
187675
|
|
|
187653
187676
|
var checkOver = React.useCallback( /*#__PURE__*/function () {
|
|
187654
|
-
var
|
|
187677
|
+
var _ref6 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3(file) {
|
|
187655
187678
|
var res, newFile;
|
|
187656
|
-
return _regeneratorRuntime$1().wrap(function
|
|
187679
|
+
return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
|
|
187657
187680
|
while (1) {
|
|
187658
|
-
switch (
|
|
187681
|
+
switch (_context3.prev = _context3.next) {
|
|
187659
187682
|
case 0:
|
|
187660
187683
|
if (props === null || props === void 0 ? void 0 : props.beforeUpload) {
|
|
187661
|
-
|
|
187684
|
+
_context3.next = 3;
|
|
187662
187685
|
break;
|
|
187663
187686
|
}
|
|
187664
187687
|
|
|
187665
187688
|
uploadFile(file);
|
|
187666
|
-
return
|
|
187689
|
+
return _context3.abrupt("return");
|
|
187667
187690
|
|
|
187668
187691
|
case 3:
|
|
187669
187692
|
res = props.beforeUpload(file, getFileList()); // Promise
|
|
187670
187693
|
|
|
187671
187694
|
if (!(res === null || res === void 0 ? void 0 : res.then)) {
|
|
187672
|
-
|
|
187695
|
+
_context3.next = 16;
|
|
187673
187696
|
break;
|
|
187674
187697
|
}
|
|
187675
187698
|
|
|
187676
|
-
|
|
187677
|
-
|
|
187699
|
+
_context3.prev = 5;
|
|
187700
|
+
_context3.next = 8;
|
|
187678
187701
|
return res;
|
|
187679
187702
|
|
|
187680
187703
|
case 8:
|
|
187681
|
-
newFile =
|
|
187704
|
+
newFile = _context3.sent;
|
|
187682
187705
|
uploadFile(newFile);
|
|
187683
|
-
|
|
187706
|
+
_context3.next = 15;
|
|
187684
187707
|
break;
|
|
187685
187708
|
|
|
187686
187709
|
case 12:
|
|
187687
|
-
|
|
187688
|
-
|
|
187710
|
+
_context3.prev = 12;
|
|
187711
|
+
_context3.t0 = _context3["catch"](5);
|
|
187689
187712
|
console.log('上传失败!');
|
|
187690
187713
|
|
|
187691
187714
|
case 15:
|
|
187692
|
-
return
|
|
187715
|
+
return _context3.abrupt("return");
|
|
187693
187716
|
|
|
187694
187717
|
case 16:
|
|
187695
187718
|
if (res) {
|
|
187696
|
-
|
|
187719
|
+
_context3.next = 18;
|
|
187697
187720
|
break;
|
|
187698
187721
|
}
|
|
187699
187722
|
|
|
187700
|
-
return
|
|
187723
|
+
return _context3.abrupt("return");
|
|
187701
187724
|
|
|
187702
187725
|
case 18:
|
|
187703
187726
|
// () => true
|
|
@@ -187705,14 +187728,14 @@
|
|
|
187705
187728
|
|
|
187706
187729
|
case 19:
|
|
187707
187730
|
case "end":
|
|
187708
|
-
return
|
|
187731
|
+
return _context3.stop();
|
|
187709
187732
|
}
|
|
187710
187733
|
}
|
|
187711
|
-
},
|
|
187734
|
+
}, _callee3, null, [[5, 12]]);
|
|
187712
187735
|
}));
|
|
187713
187736
|
|
|
187714
|
-
return function (
|
|
187715
|
-
return
|
|
187737
|
+
return function (_x5) {
|
|
187738
|
+
return _ref6.apply(this, arguments);
|
|
187716
187739
|
};
|
|
187717
187740
|
}(), [props.beforeUpload, getFileList, uploadFile]); // 单个文件异步校验
|
|
187718
187741
|
|
|
@@ -187774,19 +187797,19 @@
|
|
|
187774
187797
|
*/
|
|
187775
187798
|
|
|
187776
187799
|
var beforeUpload = React.useCallback( /*#__PURE__*/function () {
|
|
187777
|
-
var
|
|
187800
|
+
var _ref7 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(e) {
|
|
187778
187801
|
var files, res;
|
|
187779
|
-
return _regeneratorRuntime$1().wrap(function
|
|
187802
|
+
return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
|
|
187780
187803
|
while (1) {
|
|
187781
|
-
switch (
|
|
187804
|
+
switch (_context4.prev = _context4.next) {
|
|
187782
187805
|
case 0:
|
|
187783
187806
|
files = Array.from(e.target.files);
|
|
187784
|
-
|
|
187785
|
-
|
|
187807
|
+
_context4.prev = 1;
|
|
187808
|
+
_context4.next = 4;
|
|
187786
187809
|
return filesLoopCheck(files);
|
|
187787
187810
|
|
|
187788
187811
|
case 4:
|
|
187789
|
-
res =
|
|
187812
|
+
res = _context4.sent;
|
|
187790
187813
|
fileUploadLen.current = res.length; // 仅单文件上传时可剪裁
|
|
187791
187814
|
|
|
187792
187815
|
if (enableCrop) {
|
|
@@ -187799,43 +187822,43 @@
|
|
|
187799
187822
|
res.forEach(checkOver);
|
|
187800
187823
|
}
|
|
187801
187824
|
|
|
187802
|
-
|
|
187825
|
+
_context4.next = 13;
|
|
187803
187826
|
break;
|
|
187804
187827
|
|
|
187805
187828
|
case 9:
|
|
187806
|
-
|
|
187807
|
-
|
|
187808
|
-
console.log('文件校验未通过!',
|
|
187809
|
-
api$2.warning(
|
|
187829
|
+
_context4.prev = 9;
|
|
187830
|
+
_context4.t0 = _context4["catch"](1);
|
|
187831
|
+
console.log('文件校验未通过!', _context4.t0.message);
|
|
187832
|
+
api$2.warning(_context4.t0.message, 1.5);
|
|
187810
187833
|
|
|
187811
187834
|
case 13:
|
|
187812
187835
|
case "end":
|
|
187813
|
-
return
|
|
187836
|
+
return _context4.stop();
|
|
187814
187837
|
}
|
|
187815
187838
|
}
|
|
187816
|
-
},
|
|
187839
|
+
}, _callee4, null, [[1, 9]]);
|
|
187817
187840
|
}));
|
|
187818
187841
|
|
|
187819
|
-
return function (
|
|
187820
|
-
return
|
|
187842
|
+
return function (_x6) {
|
|
187843
|
+
return _ref7.apply(this, arguments);
|
|
187821
187844
|
};
|
|
187822
187845
|
}(), [filesLoopCheck, enableCrop, checkOver, fileUploadLen.current]); // 删除事件
|
|
187823
187846
|
|
|
187824
187847
|
var remove = React.useCallback( /*#__PURE__*/function () {
|
|
187825
|
-
var
|
|
187848
|
+
var _ref8 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5(file) {
|
|
187826
187849
|
var _props$onRemove;
|
|
187827
187850
|
|
|
187828
187851
|
var res, _getFileList, fileList;
|
|
187829
187852
|
|
|
187830
|
-
return _regeneratorRuntime$1().wrap(function
|
|
187853
|
+
return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
|
|
187831
187854
|
while (1) {
|
|
187832
|
-
switch (
|
|
187855
|
+
switch (_context5.prev = _context5.next) {
|
|
187833
187856
|
case 0:
|
|
187834
|
-
|
|
187857
|
+
_context5.next = 2;
|
|
187835
187858
|
return (_props$onRemove = props.onRemove) === null || _props$onRemove === void 0 ? void 0 : _props$onRemove.call(props, file);
|
|
187836
187859
|
|
|
187837
187860
|
case 2:
|
|
187838
|
-
res =
|
|
187861
|
+
res = _context5.sent;
|
|
187839
187862
|
|
|
187840
187863
|
if (res) {
|
|
187841
187864
|
fileList = (_getFileList = getFileList()) === null || _getFileList === void 0 ? void 0 : _getFileList.filter(function (v) {
|
|
@@ -187853,14 +187876,14 @@
|
|
|
187853
187876
|
|
|
187854
187877
|
case 4:
|
|
187855
187878
|
case "end":
|
|
187856
|
-
return
|
|
187879
|
+
return _context5.stop();
|
|
187857
187880
|
}
|
|
187858
187881
|
}
|
|
187859
|
-
},
|
|
187882
|
+
}, _callee5);
|
|
187860
187883
|
}));
|
|
187861
187884
|
|
|
187862
|
-
return function (
|
|
187863
|
-
return
|
|
187885
|
+
return function (_x7) {
|
|
187886
|
+
return _ref8.apply(this, arguments);
|
|
187864
187887
|
};
|
|
187865
187888
|
}(), [props.onRemove, getFileList, onChange, dispatch, getHasEqual]); // 点击文件链接或预览图标时的回调
|
|
187866
187889
|
|
|
@@ -188316,7 +188339,7 @@
|
|
|
188316
188339
|
var _getFileList;
|
|
188317
188340
|
|
|
188318
188341
|
return (_getFileList = getFileList()) === null || _getFileList === void 0 ? void 0 : _getFileList.sort(function (a, b) {
|
|
188319
|
-
return a.seq - b.seq;
|
|
188342
|
+
return (a === null || a === void 0 ? void 0 : a.seq) - (b === null || b === void 0 ? void 0 : b.seq);
|
|
188320
188343
|
});
|
|
188321
188344
|
}, [getFileList]);
|
|
188322
188345
|
|
|
@@ -188447,7 +188470,7 @@
|
|
|
188447
188470
|
var _getFileList;
|
|
188448
188471
|
|
|
188449
188472
|
return (_getFileList = getFileList()) === null || _getFileList === void 0 ? void 0 : _getFileList.sort(function (a, b) {
|
|
188450
|
-
return a.seq - b.seq;
|
|
188473
|
+
return (a === null || a === void 0 ? void 0 : a.seq) - (b === null || b === void 0 ? void 0 : b.seq);
|
|
188451
188474
|
});
|
|
188452
188475
|
}, [getFileList]);
|
|
188453
188476
|
var config = React.useMemo(function () {
|