form-driver 0.3.2 → 0.3.4
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 +36 -22
- package/lib/m3.js +36 -22
- package/package.json +1 -1
- package/src/plugins/ossUpload/OssUpload.jsx +28 -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,25 @@ 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
|
+
r.name = ele.file.name;
|
|
20528
|
+
r.size = ele.file.size;
|
|
20529
|
+
return r;
|
|
20530
|
+
});
|
|
20531
|
+
|
|
20532
|
+
_this.changeFileList([].concat(resList, addArr));
|
|
20533
|
+
|
|
20534
|
+
_this.endUpload();
|
|
20535
|
+
}
|
|
20530
20536
|
}).catch(async function (e) {
|
|
20531
20537
|
if (e && e.name && e.name === 'cancel') {
|
|
20532
20538
|
return;
|
|
@@ -20653,6 +20659,21 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20653
20659
|
}
|
|
20654
20660
|
};
|
|
20655
20661
|
|
|
20662
|
+
_proto.startUpload = function startUpload() {
|
|
20663
|
+
this.setState({
|
|
20664
|
+
loading: true
|
|
20665
|
+
}); // 留下上传中的标记,为了实现上传中无法提交
|
|
20666
|
+
|
|
20667
|
+
localStorage["m3-plugin-ossupload-loading"] = true;
|
|
20668
|
+
};
|
|
20669
|
+
|
|
20670
|
+
_proto.endUpload = function endUpload() {
|
|
20671
|
+
this.setState({
|
|
20672
|
+
loading: false
|
|
20673
|
+
});
|
|
20674
|
+
delete localStorage["m3-plugin-ossupload-loading"];
|
|
20675
|
+
};
|
|
20676
|
+
|
|
20656
20677
|
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
20657
20678
|
window.clearInterval(this._timer); // 关闭页面的时候取消上传
|
|
20658
20679
|
|
|
@@ -20688,20 +20709,11 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20688
20709
|
var file = _ref2.file;
|
|
20689
20710
|
// 一个个上传的
|
|
20690
20711
|
console.log('customRequest->fileList:', file);
|
|
20691
|
-
|
|
20692
|
-
_this3.setState({
|
|
20693
|
-
loading: true
|
|
20694
|
-
});
|
|
20695
|
-
|
|
20696
20712
|
await _this3.upload(keyPath + "/" + file.name, file, _objectSpread$1({
|
|
20697
20713
|
progress: function progress(p, checkpoint) {
|
|
20698
20714
|
return _this3.progress(p, checkpoint, file);
|
|
20699
20715
|
}
|
|
20700
20716
|
}, multipartUploadConf));
|
|
20701
|
-
|
|
20702
|
-
_this3.setState({
|
|
20703
|
-
loading: false
|
|
20704
|
-
});
|
|
20705
20717
|
},
|
|
20706
20718
|
beforeUpload: function beforeUpload(file, fileList) {
|
|
20707
20719
|
// 这里可以拿到上传的所有文件
|
|
@@ -20734,6 +20746,8 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20734
20746
|
}),
|
|
20735
20747
|
attachmentVisible: true
|
|
20736
20748
|
});
|
|
20749
|
+
|
|
20750
|
+
_this3.startUpload();
|
|
20737
20751
|
}
|
|
20738
20752
|
};
|
|
20739
20753
|
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,25 @@ 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
|
+
r.name = ele.file.name;
|
|
20550
|
+
r.size = ele.file.size;
|
|
20551
|
+
return r;
|
|
20552
|
+
});
|
|
20553
|
+
|
|
20554
|
+
_this.changeFileList([].concat(resList, addArr));
|
|
20555
|
+
|
|
20556
|
+
_this.endUpload();
|
|
20557
|
+
}
|
|
20552
20558
|
}).catch(async function (e) {
|
|
20553
20559
|
if (e && e.name && e.name === 'cancel') {
|
|
20554
20560
|
return;
|
|
@@ -20675,6 +20681,21 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20675
20681
|
}
|
|
20676
20682
|
};
|
|
20677
20683
|
|
|
20684
|
+
_proto.startUpload = function startUpload() {
|
|
20685
|
+
this.setState({
|
|
20686
|
+
loading: true
|
|
20687
|
+
}); // 留下上传中的标记,为了实现上传中无法提交
|
|
20688
|
+
|
|
20689
|
+
localStorage["m3-plugin-ossupload-loading"] = true;
|
|
20690
|
+
};
|
|
20691
|
+
|
|
20692
|
+
_proto.endUpload = function endUpload() {
|
|
20693
|
+
this.setState({
|
|
20694
|
+
loading: false
|
|
20695
|
+
});
|
|
20696
|
+
delete localStorage["m3-plugin-ossupload-loading"];
|
|
20697
|
+
};
|
|
20698
|
+
|
|
20678
20699
|
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
20679
20700
|
window.clearInterval(this._timer); // 关闭页面的时候取消上传
|
|
20680
20701
|
|
|
@@ -20710,20 +20731,11 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20710
20731
|
var file = _ref2.file;
|
|
20711
20732
|
// 一个个上传的
|
|
20712
20733
|
console.log('customRequest->fileList:', file);
|
|
20713
|
-
|
|
20714
|
-
_this3.setState({
|
|
20715
|
-
loading: true
|
|
20716
|
-
});
|
|
20717
|
-
|
|
20718
20734
|
await _this3.upload(keyPath + "/" + file.name, file, _objectSpread$1({
|
|
20719
20735
|
progress: function progress(p, checkpoint) {
|
|
20720
20736
|
return _this3.progress(p, checkpoint, file);
|
|
20721
20737
|
}
|
|
20722
20738
|
}, multipartUploadConf));
|
|
20723
|
-
|
|
20724
|
-
_this3.setState({
|
|
20725
|
-
loading: false
|
|
20726
|
-
});
|
|
20727
20739
|
},
|
|
20728
20740
|
beforeUpload: function beforeUpload(file, fileList) {
|
|
20729
20741
|
// 这里可以拿到上传的所有文件
|
|
@@ -20756,6 +20768,8 @@ var OssUpload$1 = /*#__PURE__*/function (_Viewer) {
|
|
|
20756
20768
|
}),
|
|
20757
20769
|
attachmentVisible: true
|
|
20758
20770
|
});
|
|
20771
|
+
|
|
20772
|
+
_this3.startUpload();
|
|
20759
20773
|
}
|
|
20760
20774
|
};
|
|
20761
20775
|
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,21 @@ 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
|
+
r.name = ele.file.name
|
|
108
|
+
r.size = ele.file.size
|
|
109
|
+
return r
|
|
110
|
+
})
|
|
111
|
+
this.changeFileList([...resList, ...addArr]);
|
|
112
|
+
this.endUpload()
|
|
113
|
+
}
|
|
100
114
|
})
|
|
101
115
|
.catch(async e => {
|
|
102
116
|
if (e && e.name && e.name === 'cancel') {
|
|
@@ -163,12 +177,10 @@ class OssUpload extends Viewer {
|
|
|
163
177
|
customRequest: async ({ file }) => {
|
|
164
178
|
// 一个个上传的
|
|
165
179
|
console.log('customRequest->fileList:', file)
|
|
166
|
-
this.setState({ loading: true });
|
|
167
180
|
await this.upload(`${keyPath}/${file.name}`, file, {
|
|
168
181
|
progress: (p, checkpoint) => this.progress(p, checkpoint, file),
|
|
169
182
|
...multipartUploadConf
|
|
170
183
|
})
|
|
171
|
-
this.setState({ loading: false });
|
|
172
184
|
},
|
|
173
185
|
beforeUpload: (file, fileList) => {
|
|
174
186
|
// 这里可以拿到上传的所有文件
|
|
@@ -181,14 +193,16 @@ class OssUpload extends Viewer {
|
|
|
181
193
|
message.error(`文件大小超过${maxSize}MB,请压缩后上传`);
|
|
182
194
|
return false
|
|
183
195
|
}
|
|
184
|
-
if (checkSame &&
|
|
196
|
+
if (checkSame && resList.findIndex(e => e.name == file.name) >= 0) {
|
|
185
197
|
message.error(`存在同名文件,无法上传该文件`);
|
|
186
198
|
return false
|
|
187
199
|
}
|
|
188
200
|
this.setState({
|
|
189
|
-
fileListStatus: fileList.map(item => ({
|
|
201
|
+
fileListStatus: fileList.map(item => ({file: item, count: 1, percent: 0})),
|
|
190
202
|
attachmentVisible: true,
|
|
191
203
|
})
|
|
204
|
+
|
|
205
|
+
this.startUpload()
|
|
192
206
|
}
|
|
193
207
|
};
|
|
194
208
|
|