@zcrkey/js-utils 0.0.5 → 0.0.7
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/README.md +9 -0
- package/dist/cjs/color.d.ts +195 -0
- package/dist/cjs/color.js +353 -0
- package/{src/eventCenter.ts → dist/cjs/eventCenter.js} +120 -112
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/index.js +54 -0
- package/dist/cjs/obj.js +37 -0
- package/{src/storage.ts → dist/cjs/storage.js} +118 -101
- package/dist/cjs/tree.js +145 -0
- package/dist/{util.d.ts → cjs/util.d.ts} +3 -3
- package/{src/util.ts → dist/cjs/util.js} +173 -257
- package/dist/esm/color.d.ts +195 -0
- package/dist/esm/color.js +500 -0
- package/dist/esm/eventCenter.d.ts +59 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/obj.d.ts +12 -0
- package/dist/{objUtil.js → esm/obj.js} +6 -6
- package/dist/esm/storage.d.ts +44 -0
- package/dist/esm/tree.d.ts +48 -0
- package/dist/esm/util.d.ts +209 -0
- package/dist/{util.js → esm/util.js} +129 -129
- package/dist/{index.umd.js → umd/index.umd.js} +1 -1
- package/package.json +15 -4
- package/.dumi/global.less +0 -1396
- package/.dumirc.ts +0 -36
- package/.fatherrc.ts +0 -14
- package/.husky/commit-msg +0 -4
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -2
- package/.stylelintrc +0 -10
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -5
- package/docs/api/eventCenter/index.md +0 -34
- package/docs/api/index.md +0 -5
- package/docs/api/storage/index.md +0 -9
- package/docs/api/storage/local.tsx +0 -91
- package/docs/api/storage/session.tsx +0 -85
- package/docs/api/treeUtil/index.md +0 -5
- package/docs/api/treeUtil/index.tsx +0 -266
- package/docs/api/util/index.md +0 -6
- package/docs/api/util/index.tsx +0 -405
- package/docs/api/util/is.tsx +0 -196
- package/docs/guide.md +0 -24
- package/src/index.ts +0 -8
- package/src/objUtil.ts +0 -20
- package/src/treeUtil.ts +0 -164
- package/tsconfig.json +0 -18
- /package/dist/{eventCenter.d.ts → cjs/eventCenter.d.ts} +0 -0
- /package/dist/{objUtil.d.ts → cjs/obj.d.ts} +0 -0
- /package/dist/{storage.d.ts → cjs/storage.d.ts} +0 -0
- /package/dist/{treeUtil.d.ts → cjs/tree.d.ts} +0 -0
- /package/dist/{eventCenter.js → esm/eventCenter.js} +0 -0
- /package/dist/{storage.js → esm/storage.js} +0 -0
- /package/dist/{treeUtil.js → esm/tree.js} +0 -0
package/.dumirc.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'dumi';
|
|
2
|
-
|
|
3
|
-
// more config: https://d.umijs.org/config
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
outputPath: 'docs-dist',
|
|
6
|
-
themeConfig: {
|
|
7
|
-
name: '@zcrkey/js-utils',
|
|
8
|
-
nav: {
|
|
9
|
-
'zh-CN': [
|
|
10
|
-
{ title: '指南', link: '/guide' },
|
|
11
|
-
{ title: 'API', link: '/api' },
|
|
12
|
-
],
|
|
13
|
-
},
|
|
14
|
-
footer: 'zcrkey | Copyright © 2023-present</span>',
|
|
15
|
-
title: '@zcrkey/js-utils',
|
|
16
|
-
description: {
|
|
17
|
-
'zh-CN': '一个 javascript 实用函数库',
|
|
18
|
-
},
|
|
19
|
-
actions: {
|
|
20
|
-
'zh-CN': [
|
|
21
|
-
{
|
|
22
|
-
type: 'primary',
|
|
23
|
-
text: '开始使用',
|
|
24
|
-
link: '/guide',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
text: 'API总览',
|
|
28
|
-
link: '/api',
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
socialLinks: {
|
|
33
|
-
github: 'https://cnb.cool/cnbkey/zcrkey/js-utils.git',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
});
|
package/.fatherrc.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'father';
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
// more father config: https://github.com/umijs/father/blob/master/docs/config.md
|
|
5
|
-
esm: {
|
|
6
|
-
output: 'dist',
|
|
7
|
-
},
|
|
8
|
-
umd: {
|
|
9
|
-
output: {
|
|
10
|
-
path: 'dist',
|
|
11
|
-
filename: 'index.umd.js',
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
});
|
package/.husky/commit-msg
DELETED
package/.husky/pre-commit
DELETED
package/.prettierignore
DELETED
package/.stylelintrc
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type * from './eventCenter';
|
|
2
|
-
export { default as CrEventCenter } from './eventCenter';
|
|
3
|
-
export type * from './objUtil';
|
|
4
|
-
export { default as CrObjUtil } from './objUtil';
|
|
5
|
-
export { default as CrStorage } from './storage';
|
|
6
|
-
export type * from './treeUtil';
|
|
7
|
-
export { default as CrTreeUtil } from './treeUtil';
|
|
8
|
-
export { default as CrUtil } from './util';
|
package/dist/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# CrEventCenter 事件发布订阅
|
|
2
|
-
|
|
3
|
-
事件发布订阅
|
|
4
|
-
|
|
5
|
-
- 推荐仅在原生 javascript 中使用
|
|
6
|
-
- 不推荐中在三大框架中使用,而是使用各家框架的状态管理库(存在问题,闭包函数未能及时更新 useState 中的值)
|
|
7
|
-
|
|
8
|
-
原生写法
|
|
9
|
-
|
|
10
|
-
```
|
|
11
|
-
import { CrEventCenter } from '@zcrkey/js-utils';
|
|
12
|
-
import type { TSubscription } from '@zcrkey/js-utils';
|
|
13
|
-
|
|
14
|
-
// 订阅事件
|
|
15
|
-
const subscription: TSubscription = CrEventCenter.on('xxx_xxx', (params) => {
|
|
16
|
-
console.log('params',params)
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
// 发布事件
|
|
20
|
-
CrEventCenter.emit('xxx_xxx',{a:1,b:2})
|
|
21
|
-
|
|
22
|
-
// 移除订阅事件
|
|
23
|
-
subscription.remove()
|
|
24
|
-
// 或者
|
|
25
|
-
CrEventCenter.off(subscription);
|
|
26
|
-
|
|
27
|
-
// 查找订阅事件
|
|
28
|
-
const item = CrEventCenter.find('xxx_xxx')
|
|
29
|
-
|
|
30
|
-
// 清除所有订阅事件
|
|
31
|
-
CrEventCenter.clear()
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* title: localStorage
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { CrStorage } from '@zcrkey/js-utils';
|
|
6
|
-
import React, { useState } from 'react';
|
|
7
|
-
|
|
8
|
-
const LOGIN_USER = 'loginUser';
|
|
9
|
-
|
|
10
|
-
export default () => {
|
|
11
|
-
const [data, setData] = useState<any>();
|
|
12
|
-
|
|
13
|
-
const onSet = () => {
|
|
14
|
-
// CrStorage.setLocalItem(LOGIN_USER, null);
|
|
15
|
-
// CrStorage.setLocalItem(LOGIN_USER, -1);
|
|
16
|
-
// CrStorage.setLocalItem(LOGIN_USER, undefined);
|
|
17
|
-
// CrStorage.setLocalItem(LOGIN_USER, {});
|
|
18
|
-
// CrStorage.setLocalItem(LOGIN_USER, []);
|
|
19
|
-
CrStorage.setLocalItem(LOGIN_USER, {
|
|
20
|
-
name: 'zcr',
|
|
21
|
-
sex: '男',
|
|
22
|
-
age: 18,
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const onGet = () => {
|
|
27
|
-
const data = CrStorage.getLocalItem(LOGIN_USER);
|
|
28
|
-
setData(data);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const onClear = () => {
|
|
32
|
-
CrStorage.removeLocalItem(LOGIN_USER);
|
|
33
|
-
setData('');
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const onAllClear = () => {
|
|
37
|
-
CrStorage.clearLocal();
|
|
38
|
-
setData('');
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<>
|
|
43
|
-
<div className="flex flex-direction">
|
|
44
|
-
<div className="text-lg">CrUtil.setLocalItem</div>
|
|
45
|
-
<div>
|
|
46
|
-
<button
|
|
47
|
-
type="button"
|
|
48
|
-
className="cr-btn line-blue radius"
|
|
49
|
-
onClick={onSet}
|
|
50
|
-
>
|
|
51
|
-
设置用户数据
|
|
52
|
-
</button>
|
|
53
|
-
</div>
|
|
54
|
-
<div className="text-lg">CrUtil.getLocalItem</div>
|
|
55
|
-
<div>
|
|
56
|
-
<button
|
|
57
|
-
type="button"
|
|
58
|
-
className="cr-btn line-blue radius"
|
|
59
|
-
onClick={onGet}
|
|
60
|
-
>
|
|
61
|
-
获取用户数据
|
|
62
|
-
</button>
|
|
63
|
-
</div>
|
|
64
|
-
<div className="text-lg">CrUtil.removeLocalItem</div>
|
|
65
|
-
<div>
|
|
66
|
-
<button
|
|
67
|
-
type="button"
|
|
68
|
-
className="cr-btn line-blue radius"
|
|
69
|
-
onClick={onClear}
|
|
70
|
-
>
|
|
71
|
-
清除用户数据
|
|
72
|
-
</button>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
<div className="text-lg">CrUtil.clearLocal</div>
|
|
76
|
-
<div>
|
|
77
|
-
<button
|
|
78
|
-
type="button"
|
|
79
|
-
className="cr-btn line-blue radius"
|
|
80
|
-
onClick={onAllClear}
|
|
81
|
-
>
|
|
82
|
-
清除全部
|
|
83
|
-
</button>
|
|
84
|
-
</div>
|
|
85
|
-
|
|
86
|
-
<div className="divider"></div>
|
|
87
|
-
|
|
88
|
-
<p>用户数据:{JSON.stringify(data)}</p>
|
|
89
|
-
</>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* title: sessionStorage
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { CrStorage } from '@zcrkey/js-utils';
|
|
6
|
-
import React, { useState } from 'react';
|
|
7
|
-
|
|
8
|
-
const LOGIN_USER = 'loginUser';
|
|
9
|
-
|
|
10
|
-
export default () => {
|
|
11
|
-
const [data, setData] = useState<any>();
|
|
12
|
-
|
|
13
|
-
const onSet = () => {
|
|
14
|
-
CrStorage.setSessionItem(LOGIN_USER, {
|
|
15
|
-
name: 'zcr',
|
|
16
|
-
sex: '男',
|
|
17
|
-
age: 18,
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const onGet = () => {
|
|
22
|
-
setData(CrStorage.getSessionItem(LOGIN_USER));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const onClear = () => {
|
|
26
|
-
CrStorage.removeSessionItem(LOGIN_USER);
|
|
27
|
-
setData('');
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const onAllClear = () => {
|
|
31
|
-
CrStorage.clearSession();
|
|
32
|
-
setData('');
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<>
|
|
37
|
-
<div className="flex flex-direction">
|
|
38
|
-
<div className="text-lg">CrUtil.setSessionItem</div>
|
|
39
|
-
<div>
|
|
40
|
-
<button
|
|
41
|
-
type="button"
|
|
42
|
-
className="cr-btn line-blue radius"
|
|
43
|
-
onClick={onSet}
|
|
44
|
-
>
|
|
45
|
-
设置用户数据
|
|
46
|
-
</button>
|
|
47
|
-
</div>
|
|
48
|
-
<div className="text-lg">CrUtil.getSessionItem</div>
|
|
49
|
-
<div>
|
|
50
|
-
<button
|
|
51
|
-
type="button"
|
|
52
|
-
className="cr-btn line-blue radius"
|
|
53
|
-
onClick={onGet}
|
|
54
|
-
>
|
|
55
|
-
获取用户数据
|
|
56
|
-
</button>
|
|
57
|
-
</div>
|
|
58
|
-
<div className="text-lg">CrUtil.removeSessionItem</div>
|
|
59
|
-
<div>
|
|
60
|
-
<button
|
|
61
|
-
type="button"
|
|
62
|
-
className="cr-btn line-blue radius"
|
|
63
|
-
onClick={onClear}
|
|
64
|
-
>
|
|
65
|
-
清除用户数据
|
|
66
|
-
</button>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
<div className="text-lg">CrUtil.clearSession</div>
|
|
70
|
-
<div>
|
|
71
|
-
<button
|
|
72
|
-
type="button"
|
|
73
|
-
className="cr-btn line-blue radius"
|
|
74
|
-
onClick={onAllClear}
|
|
75
|
-
>
|
|
76
|
-
清除全部
|
|
77
|
-
</button>
|
|
78
|
-
</div>
|
|
79
|
-
|
|
80
|
-
<div className="divider"></div>
|
|
81
|
-
|
|
82
|
-
<p>用户数据:{JSON.stringify(data)}</p>
|
|
83
|
-
</>
|
|
84
|
-
);
|
|
85
|
-
};
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* title: 基本使用
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { CrTreeUtil } from '@zcrkey/js-utils';
|
|
6
|
-
import React, { useState } from 'react';
|
|
7
|
-
|
|
8
|
-
const listData = [
|
|
9
|
-
{ id: '1', parentId: null, name: '节点 1' },
|
|
10
|
-
{ id: '1-1', parentId: '1', name: '节点 1-1' },
|
|
11
|
-
{ id: '1-1-1', parentId: '1-1', name: '节点 1-1-1' },
|
|
12
|
-
{ id: '1-1-2', parentId: '1-1', name: '节点 1-1-2' },
|
|
13
|
-
{ id: '1-2', parentId: '1', name: '节点 1-2' },
|
|
14
|
-
{ id: '1-2-1', parentId: '1-2', name: '节点 1-2-1' },
|
|
15
|
-
{ id: '1-2-1-1', parentId: '1-2-1', name: '节点 1-2-1-1' },
|
|
16
|
-
|
|
17
|
-
{ id: '2', parentId: null, name: '节点 2' },
|
|
18
|
-
{ id: '2-1', parentId: '2', name: '节点 2-1' },
|
|
19
|
-
{ id: '2-1-1', parentId: '2-1', name: '节点 2-1-1' },
|
|
20
|
-
{ id: '2-1-2', parentId: '2-1', name: '节点 2-1-2' },
|
|
21
|
-
{ id: '2-2', parentId: '2', name: '节点 2-2' },
|
|
22
|
-
|
|
23
|
-
{ id: '3', parentId: null, name: '节点 3' },
|
|
24
|
-
{ id: '3-1', parentId: '3', name: '节点 3-1' },
|
|
25
|
-
{ id: '3-1-1', parentId: '3-1', name: '节点 3-1-1' },
|
|
26
|
-
{ id: '3-1-1-1', parentId: '3-1-1', name: '节点 3-1-1-1' },
|
|
27
|
-
{ id: '3-2', parentId: '3', name: '节点 3-2' },
|
|
28
|
-
{ id: '3-2-1', parentId: '3-2', name: '节点 3-2-1' },
|
|
29
|
-
|
|
30
|
-
{ id: '4', parentId: null, name: '节点 4' },
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const treeData = [
|
|
34
|
-
{
|
|
35
|
-
id: '1',
|
|
36
|
-
parentId: null,
|
|
37
|
-
name: '节点 1',
|
|
38
|
-
children: [
|
|
39
|
-
{
|
|
40
|
-
id: '1-1',
|
|
41
|
-
parentId: '1',
|
|
42
|
-
name: '节点 1-1',
|
|
43
|
-
children: [
|
|
44
|
-
{
|
|
45
|
-
id: '1-1-1',
|
|
46
|
-
parentId: '1-1',
|
|
47
|
-
name: '节点 1-1-1',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: '1-1-2',
|
|
51
|
-
parentId: '1-1',
|
|
52
|
-
name: '节点 1-1-2',
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: '1-2',
|
|
58
|
-
parentId: '1',
|
|
59
|
-
name: '节点 1-2',
|
|
60
|
-
children: [
|
|
61
|
-
{
|
|
62
|
-
id: '1-2-1',
|
|
63
|
-
parentId: '1-2',
|
|
64
|
-
name: '节点 1-2-1',
|
|
65
|
-
children: [
|
|
66
|
-
{
|
|
67
|
-
id: '1-2-1-1',
|
|
68
|
-
parentId: '1-2-1',
|
|
69
|
-
name: '节点 1-2-1-1',
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
id: '2',
|
|
79
|
-
parentId: null,
|
|
80
|
-
name: '节点 2',
|
|
81
|
-
children: [
|
|
82
|
-
{
|
|
83
|
-
id: '2-1',
|
|
84
|
-
parentId: '2',
|
|
85
|
-
name: '节点 2-1',
|
|
86
|
-
children: [
|
|
87
|
-
{
|
|
88
|
-
id: '2-1-1',
|
|
89
|
-
parentId: '2-1',
|
|
90
|
-
name: '节点 2-1-1',
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: '2-1-2',
|
|
94
|
-
parentId: '2-1',
|
|
95
|
-
name: '节点 2-1-2',
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: '2-2',
|
|
101
|
-
parentId: '2',
|
|
102
|
-
name: '节点 2-2',
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
id: '3',
|
|
108
|
-
parentId: null,
|
|
109
|
-
name: '节点 3',
|
|
110
|
-
children: [
|
|
111
|
-
{
|
|
112
|
-
id: '3-1',
|
|
113
|
-
parentId: '3',
|
|
114
|
-
name: '节点 3-1',
|
|
115
|
-
children: [
|
|
116
|
-
{
|
|
117
|
-
id: '3-1-1',
|
|
118
|
-
parentId: '3-1',
|
|
119
|
-
name: '节点 3-1-1',
|
|
120
|
-
children: [
|
|
121
|
-
{
|
|
122
|
-
id: '3-1-1-1',
|
|
123
|
-
parentId: '3-1-1',
|
|
124
|
-
name: '节点 3-1-1-1',
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
id: '3-2',
|
|
132
|
-
parentId: '3',
|
|
133
|
-
name: '节点 3-2',
|
|
134
|
-
children: [
|
|
135
|
-
{
|
|
136
|
-
id: '3-2-1',
|
|
137
|
-
parentId: '3-2',
|
|
138
|
-
name: '节点 3-2-1',
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
id: '4',
|
|
146
|
-
parentId: null,
|
|
147
|
-
name: '节点 4',
|
|
148
|
-
},
|
|
149
|
-
];
|
|
150
|
-
|
|
151
|
-
export default () => {
|
|
152
|
-
const [result, setResult] = useState<any>({});
|
|
153
|
-
|
|
154
|
-
const listToTree = () => {
|
|
155
|
-
let res = CrTreeUtil.listToTree(listData, {
|
|
156
|
-
isDeepCopy: true,
|
|
157
|
-
});
|
|
158
|
-
setResult({
|
|
159
|
-
...result,
|
|
160
|
-
listToTree: res,
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const treeToList = () => {
|
|
165
|
-
let res = CrTreeUtil.treeToList(treeData, {
|
|
166
|
-
isDeepCopy: true,
|
|
167
|
-
});
|
|
168
|
-
setResult({
|
|
169
|
-
...result,
|
|
170
|
-
treeToList: res,
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const getFlatParentDatas = () => {
|
|
175
|
-
let res = CrTreeUtil.getFlatParentDatas(listData, '3-1-1-1', {
|
|
176
|
-
valueField: 'id',
|
|
177
|
-
getData: (item: any) => item,
|
|
178
|
-
});
|
|
179
|
-
setResult({
|
|
180
|
-
...result,
|
|
181
|
-
getFlatParentDatas: res,
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
<>
|
|
187
|
-
<div className="flex flex-direction">
|
|
188
|
-
<div>列表数据转树型数据</div>
|
|
189
|
-
<div className="text-lg">CrTreeUtil.listToTree</div>
|
|
190
|
-
<div>
|
|
191
|
-
<button
|
|
192
|
-
type="button"
|
|
193
|
-
className="cr-btn line-blue radius"
|
|
194
|
-
onClick={listToTree}
|
|
195
|
-
>
|
|
196
|
-
调用
|
|
197
|
-
</button>
|
|
198
|
-
<div>
|
|
199
|
-
<div style={{ display: 'inline-grid', width: '50%' }}>
|
|
200
|
-
<pre style={{ marginBottom: '0px' }}>
|
|
201
|
-
{JSON.stringify(listData, null, 2)}
|
|
202
|
-
</pre>
|
|
203
|
-
</div>
|
|
204
|
-
<div style={{ display: 'inline-grid', width: '50%' }}>
|
|
205
|
-
<pre style={{ marginBottom: '0px' }}>
|
|
206
|
-
{JSON.stringify(result.listToTree, null, 2)}
|
|
207
|
-
</pre>
|
|
208
|
-
</div>
|
|
209
|
-
</div>
|
|
210
|
-
</div>
|
|
211
|
-
</div>
|
|
212
|
-
<div className="divider"></div>
|
|
213
|
-
<div className="flex flex-direction">
|
|
214
|
-
<div>树型数据转列表数据</div>
|
|
215
|
-
<div className="text-lg">CrTreeUtil.treeToList</div>
|
|
216
|
-
<div>
|
|
217
|
-
<button
|
|
218
|
-
type="button"
|
|
219
|
-
className="cr-btn line-blue radius"
|
|
220
|
-
onClick={treeToList}
|
|
221
|
-
>
|
|
222
|
-
调用
|
|
223
|
-
</button>
|
|
224
|
-
<div>
|
|
225
|
-
<div style={{ display: 'inline-grid', width: '50%' }}>
|
|
226
|
-
<pre style={{ marginBottom: '0px' }}>
|
|
227
|
-
{JSON.stringify(treeData, null, 2)}
|
|
228
|
-
</pre>
|
|
229
|
-
</div>
|
|
230
|
-
<div style={{ display: 'inline-grid', width: '50%' }}>
|
|
231
|
-
<pre style={{ marginBottom: '0px' }}>
|
|
232
|
-
{JSON.stringify(result.treeToList, null, 2)}
|
|
233
|
-
</pre>
|
|
234
|
-
</div>
|
|
235
|
-
</div>
|
|
236
|
-
</div>
|
|
237
|
-
</div>
|
|
238
|
-
<div className="divider"></div>
|
|
239
|
-
<div className="flex flex-direction">
|
|
240
|
-
<div>获取扁平化父级数据</div>
|
|
241
|
-
<div className="text-lg">CrTreeUtil.getFlatParentDatas</div>
|
|
242
|
-
<div>
|
|
243
|
-
<button
|
|
244
|
-
type="button"
|
|
245
|
-
className="cr-btn line-blue radius"
|
|
246
|
-
onClick={getFlatParentDatas}
|
|
247
|
-
>
|
|
248
|
-
调用
|
|
249
|
-
</button>
|
|
250
|
-
<div>
|
|
251
|
-
<div style={{ display: 'inline-grid', width: '50%' }}>
|
|
252
|
-
<pre style={{ marginBottom: '0px' }}>
|
|
253
|
-
值:'3-1-1-1' 数据源:{JSON.stringify(listData, null, 2)}
|
|
254
|
-
</pre>
|
|
255
|
-
</div>
|
|
256
|
-
<div style={{ display: 'inline-grid', width: '50%' }}>
|
|
257
|
-
<pre style={{ marginBottom: '0px' }}>
|
|
258
|
-
{JSON.stringify(result.getFlatParentDatas, null, 2)}
|
|
259
|
-
</pre>
|
|
260
|
-
</div>
|
|
261
|
-
</div>
|
|
262
|
-
</div>
|
|
263
|
-
</div>
|
|
264
|
-
</>
|
|
265
|
-
);
|
|
266
|
-
};
|