zy-react-library 1.1.0 → 1.1.2

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.
Files changed (76) hide show
  1. package/README.md +5 -1
  2. package/components/Cascader/Area/index.js +11 -11
  3. package/components/Cascader/Basic/index.js +23 -30
  4. package/components/Cascader/Dictionary/index.js +42 -42
  5. package/components/Cascader/Industry/index.js +12 -11
  6. package/components/Editor/index.js +43 -63
  7. package/components/FormBuilder/FormBuilder.js +97 -87
  8. package/components/FormBuilder/FormItemsRenderer.js +579 -581
  9. package/components/FormBuilder/index.js +5 -3
  10. package/components/HeaderBack/index.js +39 -32
  11. package/components/HiddenInfo/gwj/index.js +507 -439
  12. package/components/Icon/AddIcon/index.js +6 -6
  13. package/components/Icon/BackIcon/index.js +6 -6
  14. package/components/Icon/DeleteIcon/index.js +6 -6
  15. package/components/Icon/DownloadIcon/index.js +6 -6
  16. package/components/Icon/EditIcon/index.js +6 -6
  17. package/components/Icon/ExportIcon/index.js +6 -6
  18. package/components/Icon/ImportIcon/index.js +6 -6
  19. package/components/Icon/LocationIcon/index.js +6 -6
  20. package/components/Icon/PrintIcon/index.js +6 -6
  21. package/components/Icon/ResetIcon/index.js +6 -6
  22. package/components/Icon/SearchIcon/index.js +6 -6
  23. package/components/Icon/VideoIcon/index.js +6 -6
  24. package/components/Icon/ViewIcon/index.js +6 -6
  25. package/components/ImportFile/index.js +94 -91
  26. package/components/LeftTree/Area/index.js +15 -15
  27. package/components/LeftTree/Basic/index.js +54 -65
  28. package/components/LeftTree/Department/Gwj/index.js +29 -32
  29. package/components/LeftTree/Dictionary/index.js +42 -42
  30. package/components/Map/MapSelector.js +280 -254
  31. package/components/Map/index.js +90 -77
  32. package/components/Page/index.d.ts +2 -0
  33. package/components/Page/index.js +44 -34
  34. package/components/Pdf/index.js +92 -90
  35. package/components/PreviewImg/index.js +26 -32
  36. package/components/PreviewPdf/index.js +78 -86
  37. package/components/Search/index.js +147 -141
  38. package/components/Select/Basic/index.js +70 -76
  39. package/components/Select/Dictionary/index.js +42 -42
  40. package/components/Select/Personnel/Gwj/index.js +45 -49
  41. package/components/SelectCreate/index.js +33 -40
  42. package/components/SelectTree/Area/index.js +11 -17
  43. package/components/SelectTree/Basic/index.js +105 -102
  44. package/components/SelectTree/Department/Gwj/index.js +40 -46
  45. package/components/SelectTree/Dictionary/index.js +42 -42
  46. package/components/SelectTree/HiddenLevel/Gwj/index.js +33 -35
  47. package/components/SelectTree/HiddenPart/Gwj/index.js +16 -19
  48. package/components/SelectTree/Industry/index.js +12 -18
  49. package/components/Signature/index.js +68 -62
  50. package/components/Table/index.js +77 -73
  51. package/components/Table/index.less +7 -1
  52. package/components/TooltipPreviewImg/index.js +28 -27
  53. package/components/Upload/index.js +229 -275
  54. package/components/Video/AliPlayer.js +182 -160
  55. package/components/Video/index.js +71 -90
  56. package/css/common.less +4 -0
  57. package/enum/dictionary/index.js +5 -3
  58. package/enum/formItemRender/index.js +37 -35
  59. package/enum/hidden/gwj/index.js +65 -26
  60. package/enum/uploadFile/gwj/index.js +166 -84
  61. package/hooks/useDeleteFile/index.js +24 -30
  62. package/hooks/useDictionary/index.js +28 -30
  63. package/hooks/useDownloadBlob/index.js +78 -77
  64. package/hooks/useDownloadFile/index.js +76 -79
  65. package/hooks/useGetFile/index.js +32 -32
  66. package/hooks/useGetUrlQuery/index.js +1 -2
  67. package/hooks/useGetUserInfo/index.js +19 -26
  68. package/hooks/useIdle/index.js +9 -11
  69. package/hooks/useImportFile/index.js +30 -28
  70. package/hooks/useIsExistenceDuplicateSelection/index.js +25 -18
  71. package/hooks/useTable/index.js +49 -38
  72. package/hooks/useUploadFile/index.js +142 -147
  73. package/hooks/useUrlQueryCriteria/index.js +20 -13
  74. package/package.json +14 -1
  75. package/regular/index.js +34 -39
  76. package/utils/index.js +515 -511
