form-driver 0.3.2 → 0.3.3
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/m3.js +1 -1
- package/es/m3.js +34 -22
- package/lib/m3.js +34 -22
- package/package.json +1 -1
- package/src/plugins/ossUpload/OssUpload.jsx +26 -14
package/es/m3.js
CHANGED
|
@@ -20497,9 +20497,7 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20497
20497
|
_this.cancleUpload = function () {
|
|
20498
20498
|
if (_this._client) _this._client.cancel();
|
|
20499
20499
|
|
|
20500
|
-
_this.
|
|
20501
|
-
loading: false
|
|
20502
|
-
});
|
|
20500
|
+
_this.endUpload();
|
|
20503
20501
|
};
|
|
20504
20502
|
|
|
20505
20503
|
_this.onRemove = function (file) {
|
|
@@ -20516,17 +20514,23 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20516
20514
|
var multipartUploadConf = _this.options.multipartUploadConf;
|
|
20517
20515
|
var _this$state = _this.state,
|
|
20518
20516
|
fileListStatus = _this$state.fileListStatus,
|
|
20519
|
-
resList = _this$state.resList
|
|
20517
|
+
resList = _this$state.resList,
|
|
20518
|
+
keyPath = _this$state.keyPath;
|
|
20520
20519
|
return _this._client.multipartUpload(name, file, config).then(function (res) {
|
|
20521
|
-
|
|
20522
|
-
|
|
20523
|
-
|
|
20524
|
-
|
|
20525
|
-
|
|
20526
|
-
|
|
20527
|
-
|
|
20528
|
-
|
|
20529
|
-
|
|
20520
|
+
// 当所有文件上传完成后,记录了到结果,并取消loading
|
|
20521
|
+
if (fileListStatus.every(function (e) {
|
|
20522
|
+
return e.percent == 100;
|
|
20523
|
+
})) {
|
|
20524
|
+
var addArr = fileListStatus.map(function (ele) {
|
|
20525
|
+
var r = ele.file;
|
|
20526
|
+
r.keyPath = keyPath + "/" + ele.file.name;
|
|
20527
|
+
return r;
|
|
20528
|
+
});
|
|
20529
|
+
|
|
20530
|
+
_this.changeFileList([].concat(resList, addArr));
|
|
20531
|
+
|
|
20532
|
+
_this.endUpload();
|
|
20533
|
+
}
|
|
20530
20534
|
}).catch(async function (e) {
|
|
20531
20535
|
if (e && e.name && e.name === 'cancel') {
|
|
20532
20536
|
return;
|
|
@@ -20653,6 +20657,21 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20653
20657
|
}
|
|
20654
20658
|
};
|
|
20655
20659
|
|
|
20660
|
+
_proto.startUpload = function startUpload() {
|
|
20661
|
+
this.setState({
|
|
20662
|
+
loading: true
|
|
20663
|
+
}); // 留下上传中的标记,为了实现上传中无法提交
|
|
20664
|
+
|
|
20665
|
+
localStorage["m3-plugin-ossupload-loading"] = true;
|
|
20666
|
+
};
|
|
20667
|
+
|
|
20668
|
+
_proto.endUpload = function endUpload() {
|
|
20669
|
+
this.setState({
|
|
20670
|
+
loading: false
|
|
20671
|
+
});
|
|
20672
|
+
delete localStorage["m3-plugin-ossupload-loading"];
|
|
20673
|
+
};
|
|
20674
|
+
|
|
20656
20675
|
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
20657
20676
|
window.clearInterval(this._timer); // 关闭页面的时候取消上传
|
|
20658
20677
|
|
|
@@ -20688,20 +20707,11 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20688
20707
|
var file = _ref2.file;
|
|
20689
20708
|
// 一个个上传的
|
|
20690
20709
|
console.log('customRequest->fileList:', file);
|
|
20691
|
-
|
|
20692
|
-
_this3.setState({
|
|
20693
|
-
loading: true
|
|
20694
|
-
});
|
|
20695
|
-
|
|
20696
20710
|
await _this3.upload(keyPath + "/" + file.name, file, _objectSpread$1({
|
|
20697
20711
|
progress: function progress(p, checkpoint) {
|
|
20698
20712
|
return _this3.progress(p, checkpoint, file);
|
|
20699
20713
|
}
|
|
20700
20714
|
}, multipartUploadConf));
|
|
20701
|
-
|
|
20702
|
-
_this3.setState({
|
|
20703
|
-
loading: false
|
|
20704
|
-
});
|
|
20705
20715
|
},
|
|
20706
20716
|
beforeUpload: function beforeUpload(file, fileList) {
|
|
20707
20717
|
// 这里可以拿到上传的所有文件
|
|
@@ -20734,6 +20744,8 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20734
20744
|
}),
|
|
20735
20745
|
attachmentVisible: true
|
|
20736
20746
|
});
|
|
20747
|
+
|
|
20748
|
+
_this3.startUpload();
|
|
20737
20749
|
}
|
|
20738
20750
|
};
|
|
20739
20751
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Upload, _extends({
|
package/lib/m3.js
CHANGED
|
@@ -20519,9 +20519,7 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20519
20519
|
_this.cancleUpload = function () {
|
|
20520
20520
|
if (_this._client) _this._client.cancel();
|
|
20521
20521
|
|
|
20522
|
-
_this.
|
|
20523
|
-
loading: false
|
|
20524
|
-
});
|
|
20522
|
+
_this.endUpload();
|
|
20525
20523
|
};
|
|
20526
20524
|
|
|
20527
20525
|
_this.onRemove = function (file) {
|
|
@@ -20538,17 +20536,23 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20538
20536
|
var multipartUploadConf = _this.options.multipartUploadConf;
|
|
20539
20537
|
var _this$state = _this.state,
|
|
20540
20538
|
fileListStatus = _this$state.fileListStatus,
|
|
20541
|
-
resList = _this$state.resList
|
|
20539
|
+
resList = _this$state.resList,
|
|
20540
|
+
keyPath = _this$state.keyPath;
|
|
20542
20541
|
return _this._client.multipartUpload(name, file, config).then(function (res) {
|
|
20543
|
-
|
|
20544
|
-
|
|
20545
|
-
|
|
20546
|
-
|
|
20547
|
-
|
|
20548
|
-
|
|
20549
|
-
|
|
20550
|
-
|
|
20551
|
-
|
|
20542
|
+
// 当所有文件上传完成后,记录了到结果,并取消loading
|
|
20543
|
+
if (fileListStatus.every(function (e) {
|
|
20544
|
+
return e.percent == 100;
|
|
20545
|
+
})) {
|
|
20546
|
+
var addArr = fileListStatus.map(function (ele) {
|
|
20547
|
+
var r = ele.file;
|
|
20548
|
+
r.keyPath = keyPath + "/" + ele.file.name;
|
|
20549
|
+
return r;
|
|
20550
|
+
});
|
|
20551
|
+
|
|
20552
|
+
_this.changeFileList([].concat(resList, addArr));
|
|
20553
|
+
|
|
20554
|
+
_this.endUpload();
|
|
20555
|
+
}
|
|
20552
20556
|
}).catch(async function (e) {
|
|
20553
20557
|
if (e && e.name && e.name === 'cancel') {
|
|
20554
20558
|
return;
|
|
@@ -20675,6 +20679,21 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20675
20679
|
}
|
|
20676
20680
|
};
|
|
20677
20681
|
|
|
20682
|
+
_proto.startUpload = function startUpload() {
|
|
20683
|
+
this.setState({
|
|
20684
|
+
loading: true
|
|
20685
|
+
}); // 留下上传中的标记,为了实现上传中无法提交
|
|
20686
|
+
|
|
20687
|
+
localStorage["m3-plugin-ossupload-loading"] = true;
|
|
20688
|
+
};
|
|
20689
|
+
|
|
20690
|
+
_proto.endUpload = function endUpload() {
|
|
20691
|
+
this.setState({
|
|
20692
|
+
loading: false
|
|
20693
|
+
});
|
|
20694
|
+
delete localStorage["m3-plugin-ossupload-loading"];
|
|
20695
|
+
};
|
|
20696
|
+
|
|
20678
20697
|
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
20679
20698
|
window.clearInterval(this._timer); // 关闭页面的时候取消上传
|
|
20680
20699
|
|
|
@@ -20710,20 +20729,11 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20710
20729
|
var file = _ref2.file;
|
|
20711
20730
|
// 一个个上传的
|
|
20712
20731
|
console.log('customRequest->fileList:', file);
|
|
20713
|
-
|
|
20714
|
-
_this3.setState({
|
|
20715
|
-
loading: true
|
|
20716
|
-
});
|
|
20717
|
-
|
|
20718
20732
|
await _this3.upload(keyPath + "/" + file.name, file, _objectSpread$1({
|
|
20719
20733
|
progress: function progress(p, checkpoint) {
|
|
20720
20734
|
return _this3.progress(p, checkpoint, file);
|
|
20721
20735
|
}
|
|
20722
20736
|
}, multipartUploadConf));
|
|
20723
|
-
|
|
20724
|
-
_this3.setState({
|
|
20725
|
-
loading: false
|
|
20726
|
-
});
|
|
20727
20737
|
},
|
|
20728
20738
|
beforeUpload: function beforeUpload(file, fileList) {
|
|
20729
20739
|
// 这里可以拿到上传的所有文件
|
|
@@ -20756,6 +20766,8 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20756
20766
|
}),
|
|
20757
20767
|
attachmentVisible: true
|
|
20758
20768
|
});
|
|
20769
|
+
|
|
20770
|
+
_this3.startUpload();
|
|
20759
20771
|
}
|
|
20760
20772
|
};
|
|
20761
20773
|
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(antd.Upload, _extends__default["default"]({
|
package/package.json
CHANGED
|
@@ -67,7 +67,18 @@ class OssUpload extends Viewer {
|
|
|
67
67
|
|
|
68
68
|
cancleUpload = () => {
|
|
69
69
|
if (this._client) this._client.cancel();
|
|
70
|
+
this.endUpload()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
startUpload() {
|
|
74
|
+
this.setState({ loading: true });
|
|
75
|
+
// 留下上传中的标记,为了实现上传中无法提交
|
|
76
|
+
localStorage["m3-plugin-ossupload-loading"] = true
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
endUpload() {
|
|
70
80
|
this.setState({ loading: false });
|
|
81
|
+
delete localStorage["m3-plugin-ossupload-loading"]
|
|
71
82
|
}
|
|
72
83
|
|
|
73
84
|
componentWillUnmount() {
|
|
@@ -85,18 +96,19 @@ class OssUpload extends Viewer {
|
|
|
85
96
|
// 自动断点续传
|
|
86
97
|
upload = (name, file, config) => {
|
|
87
98
|
const { multipartUploadConf } = this.options
|
|
88
|
-
const { fileListStatus, resList } = this.state
|
|
99
|
+
const { fileListStatus, resList, keyPath } = this.state
|
|
89
100
|
return this._client.multipartUpload(name, file, config)
|
|
90
101
|
.then(res => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
// 当所有文件上传完成后,记录了到结果,并取消loading
|
|
103
|
+
if (fileListStatus.every(e => e.percent == 100)) {
|
|
104
|
+
const addArr = fileListStatus.map(ele => {
|
|
105
|
+
const r = ele.file
|
|
106
|
+
r.keyPath = `${keyPath}/${ele.file.name}`
|
|
107
|
+
return r
|
|
108
|
+
})
|
|
109
|
+
this.changeFileList([...resList, ...addArr]);
|
|
110
|
+
this.endUpload()
|
|
111
|
+
}
|
|
100
112
|
})
|
|
101
113
|
.catch(async e => {
|
|
102
114
|
if (e && e.name && e.name === 'cancel') {
|
|
@@ -163,12 +175,10 @@ class OssUpload extends Viewer {
|
|
|
163
175
|
customRequest: async ({ file }) => {
|
|
164
176
|
// 一个个上传的
|
|
165
177
|
console.log('customRequest->fileList:', file)
|
|
166
|
-
this.setState({ loading: true });
|
|
167
178
|
await this.upload(`${keyPath}/${file.name}`, file, {
|
|
168
179
|
progress: (p, checkpoint) => this.progress(p, checkpoint, file),
|
|
169
180
|
...multipartUploadConf
|
|
170
181
|
})
|
|
171
|
-
this.setState({ loading: false });
|
|
172
182
|
},
|
|
173
183
|
beforeUpload: (file, fileList) => {
|
|
174
184
|
// 这里可以拿到上传的所有文件
|
|
@@ -181,14 +191,16 @@ class OssUpload extends Viewer {
|
|
|
181
191
|
message.error(`文件大小超过${maxSize}MB,请压缩后上传`);
|
|
182
192
|
return false
|
|
183
193
|
}
|
|
184
|
-
if (checkSame &&
|
|
194
|
+
if (checkSame && resList.findIndex(e => e.name == file.name) >= 0) {
|
|
185
195
|
message.error(`存在同名文件,无法上传该文件`);
|
|
186
196
|
return false
|
|
187
197
|
}
|
|
188
198
|
this.setState({
|
|
189
|
-
fileListStatus: fileList.map(item => ({
|
|
199
|
+
fileListStatus: fileList.map(item => ({file: item, count: 1, percent: 0})),
|
|
190
200
|
attachmentVisible: true,
|
|
191
201
|
})
|
|
202
|
+
|
|
203
|
+
this.startUpload()
|
|
192
204
|
}
|
|
193
205
|
};
|
|
194
206
|
|