@quansitech/antd-admin 1.1.33 → 1.1.34
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/lib/upload.js +18 -22
- package/package.json +1 -1
package/dist/lib/upload.js
CHANGED
|
@@ -17,16 +17,11 @@ export function customRequest(_x) {
|
|
|
17
17
|
function _customRequest() {
|
|
18
18
|
_customRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
19
19
|
var _options$file;
|
|
20
|
-
var
|
|
20
|
+
var policyRes, formData, url, key, res, err, _e$response;
|
|
21
21
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
22
22
|
while (1) switch (_context.prev = _context.next) {
|
|
23
23
|
case 0:
|
|
24
|
-
|
|
25
|
-
ext = filename.match(/(\.[^.]+)$/);
|
|
26
|
-
if (ext) {
|
|
27
|
-
filename = filename.replace(ext[1], ext[1].toLowerCase());
|
|
28
|
-
}
|
|
29
|
-
_context.next = 5;
|
|
24
|
+
_context.next = 2;
|
|
30
25
|
return http({
|
|
31
26
|
url: options.action,
|
|
32
27
|
method: 'get',
|
|
@@ -35,22 +30,22 @@ function _customRequest() {
|
|
|
35
30
|
noHandle: true
|
|
36
31
|
},
|
|
37
32
|
params: {
|
|
38
|
-
title:
|
|
33
|
+
title: options.file.name,
|
|
39
34
|
hash_id: options.file.hash_id,
|
|
40
35
|
file_type: ((_options$file = options.file) === null || _options$file === void 0 ? void 0 : _options$file.type) || ''
|
|
41
36
|
}
|
|
42
37
|
});
|
|
43
|
-
case
|
|
38
|
+
case 2:
|
|
44
39
|
policyRes = _context.sent;
|
|
45
40
|
if (!policyRes.data.status) {
|
|
46
|
-
_context.next =
|
|
41
|
+
_context.next = 6;
|
|
47
42
|
break;
|
|
48
43
|
}
|
|
49
44
|
options.onSuccess && options.onSuccess(_objectSpread(_objectSpread({}, policyRes.data), {}, {
|
|
50
45
|
url: policyRes.data.url || policyRes.data.file_url
|
|
51
46
|
}));
|
|
52
47
|
return _context.abrupt("return");
|
|
53
|
-
case
|
|
48
|
+
case 6:
|
|
54
49
|
formData = new FormData();
|
|
55
50
|
url = '';
|
|
56
51
|
if (policyRes.data.server_url) {
|
|
@@ -63,9 +58,10 @@ function _customRequest() {
|
|
|
63
58
|
formData.append(key, policyRes.data.params[key]);
|
|
64
59
|
}
|
|
65
60
|
}
|
|
61
|
+
formData.append('Content-Type', options.file.type);
|
|
66
62
|
formData.append('file', options.file);
|
|
67
|
-
_context.prev =
|
|
68
|
-
_context.next =
|
|
63
|
+
_context.prev = 12;
|
|
64
|
+
_context.next = 15;
|
|
69
65
|
return http({
|
|
70
66
|
url: url,
|
|
71
67
|
method: 'post',
|
|
@@ -80,25 +76,25 @@ function _customRequest() {
|
|
|
80
76
|
});
|
|
81
77
|
}
|
|
82
78
|
});
|
|
83
|
-
case
|
|
79
|
+
case 15:
|
|
84
80
|
res = _context.sent;
|
|
85
81
|
err = res.data.info || res.data.err_msg;
|
|
86
82
|
if (!err) {
|
|
87
|
-
_context.next =
|
|
83
|
+
_context.next = 21;
|
|
88
84
|
break;
|
|
89
85
|
}
|
|
90
86
|
message.error(err);
|
|
91
87
|
options.onError && options.onError(new Error(err), res.data);
|
|
92
88
|
return _context.abrupt("return");
|
|
93
|
-
case
|
|
89
|
+
case 21:
|
|
94
90
|
options.onSuccess && options.onSuccess(_objectSpread(_objectSpread({}, res.data), {}, {
|
|
95
91
|
url: res.data.url || res.data.file_url
|
|
96
92
|
}));
|
|
97
|
-
_context.next =
|
|
93
|
+
_context.next = 29;
|
|
98
94
|
break;
|
|
99
|
-
case
|
|
100
|
-
_context.prev =
|
|
101
|
-
_context.t0 = _context["catch"](
|
|
95
|
+
case 24:
|
|
96
|
+
_context.prev = 24;
|
|
97
|
+
_context.t0 = _context["catch"](12);
|
|
102
98
|
if (_context.t0 instanceof AxiosError) {
|
|
103
99
|
options.onError && options.onError(_context.t0, (_e$response = _context.t0.response) === null || _e$response === void 0 ? void 0 : _e$response.data);
|
|
104
100
|
}
|
|
@@ -111,11 +107,11 @@ function _customRequest() {
|
|
|
111
107
|
});
|
|
112
108
|
}
|
|
113
109
|
throw _context.t0;
|
|
114
|
-
case
|
|
110
|
+
case 29:
|
|
115
111
|
case "end":
|
|
116
112
|
return _context.stop();
|
|
117
113
|
}
|
|
118
|
-
}, _callee, null, [[
|
|
114
|
+
}, _callee, null, [[12, 24]]);
|
|
119
115
|
}));
|
|
120
116
|
return _customRequest.apply(this, arguments);
|
|
121
117
|
}
|