@kevisual/query 0.0.35 → 0.0.37
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.js +15 -3
- package/dist/query-browser.js +15 -3
- package/dist/query.js +15 -3
- package/package.json +3 -4
- package/src/adapter.ts +15 -3
package/dist/query-adapter.js
CHANGED
|
@@ -34,16 +34,28 @@ const adapter = async (opts = {}, overloadOpts) => {
|
|
|
34
34
|
url = new URL(opts.url);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
origin = window?.location?.origin || 'http://localhost:
|
|
37
|
+
origin = window?.location?.origin || 'http://localhost:51515';
|
|
38
38
|
url = new URL(opts.url, origin);
|
|
39
39
|
}
|
|
40
40
|
const isGet = method === 'GET';
|
|
41
41
|
if (isGet) {
|
|
42
|
-
|
|
42
|
+
let searchParams = new URLSearchParams(opts.body);
|
|
43
|
+
url.search = searchParams.toString();
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
const params = opts.params || {};
|
|
46
|
-
|
|
47
|
+
const searchParams = new URLSearchParams(params);
|
|
48
|
+
if (typeof opts.body === 'object' && opts.body !== null) {
|
|
49
|
+
// 浏览器环境下,自动将 body 中的 path 和 key 提取到查询参数中, 更容易排查问题
|
|
50
|
+
let body = opts.body || {};
|
|
51
|
+
if (!params.path && body?.path) {
|
|
52
|
+
searchParams.set('path', body.path);
|
|
53
|
+
if (body?.key) {
|
|
54
|
+
searchParams.set('key', body.key);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
url.search = searchParams.toString();
|
|
47
59
|
}
|
|
48
60
|
let body = undefined;
|
|
49
61
|
if (isGet) {
|
package/dist/query-browser.js
CHANGED
|
@@ -33,16 +33,28 @@ const adapter = async (opts = {}, overloadOpts) => {
|
|
|
33
33
|
url = new URL(opts.url);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
origin = window?.location?.origin || 'http://localhost:
|
|
36
|
+
origin = window?.location?.origin || 'http://localhost:51515';
|
|
37
37
|
url = new URL(opts.url, origin);
|
|
38
38
|
}
|
|
39
39
|
const isGet = method === 'GET';
|
|
40
40
|
if (isGet) {
|
|
41
|
-
|
|
41
|
+
let searchParams = new URLSearchParams(opts.body);
|
|
42
|
+
url.search = searchParams.toString();
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
45
|
const params = opts.params || {};
|
|
45
|
-
|
|
46
|
+
const searchParams = new URLSearchParams(params);
|
|
47
|
+
if (typeof opts.body === 'object' && opts.body !== null) {
|
|
48
|
+
// 浏览器环境下,自动将 body 中的 path 和 key 提取到查询参数中, 更容易排查问题
|
|
49
|
+
let body = opts.body || {};
|
|
50
|
+
if (!params.path && body?.path) {
|
|
51
|
+
searchParams.set('path', body.path);
|
|
52
|
+
if (body?.key) {
|
|
53
|
+
searchParams.set('key', body.key);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
url.search = searchParams.toString();
|
|
46
58
|
}
|
|
47
59
|
let body = undefined;
|
|
48
60
|
if (isGet) {
|
package/dist/query.js
CHANGED
|
@@ -33,16 +33,28 @@ const adapter = async (opts = {}, overloadOpts) => {
|
|
|
33
33
|
url = new URL(opts.url);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
origin = window?.location?.origin || 'http://localhost:
|
|
36
|
+
origin = window?.location?.origin || 'http://localhost:51515';
|
|
37
37
|
url = new URL(opts.url, origin);
|
|
38
38
|
}
|
|
39
39
|
const isGet = method === 'GET';
|
|
40
40
|
if (isGet) {
|
|
41
|
-
|
|
41
|
+
let searchParams = new URLSearchParams(opts.body);
|
|
42
|
+
url.search = searchParams.toString();
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
45
|
const params = opts.params || {};
|
|
45
|
-
|
|
46
|
+
const searchParams = new URLSearchParams(params);
|
|
47
|
+
if (typeof opts.body === 'object' && opts.body !== null) {
|
|
48
|
+
// 浏览器环境下,自动将 body 中的 path 和 key 提取到查询参数中, 更容易排查问题
|
|
49
|
+
let body = opts.body || {};
|
|
50
|
+
if (!params.path && body?.path) {
|
|
51
|
+
searchParams.set('path', body.path);
|
|
52
|
+
if (body?.key) {
|
|
53
|
+
searchParams.set('key', body.key);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
url.search = searchParams.toString();
|
|
46
58
|
}
|
|
47
59
|
let body = undefined;
|
|
48
60
|
if (isGet) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/query",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"main": "dist/query-browser.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "npm run clean && rollup -c",
|
|
9
|
-
"build:app": "npm run build && rsync dist/* ../deploy/dist",
|
|
10
9
|
"dev:lib": "rollup -c -w",
|
|
11
10
|
"clean": "rm -rf dist"
|
|
12
11
|
},
|
|
@@ -24,10 +23,10 @@
|
|
|
24
23
|
"devDependencies": {
|
|
25
24
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
26
25
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
27
|
-
"rollup": "^4.
|
|
26
|
+
"rollup": "^4.55.3",
|
|
28
27
|
"rollup-plugin-dts": "^6.3.0",
|
|
29
28
|
"typescript": "^5.9.3",
|
|
30
|
-
"zustand": "^5.0.
|
|
29
|
+
"zustand": "^5.0.10"
|
|
31
30
|
},
|
|
32
31
|
"publishConfig": {
|
|
33
32
|
"access": "public"
|
package/src/adapter.ts
CHANGED
|
@@ -60,15 +60,27 @@ export const adapter = async (opts: AdapterOpts = {}, overloadOpts?: RequestInit
|
|
|
60
60
|
if (opts?.url?.startsWith('http')) {
|
|
61
61
|
url = new URL(opts.url);
|
|
62
62
|
} else {
|
|
63
|
-
origin = window?.location?.origin || 'http://localhost:
|
|
63
|
+
origin = window?.location?.origin || 'http://localhost:51515';
|
|
64
64
|
url = new URL(opts.url, origin);
|
|
65
65
|
}
|
|
66
66
|
const isGet = method === 'GET';
|
|
67
67
|
if (isGet) {
|
|
68
|
-
|
|
68
|
+
let searchParams = new URLSearchParams(opts.body as SimpleObject);
|
|
69
|
+
url.search = searchParams.toString();
|
|
69
70
|
} else {
|
|
70
71
|
const params = opts.params || {};
|
|
71
|
-
|
|
72
|
+
const searchParams = new URLSearchParams(params as SimpleObject);
|
|
73
|
+
if (typeof opts.body === 'object' && opts.body !== null) {
|
|
74
|
+
// 浏览器环境下,自动将 body 中的 path 和 key 提取到查询参数中, 更容易排查问题
|
|
75
|
+
let body = opts.body as Record<string, any> || {};
|
|
76
|
+
if (!params.path && body?.path) {
|
|
77
|
+
searchParams.set('path', body.path);
|
|
78
|
+
if (body?.key) {
|
|
79
|
+
searchParams.set('key', body.key);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
url.search = searchParams.toString();
|
|
72
84
|
}
|
|
73
85
|
let body: string | FormData | undefined = undefined;
|
|
74
86
|
if (isGet) {
|