@@ -1,42 +1,42 @@
1
- import { request } from "@cqsjjb/jjb-common-lib/http";
2
- import { useEffect, useState } from "react";
3
- import { DICTIONARY_APP_KEY_ENUM } from "../../../enum/dictionary";
4
- import BasicSelectTree from "../Basic";
5
-
6
- /**
7
- * 数据字典下拉树组件
8
- */
9
- function DictionarySelectTree(props) {
10
- const {
11
- appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT,
12
- dictValue = "",
13
- nameKey = "dictLabel",
14
- idKey = "dictValue",
15
- ...restProps
16
- } = props;
17
-
18
- const [treeData, setTreeData] = useState([]);
19
-
20
- const getData = async () => {
21
- if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) {
22
- console.error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中");
23
- return;
24
- }
25
-
26
- setTreeData([]);
27
- const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue });
28
- setTreeData(data);
29
- };
30
-
31
- useEffect(() => {
32
- dictValue && getData();
33
- }, [dictValue]);
34
-
35
- return (
36
- <BasicSelectTree treeData={treeData} nameKey={nameKey} idKey={idKey} {...restProps} />
37
- );
38
- }
39
-
40
- DictionarySelectTree.displayName = "DictionarySelectTree";
41
-
42
- export default DictionarySelectTree;
1
+ import { request } from '@cqsjjb/jjb-common-lib/http';
2
+ import { useState, useEffect } from 'react';
3
+ import { DICTIONARY_APP_KEY_ENUM } from '../../../enum/dictionary/index.js';
4
+ import BasicSelectTree from '../Basic/index.js';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ function DictionarySelectTree(props) {
8
+ const {
9
+ appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT,
10
+ dictValue = "",
11
+ nameKey = "dictLabel",
12
+ idKey = "dictValue",
13
+ ...restProps
14
+ } = props;
15
+ const [treeData, setTreeData] = useState([]);
16
+ const getData = async () => {
17
+ if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) {
18
+ console.error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中");
19
+ return;
20
+ }
21
+ setTreeData([]);
22
+ const {
23
+ data
24
+ } = await request("/config/dict-trees/list/by/dictValues", "get", {
25
+ appKey,
26
+ dictValue
27
+ });
28
+ setTreeData(data);
29
+ };
30
+ useEffect(() => {
31
+ dictValue && getData();
32
+ }, [dictValue]);
33
+ return /*#__PURE__*/jsx(BasicSelectTree, {
34
+ treeData: treeData,
35
+ nameKey: nameKey,
36
+ idKey: idKey,
37
+ ...restProps
38
+ });
39
+ }
40
+ DictionarySelectTree.displayName = "DictionarySelectTree";
41
+
42
+ export { DictionarySelectTree as default };
@@ -1,11 +1,9 @@
1
- import { request } from "@cqsjjb/jjb-common-lib/http";
2
- import { useEffect, useState } from "react";
3
- import { DICTIONARY_APP_KEY_ENUM } from "../../../../enum/dictionary";
4
- import BasicSelectTree from "../../Basic";
1
+ import { request } from '@cqsjjb/jjb-common-lib/http';
2
+ import { useState, useEffect } from 'react';
3
+ import { DICTIONARY_APP_KEY_ENUM } from '../../../../enum/dictionary/index.js';
4
+ import BasicSelectTree from '../../Basic/index.js';
5
+ import { jsx } from 'react/jsx-runtime';
5
6
 
