@whitesev/utils 2.4.0 → 2.4.2

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.
@@ -1,4 +1,4 @@
1
- import type { HttpxHookErrorData, HttpxRequestOption, HttpxRequestOptionConfig, HttpxResponse, HttpxResponseData } from "./types/Httpx";
1
+ import type { HttpxHookErrorData, HttpxRequestOption, HttpxRequestOptionConfig, HttpxResponse, HttpxResponseData, HttpxPromise } from "./types/Httpx";
2
2
  declare class Httpx {
3
3
  #private;
4
4
  private GM_Api;
@@ -1314,3 +1314,10 @@ export declare interface HttpxHookErrorData {
1314
1314
  /** 请求的配置 */
1315
1315
  details: HttpxRequestOption;
1316
1316
  }
1317
+
1318
+ /**
1319
+ * httpx的自定义Promise,包含额外函数
1320
+ */
1321
+ export declare interface HttpxPromise<T> extends Promise<T> {
1322
+ abort: () => void;
1323
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
package/src/Httpx.ts CHANGED
@@ -6,6 +6,7 @@ import type {
6
6
  HttpxRequestOptionConfig,
7
7
  HttpxResponse,
8
8
  HttpxResponseData,
9
+ HttpxPromise,
9
10
  } from "./types/Httpx";
10
11
  import { Utils } from "./Utils";
11
12
  import { GenerateUUID } from "./UtilsCommon";
@@ -544,10 +545,8 @@ class Httpx {
544
545
  });
545
546
  if (ContentTypeIndex !== -1) {
546
547
  let ContentTypeKey = headersKeyList[ContentTypeIndex];
548
+ let ContentType = requestOption.headers[ContentTypeKey] as string;
547
549
  // 设置了Content-Type
548
- let ContentType = requestOption.headers[
549
- ContentTypeIndex
550
- ].toLowerCase() as string;
551
550
  if (ContentType.includes("application/json")) {
552
551
  // application/json
553
552
  if (requestOption.data instanceof FormData) {
package/src/Utils.ts CHANGED
@@ -29,7 +29,7 @@ class Utils {
29
29
  this.windowApi = new WindowApi(option);
30
30
  }
31
31
  /** 版本号 */
32
- version = "2024.10.28";
32
+ version = "2024.10.29";
33
33
 
34
34
  /**
35
35
  * 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
@@ -1314,3 +1314,10 @@ export declare interface HttpxHookErrorData {
1314
1314
  /** 请求的配置 */
1315
1315
  details: HttpxRequestOption;
1316
1316
  }
1317
+
1318
+ /**
1319
+ * httpx的自定义Promise,包含额外函数
1320
+ */
1321
+ export declare interface HttpxPromise<T> extends Promise<T> {
1322
+ abort: () => void;
1323
+ }