@kevisual/query 0.0.27 → 0.0.28

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.
@@ -7,6 +7,7 @@ type AdapterOpts = {
7
7
  timeout?: number;
8
8
  method?: Method;
9
9
  isBlob?: boolean;
10
+ isText?: boolean;
10
11
  isPostFile?: boolean;
11
12
  };
12
13
  declare const isTextForContentType: (contentType: string | null) => boolean;
@@ -15,6 +15,7 @@ const adapter = async (opts = {}, overloadOpts) => {
15
15
  const controller = new AbortController();
16
16
  const signal = controller.signal;
17
17
  const isBlob = opts.isBlob || false; // 是否返回 Blob 对象
18
+ const isText = opts.isText || false; // 是否返回文本内容
18
19
  const isPostFile = opts.isPostFile || false; // 是否为文件上传
19
20
  const timeout = opts.timeout || 60000 * 3; // 默认超时时间为 60s * 3
20
21
  const timer = setTimeout(() => {
@@ -64,7 +65,7 @@ const adapter = async (opts = {}, overloadOpts) => {
64
65
  }
65
66
  const isJson = contentType && contentType.includes('application/json');
66
67
  // 判断返回的数据类型
67
- if (isJson) {
68
+ if (isJson && !isText) {
68
69
  return await response.json(); // 解析为 JSON
69
70
  }
70
71
  else if (isTextForContentType(contentType)) {
@@ -9,6 +9,7 @@ type AdapterOpts = {
9
9
  timeout?: number;
10
10
  method?: Method;
11
11
  isBlob?: boolean;
12
+ isText?: boolean;
12
13
  isPostFile?: boolean;
13
14
  };
14
15
  /**
@@ -14,6 +14,7 @@ const adapter = async (opts = {}, overloadOpts) => {
14
14
  const controller = new AbortController();
15
15
  const signal = controller.signal;
16
16
  const isBlob = opts.isBlob || false; // 是否返回 Blob 对象
17
+ const isText = opts.isText || false; // 是否返回文本内容
17
18
  const isPostFile = opts.isPostFile || false; // 是否为文件上传
18
19
  const timeout = opts.timeout || 60000 * 3; // 默认超时时间为 60s * 3
19
20
  const timer = setTimeout(() => {
@@ -63,7 +64,7 @@ const adapter = async (opts = {}, overloadOpts) => {
63
64
  }
64
65
  const isJson = contentType && contentType.includes('application/json');
65
66
  // 判断返回的数据类型
66
- if (isJson) {
67
+ if (isJson && !isText) {
67
68
  return await response.json(); // 解析为 JSON
68
69
  }
69
70
  else if (isTextForContentType(contentType)) {
package/dist/query.d.ts CHANGED
@@ -9,6 +9,7 @@ type AdapterOpts = {
9
9
  timeout?: number;
10
10
  method?: Method;
11
11
  isBlob?: boolean;
12
+ isText?: boolean;
12
13
  isPostFile?: boolean;
13
14
  };
14
15
  /**
package/dist/query.js CHANGED
@@ -14,6 +14,7 @@ const adapter = async (opts = {}, overloadOpts) => {
14
14
  const controller = new AbortController();
15
15
  const signal = controller.signal;
16
16
  const isBlob = opts.isBlob || false; // 是否返回 Blob 对象
17
+ const isText = opts.isText || false; // 是否返回文本内容
17
18
  const isPostFile = opts.isPostFile || false; // 是否为文件上传
18
19
  const timeout = opts.timeout || 60000 * 3; // 默认超时时间为 60s * 3
19
20
  const timer = setTimeout(() => {
@@ -63,7 +64,7 @@ const adapter = async (opts = {}, overloadOpts) => {
63
64
  }
64
65
  const isJson = contentType && contentType.includes('application/json');
65
66
  // 判断返回的数据类型
66
- if (isJson) {
67
+ if (isJson && !isText) {
67
68
  return await response.json(); // 解析为 JSON
68
69
  }
69
70
  else if (isTextForContentType(contentType)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/query",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",