@stephenchenorg/astro 3.0.1 → 3.1.1
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.
|
@@ -6,6 +6,7 @@ declare global {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
export interface QueryParamsUrlOptions {
|
|
9
|
+
clear?: boolean;
|
|
9
10
|
transformParams?: (params: Record<string, any>) => Record<string, any>;
|
|
10
11
|
}
|
|
11
12
|
export declare function queryParamsUrl(additionalParams: Record<string, any>, urlConfig?: UrlConfig, options?: QueryParamsUrlOptions): string;
|
package/dist/query-params/url.js
CHANGED
|
@@ -6,14 +6,20 @@ export function queryParamsUrl(additionalParams, urlConfig = {
|
|
|
6
6
|
params: {},
|
|
7
7
|
defaultParams: {}
|
|
8
8
|
}, options = {}) {
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
clear = false,
|
|
11
|
+
transformParams
|
|
12
|
+
} = options;
|
|
10
13
|
const config = typeof window !== "undefined" ? urlConfigStore.get() : urlConfig;
|
|
11
|
-
let params =
|
|
12
|
-
if (
|
|
13
|
-
params =
|
|
14
|
+
let params = {};
|
|
15
|
+
if (!clear) {
|
|
16
|
+
params = mergeUrlParams(config.params, additionalParams);
|
|
17
|
+
if (transformParams) {
|
|
18
|
+
params = transformParams(params);
|
|
19
|
+
}
|
|
20
|
+
params = cleanParams(params, config.defaultParams || {});
|
|
14
21
|
}
|
|
15
|
-
const
|
|
16
|
-
const queryString = qs.stringify(cleanedParams, {
|
|
22
|
+
const queryString = qs.stringify(params, {
|
|
17
23
|
skipEmptyString: true,
|
|
18
24
|
skipNull: true,
|
|
19
25
|
sort: false
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export function mergeUrlParams(baseParams, userParams) {
|
|
2
2
|
return Object.keys(baseParams).reduce((result, key) => {
|
|
3
|
-
if (
|
|
3
|
+
if (userParams[key] === null) {
|
|
4
|
+
result[key] = null;
|
|
5
|
+
} else if (Array.isArray(baseParams[key])) {
|
|
4
6
|
result[key] = Array.from(/* @__PURE__ */ new Set([...baseParams[key], ...userParams[key] || []]));
|
|
5
7
|
} else {
|
|
6
8
|
result[key] = typeof userParams[key] !== "undefined" ? userParams[key] : baseParams[key];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stephenchenorg/astro",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.1.1",
|
|
5
5
|
"description": "Stephenchenorg Astro 前端通用套件",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://stephenchenorg-astro.netlify.app",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"build": "mkdist --declaration --ext=js && sh ./scripts/postbuild.sh",
|
|
63
63
|
"lint": "eslint \"*.{js,ts,json}\" \"src/**/*.ts\"",
|
|
64
64
|
"code-check": "astro check && npm run lint",
|
|
65
|
+
"test": "vitest",
|
|
65
66
|
"prepack": "npm run build",
|
|
66
67
|
"release": "bumpp --commit \"Release v%s\" && npm publish"
|
|
67
68
|
},
|
|
@@ -80,17 +81,18 @@
|
|
|
80
81
|
"graphql": "^16.11.0",
|
|
81
82
|
"graphql-tag": "^2.12.6",
|
|
82
83
|
"nanostores": "^1.0.1",
|
|
83
|
-
"query-string": "^9.2.
|
|
84
|
+
"query-string": "^9.2.2"
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
87
|
"@astrojs/check": "^0.9.4",
|
|
87
|
-
"@ycs77/eslint-config": "^4.
|
|
88
|
-
"astro": "^5.
|
|
89
|
-
"bumpp": "^10.
|
|
90
|
-
"eslint": "^9.
|
|
88
|
+
"@ycs77/eslint-config": "^4.4.0",
|
|
89
|
+
"astro": "^5.11.0",
|
|
90
|
+
"bumpp": "^10.2.0",
|
|
91
|
+
"eslint": "^9.30.1",
|
|
91
92
|
"eslint-plugin-astro": "^1.3.1",
|
|
92
93
|
"mkdist": "^2.3.0",
|
|
93
94
|
"typescript": "^5.8.3",
|
|
94
|
-
"
|
|
95
|
+
"vitest": "^3.2.4",
|
|
96
|
+
"vue": "^3.5.17"
|
|
95
97
|
}
|
|
96
98
|
}
|