@tuya-sat/sdf-main-sdk 0.0.1-beta.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.
- package/.vscode/settings.json +5 -0
- package/README.md +1 -0
- package/antd.less.overwrite.js +56 -0
- package/color.js +140 -0
- package/dark-variable.less +1449 -0
- package/package.json +74 -0
- package/scripts/gen-localize-file.mjs +56 -0
- package/src/App.less +156 -0
- package/src/App.tsx +87 -0
- package/src/api/index.ts +52 -0
- package/src/api/req.ts +23 -0
- package/src/api/res.ts +29 -0
- package/src/api/urls.ts +30 -0
- package/src/api/utils.ts +41 -0
- package/src/assets/imgs/404.svg +194 -0
- package/src/assets/imgs/reLogin.png +0 -0
- package/src/components/404/index.tsx +44 -0
- package/src/components/500/index.tsx +49 -0
- package/src/components/BCustomNav/index.module.less +17 -0
- package/src/components/BCustomNav/index.tsx +108 -0
- package/src/components/BForgot/index.module.less +5 -0
- package/src/components/BForgot/index.tsx +96 -0
- package/src/components/BHeaderUser/account.png +0 -0
- package/src/components/BHeaderUser/app-scan-en.png +0 -0
- package/src/components/BHeaderUser/app-scan-zh.png +0 -0
- package/src/components/BHeaderUser/app-scan.png +0 -0
- package/src/components/BHeaderUser/components/BSwitchLang/index.module.less +6 -0
- package/src/components/BHeaderUser/components/BSwitchLang/index.tsx +56 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/Content.tsx +199 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/index.module.less +11 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/Drawer/index.tsx +27 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/hooks.ts +104 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/index.module.less +70 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/index.tsx +184 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/table/index.tsx +184 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/table/read.tsx +67 -0
- package/src/components/BHeaderUser/components/Badge/components/Notice/tools/index.tsx +116 -0
- package/src/components/BHeaderUser/components/Badge/index.module.less +99 -0
- package/src/components/BHeaderUser/components/Badge/index.tsx +179 -0
- package/src/components/BHeaderUser/index.module.less +105 -0
- package/src/components/BHeaderUser/index.tsx +261 -0
- package/src/components/BHeaderUser/logout.tsx +26 -0
- package/src/components/BLayout/components/Header/index.module.less +27 -0
- package/src/components/BLayout/components/Header/index.tsx +36 -0
- package/src/components/BLayout/components/Layout/empty.tsx +35 -0
- package/src/components/BLayout/components/Layout/emptyPage.png +0 -0
- package/src/components/BLayout/components/Layout/index.tsx +72 -0
- package/src/components/BLayout/components/Logo.tsx +6 -0
- package/src/components/BLayout/components/Menu/collapse.tsx +41 -0
- package/src/components/BLayout/components/Menu/image/close.tsx +26 -0
- package/src/components/BLayout/components/Menu/image/closedefault.tsx +26 -0
- package/src/components/BLayout/components/Menu/image/open.tsx +38 -0
- package/src/components/BLayout/components/Menu/image/opendefault.tsx +38 -0
- package/src/components/BLayout/components/Menu/index.module.less +125 -0
- package/src/components/BLayout/components/Menu/index.tsx +244 -0
- package/src/components/BLayout/components/MenuIcon.module.less +5 -0
- package/src/components/BLayout/components/MenuIcon.tsx +46 -0
- package/src/components/BLayout/components/MultiSider/index.module.less +104 -0
- package/src/components/BLayout/components/MultiSider/index.tsx +172 -0
- package/src/components/BLayout/components/Sider/index.less +64 -0
- package/src/components/BLayout/components/Sider/index.module.less +17 -0
- package/src/components/BLayout/components/Sider/index.tsx +34 -0
- package/src/components/BLayout/index.tsx +78 -0
- package/src/components/BLayoutLogin/index.module.less +65 -0
- package/src/components/BLayoutLogin/index.tsx +68 -0
- package/src/components/BLayoutLogin/login.jpg +0 -0
- package/src/components/BLogin/component/Clause/index.module.less +25 -0
- package/src/components/BLogin/component/Clause/index.tsx +58 -0
- package/src/components/BLogin/component/ForgotBtn/index.module.less +9 -0
- package/src/components/BLogin/component/ForgotBtn/index.tsx +18 -0
- package/src/components/BLogin/component/Password/index.tsx +39 -0
- package/src/components/BLogin/component/SubmitBtn/index.tsx +30 -0
- package/src/components/BLogin/component/TenanSpace/index.tsx +28 -0
- package/src/components/BLogin/component/Title/index.module.less +6 -0
- package/src/components/BLogin/component/Title/index.tsx +12 -0
- package/src/components/BLogin/component/UserName/index.tsx +48 -0
- package/src/components/BLogin/component/VerifyCode/index.module.less +11 -0
- package/src/components/BLogin/component/VerifyCode/index.tsx +165 -0
- package/src/components/BLogin/index.module.less +31 -0
- package/src/components/BLogin/index.tsx +210 -0
- package/src/components/BRegister/components/TenantName/index.tsx +26 -0
- package/src/components/BRegister/index.module.less +5 -0
- package/src/components/BRegister/index.tsx +71 -0
- package/src/components/Back/index.tsx +25 -0
- package/src/components/IconFont/font.js +66 -0
- package/src/components/IconFont/index.tsx +18 -0
- package/src/components/MicroComponent/Header/index.module.less +7 -0
- package/src/components/MicroComponent/Header/index.tsx +220 -0
- package/src/components/PForgot/index.tsx +10 -0
- package/src/components/PLogin/index.tsx +12 -0
- package/src/components/PRegister/index.tsx +10 -0
- package/src/components/PSetting/index.module.less +53 -0
- package/src/components/PSetting/index.tsx +420 -0
- package/src/constant/chargeStatus.ts +6 -0
- package/src/constant/imgs.ts +6 -0
- package/src/constant/index.ts +293 -0
- package/src/dark-variable.less +1449 -0
- package/src/global.d.ts +54 -0
- package/src/hooks/index.ts +133 -0
- package/src/index.css +1493 -0
- package/src/index.tsx +105 -0
- package/src/lang/en.json +266 -0
- package/src/lang/index.ts +44 -0
- package/src/lang/utils.ts +285 -0
- package/src/lang/zh.json +270 -0
- package/src/micro-script/theme/index.ts +29 -0
- package/src/micro-script/theme/theme-css/static.js +73 -0
- package/src/micro-script/theme/theme-css/subscriber.ts +201 -0
- package/src/micro-script/theme/util/index.ts +58 -0
- package/src/mqtt/index.ts +121 -0
- package/src/pages/403.tsx +18 -0
- package/src/pages/404.tsx +17 -0
- package/src/pages/expiration.tsx +23 -0
- package/src/pages/forgot.tsx +9 -0
- package/src/pages/home/index.tsx +172 -0
- package/src/pages/home/setting/index.tsx +7 -0
- package/src/pages/index.ts +50 -0
- package/src/pages/login.tsx +46 -0
- package/src/pages/register.tsx +9 -0
- package/src/pages/relogin/index.module.less +0 -0
- package/src/pages/relogin/index.tsx +54 -0
- package/src/plugins/index.ts +11 -0
- package/src/public-path.js +8 -0
- package/src/qiankun/globalState.ts +6 -0
- package/src/qiankun/index.ts +174 -0
- package/src/qiankun/utils/index.ts +69 -0
- package/src/qiankun/xhook/index.ts +193 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/sentry/index.ts +33 -0
- package/src/sky/index.ts +57 -0
- package/src/theme/custom-dark.less +64 -0
- package/src/theme/custom-light.less +48 -0
- package/src/theme/index.less +327 -0
- package/src/theme/variable.less +13 -0
- package/src/utils/checkPass.ts +21 -0
- package/src/utils/common.ts +195 -0
- package/src/utils/eventBus.ts +112 -0
- package/src/utils/gt.js +293 -0
- package/src/utils/index.ts +89 -0
- package/src/utils/theme/base.ts +110 -0
- package/src/utils/theme/changeCssVariable.ts +157 -0
- package/src/utils/theme/changeMenuCssVariable.ts +176 -0
- package/src/utils/theme/index.ts +85 -0
- package/src/utils/theme/store.ts +37 -0
- package/tsconfig.json +28 -0
- package/typings.d.ts +10 -0
- package/webpack.config.js +103 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const OpenSvg = () => {
|
|
2
|
+
return (
|
|
3
|
+
<svg
|
|
4
|
+
width="14"
|
|
5
|
+
height="40"
|
|
6
|
+
viewBox="0 0 14 40"
|
|
7
|
+
fill="none"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
>
|
|
10
|
+
<path
|
|
11
|
+
d="M0 0L10.7032 1.91128C12.6109 2.25194 14 3.9111 14 5.84899V34.151C14 36.0889 12.6109 37.7481 10.7032 38.0887L0 40V0Z"
|
|
12
|
+
fill="#1890FF"
|
|
13
|
+
/>
|
|
14
|
+
<g clip-path="url(#clip0_253_94238)">
|
|
15
|
+
<path
|
|
16
|
+
d="M4.26078 16.5698C4.02867 16.3377 3.65236 16.3377 3.42026 16.5698V16.5698C3.18817 16.8019 3.18816 17.1782 3.42025 17.4103L6.14554 20.1357L3.42025 22.8612C3.18816 23.0933 3.18817 23.4696 3.42026 23.7017V23.7017C3.65236 23.9338 4.02867 23.9338 4.26077 23.7017L7.40646 20.556C7.62634 20.3361 7.63792 19.9868 7.44118 19.7533L7.40646 19.7155L4.26078 16.5698Z"
|
|
17
|
+
fill="white"
|
|
18
|
+
/>
|
|
19
|
+
<path
|
|
20
|
+
d="M7.82669 16.5698C7.59459 16.3377 7.21828 16.3377 6.98618 16.5698V16.5698C6.75408 16.8019 6.75408 17.1782 6.98617 17.4103L9.71146 20.1357L6.98617 22.8612C6.75408 23.0933 6.75408 23.4696 6.98618 23.7017V23.7017C7.21828 23.9338 7.59459 23.9338 7.82669 23.7017L10.9724 20.556C11.1923 20.3361 11.2038 19.9868 11.0071 19.7533L10.9724 19.7155L7.82669 16.5698Z"
|
|
21
|
+
fill="white"
|
|
22
|
+
/>
|
|
23
|
+
</g>
|
|
24
|
+
<defs>
|
|
25
|
+
<clipPath id="clip0_253_94238">
|
|
26
|
+
<rect
|
|
27
|
+
width="10"
|
|
28
|
+
height="10"
|
|
29
|
+
fill="white"
|
|
30
|
+
transform="translate(12 25) rotate(-180)"
|
|
31
|
+
/>
|
|
32
|
+
</clipPath>
|
|
33
|
+
</defs>
|
|
34
|
+
</svg>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default OpenSvg;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const OpenDefaultSvg = () => {
|
|
2
|
+
return (
|
|
3
|
+
<svg
|
|
4
|
+
width="14"
|
|
5
|
+
height="40"
|
|
6
|
+
viewBox="0 0 14 40"
|
|
7
|
+
fill="none"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
>
|
|
10
|
+
<path
|
|
11
|
+
d="M0 0L10.7032 1.91128C12.6109 2.25194 14 3.9111 14 5.84899V34.151C14 36.0889 12.6109 37.7481 10.7032 38.0887L0 40V0Z"
|
|
12
|
+
fill="#E6E9EA"
|
|
13
|
+
/>
|
|
14
|
+
<g clip-path="url(#clip0_253_94229)">
|
|
15
|
+
<path
|
|
16
|
+
d="M4.26076 16.5698C4.02866 16.3377 3.65235 16.3377 3.42025 16.5698V16.5698C3.18815 16.8019 3.18815 17.1782 3.42024 17.4103L6.14553 20.1357L3.42024 22.8612C3.18815 23.0933 3.18815 23.4696 3.42025 23.7017V23.7017C3.65235 23.9338 4.02866 23.9338 4.26076 23.7017L7.40645 20.556C7.62633 20.3361 7.6379 19.9868 7.44116 19.7533L7.40645 19.7155L4.26076 16.5698Z"
|
|
17
|
+
fill="black"
|
|
18
|
+
/>
|
|
19
|
+
<path
|
|
20
|
+
d="M7.82669 16.5698C7.59459 16.3377 7.21828 16.3377 6.98618 16.5698V16.5698C6.75408 16.8019 6.75408 17.1782 6.98617 17.4103L9.71146 20.1357L6.98617 22.8612C6.75408 23.0933 6.75408 23.4696 6.98618 23.7017V23.7017C7.21828 23.9338 7.59459 23.9338 7.82669 23.7017L10.9724 20.556C11.1923 20.3361 11.2038 19.9868 11.0071 19.7533L10.9724 19.7155L7.82669 16.5698Z"
|
|
21
|
+
fill="black"
|
|
22
|
+
/>
|
|
23
|
+
</g>
|
|
24
|
+
<defs>
|
|
25
|
+
<clipPath id="clip0_253_94229">
|
|
26
|
+
<rect
|
|
27
|
+
width="10"
|
|
28
|
+
height="10"
|
|
29
|
+
fill="white"
|
|
30
|
+
transform="translate(12 25) rotate(-180)"
|
|
31
|
+
/>
|
|
32
|
+
</clipPath>
|
|
33
|
+
</defs>
|
|
34
|
+
</svg>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default OpenDefaultSvg;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
.group {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-flow: column nowrap;
|
|
6
|
+
|
|
7
|
+
.title {
|
|
8
|
+
width: 100%;
|
|
9
|
+
line-height: 48px;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
text-overflow: ellipsis;
|
|
13
|
+
font-weight: normal;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.menu {
|
|
17
|
+
flex: 1;
|
|
18
|
+
border-right: none;
|
|
19
|
+
overflow-y: overlay;
|
|
20
|
+
overflow-x: hidden;
|
|
21
|
+
&::-webkit-scrollbar {
|
|
22
|
+
width: 6px;
|
|
23
|
+
}
|
|
24
|
+
&::-webkit-scrollbar-track {
|
|
25
|
+
width: 6px;
|
|
26
|
+
}
|
|
27
|
+
// :global {
|
|
28
|
+
// .main-menu-sub.main-menu-inline {
|
|
29
|
+
// background: inherit;
|
|
30
|
+
// }
|
|
31
|
+
// }
|
|
32
|
+
.menu-li {
|
|
33
|
+
margin: 4px 0;
|
|
34
|
+
// 去除菜单选中时右侧boder
|
|
35
|
+
&::after {
|
|
36
|
+
display: none;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
:global {
|
|
41
|
+
.main-menu-inline-collapsed {
|
|
42
|
+
overflow-y: overlay;
|
|
43
|
+
background: inherit;
|
|
44
|
+
&::-webkit-scrollbar {
|
|
45
|
+
display: none !important;
|
|
46
|
+
}
|
|
47
|
+
&:hover {
|
|
48
|
+
&::-webkit-scrollbar {
|
|
49
|
+
display: inherit !important;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
.group-normal {
|
|
55
|
+
:global {
|
|
56
|
+
.main-menu-item-only-child > .main-menu-title-content {
|
|
57
|
+
padding-left: 5px;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
.collapsedBar {
|
|
62
|
+
height: 40px;
|
|
63
|
+
line-height: 40px;
|
|
64
|
+
padding-left: 16px;
|
|
65
|
+
span {
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
user-select: none;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.preview {
|
|
73
|
+
margin-left: 10px;
|
|
74
|
+
font-size: 12px;
|
|
75
|
+
line-height: 20px;
|
|
76
|
+
padding: 0 8px;
|
|
77
|
+
height: 22px;
|
|
78
|
+
border-radius: 2px;
|
|
79
|
+
display: inline-block;
|
|
80
|
+
}
|
|
81
|
+
.trial {
|
|
82
|
+
margin-left: 10px;
|
|
83
|
+
font-size: 12px;
|
|
84
|
+
line-height: 20px;
|
|
85
|
+
padding: 0px 8px;
|
|
86
|
+
height: 22px;
|
|
87
|
+
border-radius: 2px;
|
|
88
|
+
box-sizing: border-box;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.latest {
|
|
92
|
+
margin-left: 10px;
|
|
93
|
+
font-size: 12px;
|
|
94
|
+
line-height: 20px;
|
|
95
|
+
height: 22px;
|
|
96
|
+
padding: 0px 8px;
|
|
97
|
+
border-radius: 2px;
|
|
98
|
+
box-sizing: border-box;
|
|
99
|
+
}
|
|
100
|
+
.collapsed {
|
|
101
|
+
position: absolute;
|
|
102
|
+
right: 0;
|
|
103
|
+
top: 0;
|
|
104
|
+
width: 0px;
|
|
105
|
+
height: 100%;
|
|
106
|
+
.line {
|
|
107
|
+
position: absolute;
|
|
108
|
+
right: -1px;
|
|
109
|
+
top: 0;
|
|
110
|
+
width: 1px;
|
|
111
|
+
height: 100%;
|
|
112
|
+
}
|
|
113
|
+
.svgContainer {
|
|
114
|
+
position: absolute;
|
|
115
|
+
right: 0px;
|
|
116
|
+
top: 50%;
|
|
117
|
+
width: 20px;
|
|
118
|
+
height: 60px;
|
|
119
|
+
transform: translate(100%, -50%);
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
& > svg {
|
|
122
|
+
margin-top: 10px;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { useEffect, useState, useRef } from 'react';
|
|
2
|
+
import { Menu } from 'antd';
|
|
3
|
+
import { NavLink, useLocation } from 'react-router-dom';
|
|
4
|
+
import MenuIcon from '../MenuIcon';
|
|
5
|
+
import { findEntry } from '@/utils/common';
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
import styles from './index.module.less';
|
|
8
|
+
import { useTranslation } from 'react-i18next';
|
|
9
|
+
|
|
10
|
+
export enum MenuType {
|
|
11
|
+
GROUP = 'group',
|
|
12
|
+
NORMAL = 'normal',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { SubMenu, Item } = Menu;
|
|
16
|
+
|
|
17
|
+
const Icon = ({ icon, mode }) => {
|
|
18
|
+
return (
|
|
19
|
+
<span className="anticon">
|
|
20
|
+
<MenuIcon mode={mode} src={icon} />
|
|
21
|
+
</span>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export interface IMenu {
|
|
26
|
+
entry_id: string;
|
|
27
|
+
entry_name: string;
|
|
28
|
+
entry_type: 'entry' | 'group';
|
|
29
|
+
icon: string;
|
|
30
|
+
path: string;
|
|
31
|
+
sub_entry_list: IMenu[];
|
|
32
|
+
tag_code: 'STABLE' | 'LATEST' | 'PREVIEW' | 'TRIAL';
|
|
33
|
+
[k: string]: any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface IMenuProps {
|
|
37
|
+
name?: string;
|
|
38
|
+
menus: Array<IMenu>;
|
|
39
|
+
showCollapsed?: boolean;
|
|
40
|
+
mode?: MenuType;
|
|
41
|
+
collapsed: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let qkSetSelectedKeys = null;
|
|
45
|
+
let qkSetKeys = null;
|
|
46
|
+
|
|
47
|
+
export const modifySelectedMenu = (path: string) => {
|
|
48
|
+
const paths = window.location.pathname.split('/').filter((item) => !!item);
|
|
49
|
+
if (paths.length >= 2) {
|
|
50
|
+
const basePath = `/${paths[0]}/${paths[1]}`;
|
|
51
|
+
const pathname = `/${basePath}${path}`;
|
|
52
|
+
qkSetSelectedKeys([pathname]);
|
|
53
|
+
qkSetKeys([basePath]);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const usePrevious = (value) => {
|
|
58
|
+
const ref = useRef();
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
ref.current = value;
|
|
61
|
+
}, [value]);
|
|
62
|
+
return ref.current;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// eslint-disable-next-line import/no-anonymous-default-export
|
|
66
|
+
export default ({
|
|
67
|
+
name,
|
|
68
|
+
menus,
|
|
69
|
+
showCollapsed,
|
|
70
|
+
collapsed,
|
|
71
|
+
mode,
|
|
72
|
+
}: IMenuProps) => {
|
|
73
|
+
const { pathname } = useLocation();
|
|
74
|
+
const [openKeys, setKeys] = useState<Array<string>>([]);
|
|
75
|
+
const prePathname = usePrevious(pathname);
|
|
76
|
+
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
77
|
+
const { t } = useTranslation();
|
|
78
|
+
|
|
79
|
+
qkSetSelectedKeys = setSelectedKeys;
|
|
80
|
+
qkSetKeys = setKeys;
|
|
81
|
+
|
|
82
|
+
const searchSelectPath = (menus, pathname, paths) => {
|
|
83
|
+
const entry = findEntry(menus, pathname);
|
|
84
|
+
if (entry) {
|
|
85
|
+
if (
|
|
86
|
+
window.location.pathname.split('/')?.filter((item) => !!item)
|
|
87
|
+
?.length === 4
|
|
88
|
+
) {
|
|
89
|
+
setSelectedKeys([window.location.pathname]);
|
|
90
|
+
} else {
|
|
91
|
+
setSelectedKeys([entry.path]);
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
if (paths.length > 2) {
|
|
95
|
+
const zPahts = paths.slice(0, paths.length - 1);
|
|
96
|
+
searchSelectPath(
|
|
97
|
+
menus,
|
|
98
|
+
zPahts.reduce((pre, cur) => pre + '/' + cur, ''),
|
|
99
|
+
zPahts,
|
|
100
|
+
);
|
|
101
|
+
} else if (paths.length === 2) {
|
|
102
|
+
if (menus.filter((item) => item.path === pathname).length > 0) {
|
|
103
|
+
setSelectedKeys([pathname]);
|
|
104
|
+
} else {
|
|
105
|
+
setSelectedKeys([prePathname]);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (pathname !== '/') {
|
|
113
|
+
const paths = pathname.split('/').filter((item) => !!item);
|
|
114
|
+
searchSelectPath(menus, pathname, paths);
|
|
115
|
+
}
|
|
116
|
+
}, [pathname, menus]);
|
|
117
|
+
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
const keys = pathname.split('/').slice(0, 3).join('/');
|
|
120
|
+
setKeys([keys]);
|
|
121
|
+
}, [pathname]);
|
|
122
|
+
const onOpenKeys = (openKeys) => {
|
|
123
|
+
setKeys(openKeys);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
*
|
|
128
|
+
* @param entry 菜单名称
|
|
129
|
+
* @param tag 菜单所属tag
|
|
130
|
+
* @param isSubMenu 是否有子菜单
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
const tag = (entry, tag, isSubMenu) => {
|
|
134
|
+
const menuWidth = tag === 'STABLE' ? '100%' : `calc(100% - 68px)`;
|
|
135
|
+
return (
|
|
136
|
+
<div style={{ width: '100%', display: 'flex', alignItems: 'center' }}>
|
|
137
|
+
<span
|
|
138
|
+
style={{
|
|
139
|
+
maxWidth: menuWidth,
|
|
140
|
+
overflow: 'hidden',
|
|
141
|
+
textOverflow: 'ellipsis',
|
|
142
|
+
whiteSpace: 'nowrap',
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
{entry}
|
|
146
|
+
</span>
|
|
147
|
+
{tag === 'STABLE' ? null : !isSubMenu ? (
|
|
148
|
+
<span
|
|
149
|
+
className={
|
|
150
|
+
tag === 'PREVIEW'
|
|
151
|
+
? cx(styles['preview'], 'main-app-tag-priview')
|
|
152
|
+
: tag === 'TRIAL'
|
|
153
|
+
? cx(styles['trial'], 'main-app-tag-trial')
|
|
154
|
+
: cx(styles['latest'], 'main-app-tag-latest')
|
|
155
|
+
}
|
|
156
|
+
>
|
|
157
|
+
{tag === 'PREVIEW'
|
|
158
|
+
? t('menu.edition.preview')
|
|
159
|
+
: tag === 'TRIAL'
|
|
160
|
+
? t('menu.edition.trial')
|
|
161
|
+
: t('menu.edition.latest')}
|
|
162
|
+
</span>
|
|
163
|
+
) : null}
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
const renderMenu = (entries, isSubmenu, hasSubMenu = false) => {
|
|
168
|
+
return entries?.map((entry) => {
|
|
169
|
+
const subMenu = entry.sub_entry_list && entry.sub_entry_list.length;
|
|
170
|
+
const tagLabel = tag(
|
|
171
|
+
entry.entry_name,
|
|
172
|
+
entry.tag_code ? entry.tag_code : 'STABLE',
|
|
173
|
+
hasSubMenu,
|
|
174
|
+
);
|
|
175
|
+
if (subMenu) {
|
|
176
|
+
return (
|
|
177
|
+
<SubMenu
|
|
178
|
+
title={tagLabel}
|
|
179
|
+
key={entry.path}
|
|
180
|
+
className={cx(
|
|
181
|
+
styles['menu-submenu'],
|
|
182
|
+
mode === 'normal' &&
|
|
183
|
+
collapsed &&
|
|
184
|
+
selectedKeys[0].indexOf(entry.path) !== -1
|
|
185
|
+
? 'main-app-menu-collapsed-selected'
|
|
186
|
+
: null,
|
|
187
|
+
)}
|
|
188
|
+
icon={
|
|
189
|
+
!!entry.icon && showCollapsed ? (
|
|
190
|
+
<Icon mode={mode} icon={entry.icon} />
|
|
191
|
+
) : null
|
|
192
|
+
}
|
|
193
|
+
>
|
|
194
|
+
{renderMenu(entry.sub_entry_list, true, true)}
|
|
195
|
+
</SubMenu>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
const isIcon = !!entry.icon && showCollapsed && !isSubmenu;
|
|
199
|
+
return (
|
|
200
|
+
<Item
|
|
201
|
+
title={entry.entry_name}
|
|
202
|
+
className={styles['menu-li']}
|
|
203
|
+
key={entry.path}
|
|
204
|
+
icon={isIcon ? <Icon mode={mode} icon={entry.icon} /> : null}
|
|
205
|
+
>
|
|
206
|
+
<NavLink to={entry.path}>{tagLabel}</NavLink>
|
|
207
|
+
</Item>
|
|
208
|
+
);
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
<div
|
|
214
|
+
className={cx(
|
|
215
|
+
styles.group,
|
|
216
|
+
'main-app-menu-group',
|
|
217
|
+
mode === 'normal' ? null : 'main-app-menu-group-mode',
|
|
218
|
+
)}
|
|
219
|
+
>
|
|
220
|
+
{name && (
|
|
221
|
+
<div className={cx(styles['title'], 'main-app-menu-group-title')}>
|
|
222
|
+
<span style={{ marginLeft: '16px' }}> {name}</span>
|
|
223
|
+
</div>
|
|
224
|
+
)}
|
|
225
|
+
<Menu
|
|
226
|
+
className={cx(
|
|
227
|
+
{
|
|
228
|
+
[styles.menu]: true,
|
|
229
|
+
[styles['group-normal']]: mode === MenuType.NORMAL,
|
|
230
|
+
},
|
|
231
|
+
'main-app-menu-group-menu',
|
|
232
|
+
)}
|
|
233
|
+
mode="inline"
|
|
234
|
+
selectedKeys={selectedKeys}
|
|
235
|
+
openKeys={openKeys}
|
|
236
|
+
inlineIndent={mode === MenuType.GROUP ? 16 : 17}
|
|
237
|
+
inlineCollapsed={collapsed}
|
|
238
|
+
onOpenChange={onOpenKeys}
|
|
239
|
+
>
|
|
240
|
+
{renderMenu(menus, false)}
|
|
241
|
+
</Menu>
|
|
242
|
+
</div>
|
|
243
|
+
);
|
|
244
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
import { MenuType } from './Menu';
|
|
4
|
+
import styled from './MenuIcon.module.less';
|
|
5
|
+
interface IconProps {
|
|
6
|
+
src: string;
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
mode?: MenuType;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const iconUrlReg = /^((https?:)?\/\/|\/)/;
|
|
12
|
+
const MenuIcon = ({ src, mode, style = {} }: IconProps) => {
|
|
13
|
+
const isUrl = iconUrlReg.test(src);
|
|
14
|
+
const iconStyle = {
|
|
15
|
+
width: 16,
|
|
16
|
+
height: 16,
|
|
17
|
+
marginTop: isUrl ? -2 : 1,
|
|
18
|
+
...style,
|
|
19
|
+
};
|
|
20
|
+
return (
|
|
21
|
+
<span
|
|
22
|
+
className={cx(styled['main-menu-item-icon'], 'main-menu-icon')}
|
|
23
|
+
style={
|
|
24
|
+
mode === 'normal'
|
|
25
|
+
? { height: '40px' }
|
|
26
|
+
: { height: '16px', margin: '0 0 4px' }
|
|
27
|
+
}
|
|
28
|
+
>
|
|
29
|
+
{isUrl ? (
|
|
30
|
+
<img src={src} alt="" style={iconStyle} />
|
|
31
|
+
) : (
|
|
32
|
+
<svg
|
|
33
|
+
style={iconStyle}
|
|
34
|
+
viewBox="0 0 1024 1024"
|
|
35
|
+
version="1.1"
|
|
36
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
37
|
+
fill="currentColor"
|
|
38
|
+
>
|
|
39
|
+
<path d={src} />
|
|
40
|
+
</svg>
|
|
41
|
+
)}
|
|
42
|
+
</span>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default MenuIcon;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
@group-with: 80px;
|
|
2
|
+
|
|
3
|
+
.sider {
|
|
4
|
+
height: calc(100vh - 48px);
|
|
5
|
+
background-color: #fff;
|
|
6
|
+
z-index: 100;
|
|
7
|
+
/**
|
|
8
|
+
* cover antd style -s
|
|
9
|
+
*/
|
|
10
|
+
flex: 0 0 auto !important;
|
|
11
|
+
width: auto !important;
|
|
12
|
+
max-width: 400px !important;
|
|
13
|
+
min-width: 0px !important;
|
|
14
|
+
/**
|
|
15
|
+
* cover antd style -e
|
|
16
|
+
*/
|
|
17
|
+
:global {
|
|
18
|
+
.main-layout-sider-children {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: flex-start;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
.menuContainer {
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 100%;
|
|
26
|
+
position: relative;
|
|
27
|
+
transition: all 0.3s;
|
|
28
|
+
}
|
|
29
|
+
.group {
|
|
30
|
+
padding-top: 16px;
|
|
31
|
+
height: 100%;
|
|
32
|
+
padding-left: 0;
|
|
33
|
+
overflow-y: overlay;
|
|
34
|
+
min-width: @group-with;
|
|
35
|
+
overflow-x: hidden;
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
.group-menu {
|
|
39
|
+
margin: 4px 0;
|
|
40
|
+
}
|
|
41
|
+
&::-webkit-scrollbar {
|
|
42
|
+
width: 6px;
|
|
43
|
+
}
|
|
44
|
+
&::-webkit-scrollbar-track {
|
|
45
|
+
width: 6px;
|
|
46
|
+
}
|
|
47
|
+
.fakeMenu182 {
|
|
48
|
+
width: 182px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.fakeMenu156 {
|
|
52
|
+
width: 156px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.fakeMenu132 {
|
|
56
|
+
width: 132px;
|
|
57
|
+
}
|
|
58
|
+
.fakeMenu {
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: 0;
|
|
61
|
+
left: @group-with;
|
|
62
|
+
height: 100%;
|
|
63
|
+
transform: translate(-100%, 0);
|
|
64
|
+
transition: all 0.3s;
|
|
65
|
+
transition-delay: 0.2s;
|
|
66
|
+
// background-color: #fff;
|
|
67
|
+
z-index: 1;
|
|
68
|
+
&:hover {
|
|
69
|
+
transform: translate(0, 0);
|
|
70
|
+
z-index: 2;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
.groupCover {
|
|
74
|
+
position: absolute;
|
|
75
|
+
z-index: 3;
|
|
76
|
+
left: 0;
|
|
77
|
+
top: 0;
|
|
78
|
+
width: @group-with;
|
|
79
|
+
height: 100%;
|
|
80
|
+
}
|
|
81
|
+
.groupItem {
|
|
82
|
+
width: @group-with - 1px;
|
|
83
|
+
height: 42px;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-flow: column nowrap;
|
|
87
|
+
justify-content: space-around;
|
|
88
|
+
align-items: center;
|
|
89
|
+
padding: 11px 0;
|
|
90
|
+
box-sizing: content-box;
|
|
91
|
+
.groupName {
|
|
92
|
+
text-align: center;
|
|
93
|
+
width: 100%;
|
|
94
|
+
white-space: nowrap;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
text-overflow: ellipsis;
|
|
97
|
+
}
|
|
98
|
+
&:hover + .fakeMenu {
|
|
99
|
+
transform: translateX(0);
|
|
100
|
+
z-index: 2;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|