ds-web-all 1.0.1-beta.95 → 1.0.1-beta.97
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.
|
@@ -112,13 +112,16 @@ var BaseUpload = function BaseUpload(_ref) {
|
|
|
112
112
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
113
113
|
while (1) switch (_context.prev = _context.next) {
|
|
114
114
|
case 0:
|
|
115
|
+
console.log(222);
|
|
115
116
|
setLoading(true);
|
|
116
117
|
formData = new FormData();
|
|
117
118
|
uploadFiles.forEach(function (file) {
|
|
118
119
|
formData.append("file", file);
|
|
120
|
+
formData.append("file", file);
|
|
119
121
|
});
|
|
120
|
-
|
|
121
|
-
_context.
|
|
122
|
+
console.log(formData);
|
|
123
|
+
_context.prev = 5;
|
|
124
|
+
_context.next = 8;
|
|
122
125
|
return (0, _fileRequest.default)(requestUrl, {
|
|
123
126
|
method: 'POST',
|
|
124
127
|
headers: {
|
|
@@ -127,33 +130,42 @@ var BaseUpload = function BaseUpload(_ref) {
|
|
|
127
130
|
data: formData,
|
|
128
131
|
timeout: requestTimeout
|
|
129
132
|
});
|
|
130
|
-
case
|
|
133
|
+
case 8:
|
|
131
134
|
res = _context.sent;
|
|
132
135
|
onFinish(res);
|
|
133
|
-
_context.next =
|
|
136
|
+
_context.next = 18;
|
|
134
137
|
break;
|
|
135
|
-
case
|
|
136
|
-
_context.prev =
|
|
137
|
-
_context.t0 = _context["catch"](
|
|
138
|
+
case 12:
|
|
139
|
+
_context.prev = 12;
|
|
140
|
+
_context.t0 = _context["catch"](5);
|
|
138
141
|
errorMessage = (_context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$response = _context.t0.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message) || (_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) || defaultErrorMsg;
|
|
139
142
|
_message2.default.error(errorMessage);
|
|
140
143
|
onError === null || onError === void 0 ? void 0 : onError(_context.t0);
|
|
141
144
|
console.error('Upload error:', _context.t0);
|
|
142
|
-
case
|
|
143
|
-
_context.prev =
|
|
145
|
+
case 18:
|
|
146
|
+
_context.prev = 18;
|
|
144
147
|
setLoading(false);
|
|
145
|
-
return _context.finish(
|
|
146
|
-
case
|
|
148
|
+
return _context.finish(18);
|
|
149
|
+
case 21:
|
|
147
150
|
case "end":
|
|
148
151
|
return _context.stop();
|
|
149
152
|
}
|
|
150
|
-
}, _callee, null, [[
|
|
153
|
+
}, _callee, null, [[5, 12, 18, 21]]);
|
|
151
154
|
}));
|
|
152
155
|
return function customRequest() {
|
|
153
156
|
return _ref2.apply(this, arguments);
|
|
154
157
|
};
|
|
155
158
|
}();
|
|
156
159
|
var beforeUpload = function beforeUpload(file, FileList) {
|
|
160
|
+
var reg = new RegExp("(".concat(_accept.split(',').map(function (el) {
|
|
161
|
+
return el.replace(/^\./, '\\.');
|
|
162
|
+
}).join('|'), ")$"));
|
|
163
|
+
if (_accept && !reg.test(file.name || '')) {
|
|
164
|
+
_message2.default.error("\u4EC5\u652F\u6301".concat(_accept.split(',').map(function (el) {
|
|
165
|
+
return el.replace(/^\./, '');
|
|
166
|
+
}).join('、'), "\u683C\u5F0F\u6587\u4EF6"));
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
157
169
|
setUploadFiles(FileList);
|
|
158
170
|
return false;
|
|
159
171
|
};
|
|
@@ -177,37 +177,50 @@ var uploadFIle = function uploadFIle(_ref) {
|
|
|
177
177
|
};
|
|
178
178
|
var beforeUpload = /*#__PURE__*/function () {
|
|
179
179
|
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
|
|
180
|
-
var size, type, fileDuration;
|
|
180
|
+
var reg, errMsg, size, type, fileDuration;
|
|
181
181
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
182
182
|
while (1) switch (_context.prev = _context.next) {
|
|
183
183
|
case 0:
|
|
184
|
+
reg = new RegExp("(".concat((_accept || '').split(',').map(function (el) {
|
|
185
|
+
return el.replace(/^\./, '\\.');
|
|
186
|
+
}).join('|'), ")$"));
|
|
187
|
+
if (!(_accept && !reg.test(file.name || ''))) {
|
|
188
|
+
_context.next = 5;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
errMsg = "\u4EC5\u652F\u6301".concat(_accept.split(',').map(function (el) {
|
|
192
|
+
return el.replace(/^\./, '');
|
|
193
|
+
}).join('、'), "\u683C\u5F0F\u6587\u4EF6");
|
|
194
|
+
_message2.default.error(errMsg);
|
|
195
|
+
throw new Error(errMsg);
|
|
196
|
+
case 5:
|
|
184
197
|
size = file.size, type = file.type;
|
|
185
198
|
if (!(size > maxSize * 1024 * 1024)) {
|
|
186
|
-
_context.next =
|
|
199
|
+
_context.next = 9;
|
|
187
200
|
break;
|
|
188
201
|
}
|
|
189
202
|
_message2.default.error("\u4E0A\u4F20\u6587\u4EF6\u4E0D\u5F97\u8D85\u8FC7".concat(maxSize, "M"));
|
|
190
203
|
throw new Error("\u4E0A\u4F20\u6587\u4EF6\u4E0D\u5F97\u8D85\u8FC7".concat(maxSize, "M"));
|
|
191
|
-
case
|
|
204
|
+
case 9:
|
|
192
205
|
if (maxCount * 1 === 1) {
|
|
193
206
|
setGroupId(0);
|
|
194
207
|
}
|
|
195
208
|
if (!/^video\//.test(type)) {
|
|
196
|
-
_context.next =
|
|
209
|
+
_context.next = 17;
|
|
197
210
|
break;
|
|
198
211
|
}
|
|
199
|
-
_context.next =
|
|
212
|
+
_context.next = 13;
|
|
200
213
|
return (0, _util.getVideoDuration)(file);
|
|
201
|
-
case
|
|
214
|
+
case 13:
|
|
202
215
|
fileDuration = _context.sent;
|
|
203
216
|
setDuration(fileDuration);
|
|
204
|
-
_context.next =
|
|
217
|
+
_context.next = 18;
|
|
205
218
|
break;
|
|
206
|
-
case
|
|
219
|
+
case 17:
|
|
207
220
|
setDuration(0);
|
|
208
|
-
case
|
|
221
|
+
case 18:
|
|
209
222
|
return _context.abrupt("return", file);
|
|
210
|
-
case
|
|
223
|
+
case 19:
|
|
211
224
|
case "end":
|
|
212
225
|
return _context.stop();
|
|
213
226
|
}
|