@kevisual/query 0.0.25 → 0.0.26
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/query-adapter.d.ts +2 -1
- package/dist/query-adapter.js +12 -1
- package/dist/query-ai.d.ts +6 -2
- package/dist/query-ai.js +4424 -4363
- package/dist/query-browser.d.ts +4 -2
- package/dist/query-browser.js +12 -1
- package/dist/query.d.ts +4 -2
- package/dist/query.js +12 -1
- package/package.json +1 -1
package/dist/query-browser.d.ts
CHANGED
|
@@ -5,10 +5,11 @@ type Method = (typeof methods)[number];
|
|
|
5
5
|
type AdapterOpts = {
|
|
6
6
|
url?: string;
|
|
7
7
|
headers?: Record<string, string>;
|
|
8
|
-
body?: Record<string, any
|
|
8
|
+
body?: Record<string, any> | FormData;
|
|
9
9
|
timeout?: number;
|
|
10
10
|
method?: Method;
|
|
11
11
|
isBlob?: boolean;
|
|
12
|
+
isPostFile?: boolean;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
14
15
|
*
|
|
@@ -94,10 +95,11 @@ type Fn = (opts: {
|
|
|
94
95
|
type QueryOpts$1 = {
|
|
95
96
|
url?: string;
|
|
96
97
|
headers?: Record<string, string>;
|
|
97
|
-
body?: Record<string, any
|
|
98
|
+
body?: Record<string, any> | FormData;
|
|
98
99
|
timeout?: number;
|
|
99
100
|
method?: Method;
|
|
100
101
|
isBlob?: boolean;
|
|
102
|
+
isPostFile?: boolean;
|
|
101
103
|
adapter?: typeof adapter;
|
|
102
104
|
[key: string]: any;
|
|
103
105
|
};
|
package/dist/query-browser.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 isPostFile = opts.isPostFile || false; // 是否为文件上传
|
|
17
18
|
const timeout = opts.timeout || 60000 * 3; // 默认超时时间为 60s * 3
|
|
18
19
|
const timer = setTimeout(() => {
|
|
19
20
|
controller.abort();
|
|
@@ -32,6 +33,16 @@ const adapter = async (opts, overloadOpts) => {
|
|
|
32
33
|
if (isGet) {
|
|
33
34
|
url.search = new URLSearchParams(opts.body).toString();
|
|
34
35
|
}
|
|
36
|
+
let body = undefined;
|
|
37
|
+
if (isGet) {
|
|
38
|
+
body = undefined;
|
|
39
|
+
}
|
|
40
|
+
else if (isPostFile) {
|
|
41
|
+
body = opts.body; // 如果是文件上传,直接使用 FormData
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
body = JSON.stringify(opts.body); // 否则将对象转换为 JSON 字符串
|
|
45
|
+
}
|
|
35
46
|
return fetch(url, {
|
|
36
47
|
method: method.toUpperCase(),
|
|
37
48
|
headers: {
|
|
@@ -40,7 +51,7 @@ const adapter = async (opts, overloadOpts) => {
|
|
|
40
51
|
},
|
|
41
52
|
signal,
|
|
42
53
|
...overloadOpts,
|
|
43
|
-
body:
|
|
54
|
+
body: body,
|
|
44
55
|
})
|
|
45
56
|
.then(async (response) => {
|
|
46
57
|
// 获取 Content-Type 头部信息
|
package/dist/query.d.ts
CHANGED
|
@@ -5,10 +5,11 @@ type Method = (typeof methods)[number];
|
|
|
5
5
|
type AdapterOpts = {
|
|
6
6
|
url?: string;
|
|
7
7
|
headers?: Record<string, string>;
|
|
8
|
-
body?: Record<string, any
|
|
8
|
+
body?: Record<string, any> | FormData;
|
|
9
9
|
timeout?: number;
|
|
10
10
|
method?: Method;
|
|
11
11
|
isBlob?: boolean;
|
|
12
|
+
isPostFile?: boolean;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
14
15
|
*
|
|
@@ -94,10 +95,11 @@ type Fn = (opts: {
|
|
|
94
95
|
type QueryOpts = {
|
|
95
96
|
url?: string;
|
|
96
97
|
headers?: Record<string, string>;
|
|
97
|
-
body?: Record<string, any
|
|
98
|
+
body?: Record<string, any> | FormData;
|
|
98
99
|
timeout?: number;
|
|
99
100
|
method?: Method;
|
|
100
101
|
isBlob?: boolean;
|
|
102
|
+
isPostFile?: boolean;
|
|
101
103
|
adapter?: typeof adapter;
|
|
102
104
|
[key: string]: any;
|
|
103
105
|
};
|
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 isPostFile = opts.isPostFile || false; // 是否为文件上传
|
|
17
18
|
const timeout = opts.timeout || 60000 * 3; // 默认超时时间为 60s * 3
|
|
18
19
|
const timer = setTimeout(() => {
|
|
19
20
|
controller.abort();
|
|
@@ -32,6 +33,16 @@ const adapter = async (opts, overloadOpts) => {
|
|
|
32
33
|
if (isGet) {
|
|
33
34
|
url.search = new URLSearchParams(opts.body).toString();
|
|
34
35
|
}
|
|
36
|
+
let body = undefined;
|
|
37
|
+
if (isGet) {
|
|
38
|
+
body = undefined;
|
|
39
|
+
}
|
|
40
|
+
else if (isPostFile) {
|
|
41
|
+
body = opts.body; // 如果是文件上传,直接使用 FormData
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
body = JSON.stringify(opts.body); // 否则将对象转换为 JSON 字符串
|
|
45
|
+
}
|
|
35
46
|
return fetch(url, {
|
|
36
47
|
method: method.toUpperCase(),
|
|
37
48
|
headers: {
|
|
@@ -40,7 +51,7 @@ const adapter = async (opts, overloadOpts) => {
|
|
|
40
51
|
},
|
|
41
52
|
signal,
|
|
42
53
|
...overloadOpts,
|
|
43
|
-
body:
|
|
54
|
+
body: body,
|
|
44
55
|
})
|
|
45
56
|
.then(async (response) => {
|
|
46
57
|
// 获取 Content-Type 头部信息
|