6
- /**
7
- * 隐患级别下拉树组件(港务局版本)
8
- */
9
7
  function HiddenLevelSelectTree(props) {
10
8
  const {
11
9
  isShowNeglect = true,
@@ -13,60 +11,60 @@ function HiddenLevelSelectTree(props) {
13
11
  isShowMajor = true,
14
12
  ...restProps
15
13
  } = props;
16
-
17
14
  const [treeData, setTreeData] = useState([]);
18
15
 
19
16
  // 过滤隐患级别的树数据
20
- const filterTreeData = (treeData) => {
17
+ const filterTreeData = treeData => {
21
18
  // 隐患级别的特定ID
22
19
  const HIDDEN_LEVEL_IDS = {
23
- neglect: "hiddenLevel1001", // 忽略隐患
24
- larger: "jdyh001", // 较大隐患
25
- major: "hiddenLevel0002", // 重大隐患
20
+ neglect: "hiddenLevel1001",
21
+ // 忽略隐患
22
+ larger: "jdyh001",
23
+ // 较大隐患
24
+ major: "hiddenLevel0002" // 重大隐患
26
25
  };
27
26
 
28
27
  // 递归过滤树数据
29
- const filterTree = (nodes) => {
30
- if (!nodes || !Array.isArray(nodes))
31
- return [];
32
-
33
- return nodes.filter((node) => {
28
+ const filterTree = nodes => {
29
+ if (!nodes || !Array.isArray(nodes)) return [];
30
+ return nodes.filter(node => {
34
31
  // 根据不同的ID和对应的props来决定是否显示
35
- if (node.dictValue === HIDDEN_LEVEL_IDS.neglect)
36
- return isShowNeglect;
37
- if (node.dictValue === HIDDEN_LEVEL_IDS.larger)
38
- return isShowLarger;
39
- if (node.dictValue === HIDDEN_LEVEL_IDS.major)
40
- return isShowMajor;
32
+ if (node.dictValue === HIDDEN_LEVEL_IDS.neglect) return isShowNeglect;
33
+ if (node.dictValue === HIDDEN_LEVEL_IDS.larger) return isShowLarger;
34
+ if (node.dictValue === HIDDEN_LEVEL_IDS.major) return isShowMajor;
41
35
 
42
36
  // 如果有子节点,递归过滤子节点
43
- if (node.children && node.children.length > 0)
44
- node.children = filterTree(node.children);
37
+ if (node.children && node.children.length > 0) node.children = filterTree(node.children);
45
38
 
46
39
  // 默认显示其他节点
47
40
  return true;
48
41
  });
49
42
  };
50
-
51
43
  return filterTree(treeData);
52
44
  };
53
-
54
45
  const getData = async () => {
55
46
  setTreeData([]);
56
- const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey: DICTIONARY_APP_KEY_ENUM.GWJ, dictValue: "hiddenLevel" });
47
+ const {
48
+ data
49
+ } = await request("/config/dict-trees/list/by/dictValues", "get", {
50
+ appKey: DICTIONARY_APP_KEY_ENUM.GWJ,
51
+ dictValue: "hiddenLevel"
52
+ });
57
53
  const filterData = filterTreeData(data);
58
54
  setTreeData(filterData);
59
55
  };
60
-
61
56
  useEffect(() => {
62
57
  getData();
63
58
  }, []);
64
-
65
- return (
66
- <BasicSelectTree treeData={treeData} placeholder="隐患级别" onlyLastLevel={true} nameKey="dictLabel" idKey="dictValue" {...restProps} />
67
- );
59
+ return /*#__PURE__*/jsx(BasicSelectTree, {
60
+ treeData: treeData,
61
+ placeholder: "\u9690\u60A3\u7EA7\u522B",
62
+ onlyLastLevel: true,
63
+ nameKey: "dictLabel",
64
+ idKey: "dictValue",
65
+ ...restProps
66
+ });
68
67
  }
69
-
70
68
  HiddenLevelSelectTree.displayName = "HiddenLevelSelectTree";
71
69
 
72
- export default HiddenLevelSelectTree;
70
+ export { HiddenLevelSelectTree as default };
@@ -1,39 +1,36 @@
1
- import { request } from "@cqsjjb/jjb-common-lib/http";
2
- import { useEffect, useState } from "react";
3
- import BasicSelectTree from "../../Basic";
1
+ import { request } from '@cqsjjb/jjb-common-lib/http';
2
+ import { useState, useEffect } from 'react';
3
+ import BasicSelectTree from '../../Basic/index.js';
4
+ import { jsx } from 'react/jsx-runtime';
4
5
 
5
- /**
6
- * 隐患部位下拉树组件(港务局版本)
7
- */
8
6
  function HiddenPartSelectTree(props) {
9
7
  const {
10
8
  params = {},
11
9
  isNeedCorpInfoId = false,
12
10
  ...restProps
13
11
  } = props;
14
-
15
12
  const [treeData, setTreeData] = useState([]);
16
-
17
13
  const getData = async () => {
18
14
  setTreeData([]);
19
15
 
20
16
  // 根据参数决定是否发送请求
21
- if (isNeedCorpInfoId && !params.eqCorpinfoId)
22
- return;
23
-
24
- const { data } = await request("/hidden/hiddenRegion/listByTree", "post", params);
17
+ if (isNeedCorpInfoId && !params.eqCorpinfoId) return;
18
+ const {
19
+ data
20
+ } = await request("/hidden/hiddenRegion/listByTree", "post", params);
25
21
  setTreeData(data);
26
22
  };
27
-
28
23
  useEffect(() => {
29
24
  getData();
30
25
  }, [JSON.stringify(params), isNeedCorpInfoId]);
31
-
32
- return (
33
- <BasicSelectTree treeData={treeData} placeholder="隐患部位" nameKey="hiddenregion" idKey="hiddenregionId" {...restProps} />
34
- );
26
+ return /*#__PURE__*/jsx(BasicSelectTree, {
27
+ treeData: treeData,
28
+ placeholder: "\u9690\u60A3\u90E8\u4F4D",
29
+ nameKey: "hiddenregion",
30
+ idKey: "hiddenregionId",
31
+ ...restProps
32
+ });
35
33
  }
36
-
37
34
  HiddenPartSelectTree.displayName = "HiddenPartSelectTree";
38
35
 
39
- export default HiddenPartSelectTree;
36
+ export { HiddenPartSelectTree as default };
@@ -1,27 +1,21 @@
1
- import Industry from "../../../json/industry.json";
2
- import BasicSelectTree from "../Basic";
1
+ import Industry from '../../../json/industry.json';
2
+ import BasicSelectTree from '../Basic/index.js';
3
+ import { jsx } from 'react/jsx-runtime';
3
4
 
4
- /**
5
- * 行业类型下拉树组件
6
- */
7
5
  function IndustrySelectTree(props) {
8
6
  const {
9
7
  placeholder = "行业类型",
10
8
  ...restProps
11
9
  } = props;
12
-
13
- return (
14
- <BasicSelectTree
15
- treeData={Industry}
16
- placeholder={placeholder}
17
- nameKey="dict_label"
18
- idKey="dict_value"
19
- childrenKey="childrenList"
20
- {...restProps}
21
- />
22
- );
10
+ return /*#__PURE__*/jsx(BasicSelectTree, {
11
+ treeData: Industry,
12
+ placeholder: placeholder,
13
+ nameKey: "dict_label",
14
+ idKey: "dict_value",
15
+ childrenKey: "childrenList",
16
+ ...restProps
17
+ });
23
18
  }
24
-
25
19
  IndustrySelectTree.displayName = "IndustrySelectTree";
26
20
 
27
- export default IndustrySelectTree;
21
+ export { IndustrySelectTree as default };
@@ -1,12 +1,10 @@
1
- import { Button, Image, message, Modal } from "antd";
2
- import dayjs from "dayjs";
3
- import { useEffect, useRef, useState } from "react";
4
- import SignatureCanvas from "react-signature-canvas";
5
- import { base642File } from "../../utils";
1
+ import { Button, Image, Modal, message } from 'antd';
2
+ import dayjs from 'dayjs';
3
+ import { useState, useRef, useEffect } from 'react';
4
+ import SignatureCanvas from 'react-signature-canvas';
5
+ import { base642File } from '../../utils/index.js';
6
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
6
7
 
7
- /**
8
- * 签字组件
9
- */
10
8
  function Signature(props) {
11
9
  const {
12
10
  onConfirm,
@@ -15,14 +13,12 @@ function Signature(props) {
15
13
  url = "",
16
14
  ...restProps
17
15
  } = props;
18
-
19
16
  const [signatureModalOpen, setSignatureModalOpen] = useState(false);
20
17
  const signatureCanvas = useRef(null);
21
18
  const [base64, setBase64] = useState("");
22
19
  useEffect(() => {
23
20
  setBase64(url);
24
21
  }, [url]);
25
-
26
22
  const onOk = () => {
27
23
  if (signatureCanvas.current.isEmpty()) {
28
24
  message.warning("请签名");
@@ -33,62 +29,72 @@ function Signature(props) {
33
29
  onConfirm({
34
30
  time: dayjs().format("YYYY-MM-DD HH:mm:ss"),
35
31
  base64,
36
- file: base642File(base64),
32
+ file: base642File(base64)
37
33
  });
38
34
  signatureCanvas.current.clear();
39
35
  setSignatureModalOpen(false);
40
36
  };
41
-
42
- return (
43
- <>
44
- <div>
45
- <Button
46
- type="primary"
47
- onClick={() => {
48
- setSignatureModalOpen(true);
49
- }}
50
- >
51
- {base64 ? "重新签字" : "手写签字"}
52
- </Button>
53
- </div>
54
- {base64 && (
55
- <div style={{ border: "1px dashed #d9d9d9", width, height, marginTop: 16 }}>
56
- <Image src={base64} style={{ width, height, objectFit: "contain" }} />
57
- </div>
58
- )}
59
- <Modal
60
- title="签字"
61
- width={800}
62
- open={signatureModalOpen}
63
- maskClosable={false}
64
- onCancel={() => setSignatureModalOpen(false)}
65
- footer={[
66
- <Button key="clear" onClick={() => signatureCanvas.current.clear()}>重签</Button>,
67
- <Button
68
- key="cancel"
69
- onClick={() => {
70
- setSignatureModalOpen(false);
71
- signatureCanvas.current.clear();
72
- }}
73
- >
74
- 取消
75
- </Button>,
76
- <Button key="ok" type="primary" onClick={onOk}>确定</Button>,
77
- ]}
78
- >
79
- <div style={{ border: "1px dashed #d9d9d9" }}>
80
- <SignatureCanvas
81
- ref={signatureCanvas}
82
- penColor="black"
83
- canvasProps={{ width, height }}
84
- {...restProps}
85
- />
86
- </div>
87
- </Modal>
88
- </>
89
- );
37
+ return /*#__PURE__*/jsxs(Fragment, {
38
+ children: [/*#__PURE__*/jsx("div", {
39
+ children: /*#__PURE__*/jsx(Button, {
40
+ type: "primary",
41
+ onClick: () => {
42
+ setSignatureModalOpen(true);
43
+ },
44
+ children: base64 ? "重新签字" : "手写签字"
45
+ })
46
+ }), base64 && /*#__PURE__*/jsx("div", {
47
+ style: {
48
+ border: "1px dashed #d9d9d9",
49
+ width,
50
+ height,
51
+ marginTop: 16
52
+ },
53
+ children: /*#__PURE__*/jsx(Image, {
54
+ src: base64,
55
+ style: {
56
+ width,
57
+ height,
58
+ objectFit: "contain"
59
+ }
60
+ })
61
+ }), /*#__PURE__*/jsx(Modal, {
62
+ title: "\u7B7E\u5B57",
63
+ width: 800,
64
+ open: signatureModalOpen,
65
+ maskClosable: false,
66
+ onCancel: () => setSignatureModalOpen(false),
67
+ footer: [/*#__PURE__*/jsx(Button, {
68
+ onClick: () => signatureCanvas.current.clear(),
69
+ children: "\u91CD\u7B7E"
70
+ }, "clear"), /*#__PURE__*/jsx(Button, {
71
+ onClick: () => {
72
+ setSignatureModalOpen(false);
73
+ signatureCanvas.current.clear();
74
+ },
75
+ children: "\u53D6\u6D88"
76
+ }, "cancel"), /*#__PURE__*/jsx(Button, {
77
+ type: "primary",
78
+ onClick: onOk,
79
+ children: "\u786E\u5B9A"
80
+ }, "ok")],
81
+ children: /*#__PURE__*/jsx("div", {
82
+ style: {
83
+ border: "1px dashed #d9d9d9"
84
+ },
85
+ children: /*#__PURE__*/jsx(SignatureCanvas, {
86
+ ref: signatureCanvas,
87
+ penColor: "black",
88
+ canvasProps: {
89
+ width,
90
+ height
91
+ },
92
+ ...restProps
93
+ })
94
+ })
95
+ })]
96
+ });
90
97
  }
91
-
92
98
  Signature.displayName = "Signature";
93
99
 
94
- export default Signature;
100
+ export { Signature as default };
@@ -1,73 +1,77 @@
1
- import TablePro from "@cqsjjb/jjb-react-admin-component/Table";
2
- import { getIndexColumn } from "../../utils/index";
3
- import dayjs from 'dayjs';
4
- import "./index.less";
5
-
6
- const CLEANUP_INTERVAL_DAYS = 10; // 清理间隔天数
7
- const LAST_CLEANUP_KEY = 'tableLocalStorageLastCleanup'; // 最后清理时间存储key
8
-
9
- // 清理本地存储中特定后缀的key
10
- function cleanupTableLocalStorage() {
11
- const now = dayjs();
12
- const lastCleanupStr = localStorage.getItem(LAST_CLEANUP_KEY);
13
- const lastCleanup = lastCleanupStr ? dayjs(lastCleanupStr) : null;
14
-
15
- // 如果没有上次清理时间或距离上次清理已超过10天
16
- if (!lastCleanup || now.diff(lastCleanup, 'day') >= CLEANUP_INTERVAL_DAYS) {
17
- // 查找并清理符合条件的key
18
- const keysToRemove = [];
19
- for (let i = 0; i < localStorage.length; i++) {
20
- const key = localStorage.key(i);
21
- if (key && (key.endsWith('#columnState') ||
22
- key.endsWith('#size') ||
23
- key.endsWith('#resizable'))) {
24
- keysToRemove.push(key);
25
- }
26
- }
27
-
28
- // 删除匹配的key
29
- keysToRemove.forEach(key => {
30
- localStorage.removeItem(key);
31
- });
32
-
33
- // 更新最后清理时间
34
- localStorage.setItem(LAST_CLEANUP_KEY, now.toISOString());
35
- }
36
- }
37
-
38
- function Table(props) {
39
- const {
40
- columns = [],
41
- showIndexColumn = true,
42
- ellipsis = true,
43
- align = "center",
44
- indexColumnFixed = "left",
45
- rowKey = "id",
46
- ...restProps
47
- } = props;
48
-
49
- // 组件初始化时执行清理
50
- cleanupTableLocalStorage();
51
-
52
- function settingColumns() {
53
- showIndexColumn && columns.unshift({ ...getIndexColumn(props.pagination), fixed: indexColumnFixed });
54
-
55
- const setAlign = column => ({
56
- align,
57
- ellipsis,
58
- ...column,
59
- ...(column.children ? { children: column.children.map(setAlign) } : {}),
60
- });
61
-
62
- return columns.map(setAlign);
63
- }
64
- return (
65
- <div className="table-layout card-layout">
66
- <TablePro rowKey={rowKey} columns={settingColumns()} bordered size="small" {...restProps} />
67
- </div>
68
- );
69
- }
70
-
71
- Table.displayName = "Table";
72
-
73
- export default Table;
1
+ import TablePro from '@cqsjjb/jjb-react-admin-component/Table';
2
+ import { getIndexColumn } from '../../utils/index.js';
3
+ import dayjs from 'dayjs';
4
+ import './index.less';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ const CLEANUP_INTERVAL_DAYS = 10; // 清理间隔天数
8
+ const LAST_CLEANUP_KEY = 'tableLocalStorageLastCleanup'; // 最后清理时间存储key
9
+
10
+ // 清理本地存储中特定后缀的key
11
+ function cleanupTableLocalStorage() {
12
+ const now = dayjs();
13
+ const lastCleanupStr = localStorage.getItem(LAST_CLEANUP_KEY);
14
+ const lastCleanup = lastCleanupStr ? dayjs(lastCleanupStr) : null;
15
+
16
+ // 如果没有上次清理时间或距离上次清理已超过10天
17
+ if (!lastCleanup || now.diff(lastCleanup, 'day') >= CLEANUP_INTERVAL_DAYS) {
18
+ // 查找并清理符合条件的key
19
+ const keysToRemove = [];
20
+ for (let i = 0; i < localStorage.length; i++) {
21
+ const key = localStorage.key(i);
22
+ if (key && (key.endsWith('#columnState') || key.endsWith('#size') || key.endsWith('#resizable'))) {
23
+ keysToRemove.push(key);
24
+ }
25
+ }
26
+
27
+ // 删除匹配的key
28
+ keysToRemove.forEach(key => {
29
+ localStorage.removeItem(key);
30
+ });
31
+
32
+ // 更新最后清理时间
33
+ localStorage.setItem(LAST_CLEANUP_KEY, now.toISOString());
34
+ }
35
+ }
36
+ function Table(props) {
37
+ const {
38
+ columns = [],
39
+ showIndexColumn = true,
40
+ ellipsis = true,
41
+ align = "center",
42
+ indexColumnFixed = "left",
43
+ rowKey = "id",
44
+ ...restProps
45
+ } = props;
46
+
47
+ // 组件初始化时执行清理
48
+ cleanupTableLocalStorage();
49
+ function settingColumns() {
50
+ showIndexColumn && columns.unshift({
51
+ ...getIndexColumn(props.pagination),
52
+ fixed: indexColumnFixed
53
+ });
54
+ const setAlign = column => ({
55
+ align,
56
+ ellipsis,
57
+ ...column,
58
+ ...(column.children ? {
59
+ children: column.children.map(setAlign)
60
+ } : {})
61
+ });
62
+ return columns.map(setAlign);
63
+ }
64
+ return /*#__PURE__*/jsx("div", {
65
+ className: "table-layout card-layout",
66
+ children: /*#__PURE__*/jsx(TablePro, {
67
+ rowKey: rowKey,
68
+ columns: settingColumns(),
69
+ bordered: true,
70
+ size: "small",
71
+ ...restProps
72
+ })
73
+ });
74
+ }
75
+ Table.displayName = "Table";
76
+
77
+ export { Table as default };
@@ -9,6 +9,12 @@
9
9
  }
10
10
 
11
11
  .@{ant-prefix}-pro-table-list-toolbar-container {
12
- padding-top: 26px !important;
12
+ padding-top: 0 !important;
13
13
  padding-bottom: 16px;
14
14
  }
15
+
16
+ .search-layout {
17
+ + .table-layout .@{ant-prefix}-pro-table-list-toolbar-container {
18
+ padding-top: 26px !important;
19
+ }
20
+ }