@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/index.d.cts CHANGED
@@ -517,8 +517,8 @@ type UploadFileOption = {
517
517
  name?: string;
518
518
  /** 请求头 */
519
519
  header?: Record<string, string | number>;
520
- /** 额外的formData参数 */
521
- formData?: Record<string, string | number>;
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, formData, timeout = 0 } = option;
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 data = new FormData();
1386
- if (formData) {
1387
- Object.entries(formData).forEach(([k, v]) => {
1388
- if (v !== void 0 && v !== null) data.append(k, String(v));
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
- data.append(name, file);
1392
- xhr.send(data);
1391
+ formData.append(name, file);
1392
+ xhr.send(formData);
1393
1393
  });
1394
1394
  }
1395
1395
  function uploadFile(option, config) {