zy-react-library 1.0.163 → 1.0.164
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/hooks/useUrlQueryCriteria/index.js +16 -11
- package/package.json +2 -1
- package/utils/index.d.ts +2 -2
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import useGetUrlQuery from "../useGetUrlQuery";
|
|
3
|
-
|
|
4
|
-
const { query } = tools.router;
|
|
1
|
+
import useUrlState from "@ahooksjs/use-url-state";
|
|
5
2
|
|
|
6
3
|
/**
|
|
7
4
|
* 处理搜索条件缓存到 URL
|
|
8
5
|
*/
|
|
9
6
|
export default function useUrlQueryCriteria() {
|
|
7
|
+
const [state, setState] = useUrlState({
|
|
8
|
+
searchFormKeys: "",
|
|
9
|
+
searchFormValues: "",
|
|
10
|
+
paginationKeys: "",
|
|
11
|
+
paginationValues: "",
|
|
12
|
+
}, { navigateMode: "replace" });
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* 将搜索表单项和分页参数缓存到 URL 中
|
|
12
16
|
*/
|
|
@@ -35,20 +39,21 @@ export default function useUrlQueryCriteria() {
|
|
|
35
39
|
const paginationData = getJoinString(pagination);
|
|
36
40
|
|
|
37
41
|
// 将数据存储到 URL 查询参数中
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
setState({
|
|
43
|
+
searchFormKeys: searchFormData.keys || undefined,
|
|
44
|
+
searchFormValues: searchFormData.values || undefined,
|
|
45
|
+
paginationKeys: paginationData.keys || undefined,
|
|
46
|
+
paginationValues: paginationData.values || undefined,
|
|
47
|
+
});
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
/**
|
|
45
51
|
* 从 URL 中获取缓存的查询参数
|
|
46
52
|
*/
|
|
47
53
|
function getUrlCriteriaQuery(keysStr, valuesStr) {
|
|
48
|
-
const query = useGetUrlQuery();
|
|
49
54
|
// 将键值字符串分割为数组
|
|
50
|
-
const keys =
|
|
51
|
-
const values =
|
|
55
|
+
const keys = state[keysStr] ? state[keysStr].split(",") : [];
|
|
56
|
+
const values = state[valuesStr] ? state[valuesStr].split(",") : [];
|
|
52
57
|
|
|
53
58
|
// 构建结果对象
|
|
54
59
|
const resultMap = {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zy-react-library",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.164",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "",
|
|
7
7
|
"author": "LiuJiaNan",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"postinstall": "echo 'Thanks for using our component library!'"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@ahooksjs/use-url-state": "^3.5.1",
|
|
25
26
|
"@ant-design/icons": "^6.1.0",
|
|
26
27
|
"@ant-design/pro-components": "^2.8.10",
|
|
27
28
|
"@cqsjjb/jjb-common-lib": "latest",
|
package/utils/index.d.ts
CHANGED
|
@@ -329,14 +329,14 @@ export function processTreeDataForOnlyLastLevel(
|
|
|
329
329
|
/**
|
|
330
330
|
* 验证结束时间是否大于开始时间
|
|
331
331
|
*/
|
|
332
|
-
export function validatorEndTime(timeStart: string, message
|
|
332
|
+
export function validatorEndTime(timeStart: string, message?: string): {
|
|
333
333
|
validator: (_: any, value: any) => Promise<void | string>;
|
|
334
334
|
};
|
|
335
335
|
|
|
336
336
|
/**
|
|
337
337
|
* 验证时间是否大于等于当前时间
|
|
338
338
|
*/
|
|
339
|
-
export function validatorTimeGTCurrentDay(message
|
|
339
|
+
export function validatorTimeGTCurrentDay(message?: string): {
|
|
340
340
|
validator: (_: any, value: any) => Promise<void | string>;
|
|
341
341
|
};
|
|
342
342
|
|