@cqsjjb/jjb-react-admin-component 3.0.11 → 3.0.13

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/Table/index.d.ts CHANGED
@@ -6,6 +6,10 @@ import type { TableProps } from 'antd';
6
6
  interface OverTableProps extends TableProps {
7
7
  // 是否禁用内容区滚动,默认true
8
8
  disabledResizer?: boolean;
9
+ // 当一个路由下存在多个表格的情况下
10
+ // 需要给每一个表格设置一个唯一存储索引
11
+ // 若没有设置则使用默认索引,请注意缓存数据会被覆盖
12
+ storeIndex?: string;
9
13
  }
10
14
 
11
15
  interface TableFc extends React.FC<OverTableProps> {
package/Table/index.js CHANGED
@@ -6,13 +6,16 @@ import { getElementAbsRect, antPrefix, className, setTableSize, getTableSize, ge
6
6
  import './index.less';
7
7
  require('use-antd-resizable-header/dist/style.css');
8
8
  export default function TablePro(props) {
9
- const [size, setSize] = React.useState(getTableSize() || 'default');
9
+ const {
10
+ storeIndex
11
+ } = props;
12
+ const [size, setSize] = React.useState(getTableSize(storeIndex) || 'default');
10
13
  const [tableHeight, setTableHeight] = React.useState(0);
11
- const persistenceKey = getPersistenceKey();
14
+ const persistenceKey = getPersistenceKey(storeIndex);
12
15
  React.useEffect(() => {
13
16
  let observer;
17
+ const table = document.querySelector(className('pro-table'));
14
18
  if (!props.disabledResizer) {
15
- const table = document.querySelector(className('pro-table'));
16
19
  observer = new ResizeObserver(() => {
17
20
  setTimeout(() => {
18
21
  const tBody = document.querySelector(className('table-body'));
@@ -36,7 +39,7 @@ export default function TablePro(props) {
36
39
  };
37
40
  }, []);
38
41
  React.useEffect(() => {
39
- setTableSize(size);
42
+ setTableSize(size, storeIndex);
40
43
  }, [size]);
41
44
  const {
42
45
  components,
package/Table/index.mjs CHANGED
@@ -10,15 +10,17 @@ import './index.less';
10
10
  require('use-antd-resizable-header/dist/style.css');
11
11
 
12
12
  export default function TablePro(props) {
13
- const [ size, setSize ] = React.useState(getTableSize() || 'default');
13
+ const { storeIndex } = props;
14
+ const [ size, setSize ] = React.useState(getTableSize(storeIndex) || 'default');
14
15
  const [ tableHeight, setTableHeight ] = React.useState(0);
15
16
 
16
- const persistenceKey = getPersistenceKey();
17
+ const persistenceKey = getPersistenceKey(storeIndex);
17
18
 
18
19
  React.useEffect(() => {
19
20
  let observer;
21
+ const table = document.querySelector(className('pro-table'));
22
+
20
23
  if (!props.disabledResizer) {
21
- const table = document.querySelector(className('pro-table'));
22
24
 
23
25
  observer = new ResizeObserver(() => {
24
26
  setTimeout(() => {
@@ -53,7 +55,7 @@ export default function TablePro(props) {
53
55
  };
54
56
  }, []);
55
57
  React.useEffect(() => {
56
- setTableSize(size);
58
+ setTableSize(size, storeIndex);
57
59
  }, [ size ]);
58
60
 
59
61
  const {
package/Table/utils.js CHANGED
@@ -80,20 +80,22 @@ export function className(name) {
80
80
  return `.${antPrefix}-${name}`;
81
81
  }
82
82
 
83
- export function getPersistenceKey() {
83
+ export function getPersistenceKey(index) {
84
84
  const basename = process.env?.app?.basename;
85
85
  const pathname = decodeURIComponent(window.location.pathname);
86
+ const insertIndex = tools.isUndefined(index) ? '' : `#{${index}}`;
87
+
86
88
  return {
87
- size: `${basename}#${pathname}#size`,
88
- resizable: `${basename}#${pathname}#resizable`,
89
- columnState: `${basename}#${pathname}#columnState`
89
+ size: `${basename}#${pathname}${insertIndex}#size`,
90
+ resizable: `${basename}#${pathname}${insertIndex}#resizable`,
91
+ columnState: `${basename}#${pathname}${insertIndex}#columnState`
90
92
  };
91
93
  }
92
94
 
93
- export function getTableSize() {
94
- return window.localStorage.getItem(getPersistenceKey().size);
95
+ export function getTableSize(index) {
96
+ return window.localStorage.getItem(getPersistenceKey(index).size);
95
97
  }
96
98
 
97
- export function setTableSize(value) {
98
- return window.localStorage.setItem(getPersistenceKey().size, value);
99
+ export function setTableSize(value, index) {
100
+ return window.localStorage.setItem(getPersistenceKey(index).size, value);
99
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cqsjjb/jjb-react-admin-component",
3
- "version": "3.0.11",
3
+ "version": "3.0.13",
4
4
  "description": "jjb-react-admin-组件库@new",
5
5
  "main": "index.js",
6
6
  "author": "jjb-front-team",