@base-web-kits/base-tools-web 1.2.10 → 1.3.0
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/base-tools-web.umd.global.js +7 -7
- package/dist/base-tools-web.umd.global.js.map +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/network/uploadFile.d.ts +2 -2
- package/dist/network/uploadFile.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/web/network/uploadFile.ts +9 -9
package/dist/index.d.cts
CHANGED
|
@@ -517,8 +517,8 @@ type UploadFileOption = {
|
|
|
517
517
|
name?: string;
|
|
518
518
|
/** 请求头 */
|
|
519
519
|
header?: Record<string, string | number>;
|
|
520
|
-
/**
|
|
521
|
-
|
|
520
|
+
/** 请求参数 */
|
|
521
|
+
data?: Record<string, string | number>;
|
|
522
522
|
/** 超时时间,单位 ms,默认 0(不超时) */
|
|
523
523
|
timeout?: number;
|
|
524
524
|
};
|
package/dist/index.js
CHANGED
|
@@ -1343,7 +1343,7 @@ function upload(option, config) {
|
|
|
1343
1343
|
return new Promise((resolve, reject) => {
|
|
1344
1344
|
var _a;
|
|
1345
1345
|
const xhr = new XMLHttpRequest();
|
|
1346
|
-
const { url, file, name = "file", header,
|
|
1346
|
+
const { url, file, name = "file", header, data, timeout = 0 } = option;
|
|
1347
1347
|
const fail = (error) => reject(error);
|
|
1348
1348
|
const success = (responseText) => {
|
|
1349
1349
|
resolve(responseText);
|
|
@@ -1382,14 +1382,14 @@ function upload(option, config) {
|
|
|
1382
1382
|
});
|
|
1383
1383
|
}
|
|
1384
1384
|
xhr.timeout = timeout;
|
|
1385
|
-
const
|
|
1386
|
-
if (
|
|
1387
|
-
Object.entries(
|
|
1388
|
-
if (v !== void 0 && v !== null)
|
|
1385
|
+
const formData = new FormData();
|
|
1386
|
+
if (data) {
|
|
1387
|
+
Object.entries(data).forEach(([k, v]) => {
|
|
1388
|
+
if (v !== void 0 && v !== null) formData.append(k, String(v));
|
|
1389
1389
|
});
|
|
1390
1390
|
}
|
|
1391
|
-
|
|
1392
|
-
xhr.send(
|
|
1391
|
+
formData.append(name, file);
|
|
1392
|
+
xhr.send(formData);
|
|
1393
1393
|
});
|
|
1394
1394
|
}
|
|
1395
1395
|
function uploadFile(option, config) {
|