tntd 1.4.6 → 1.4.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/components/Layout/HeaderActions.js +90 -128
- package/components/LoadingButton/index.js +11 -15
- package/dist/stats.json +4958 -4958
- package/dist/tntd.js +1 -1
- package/es/Layout/HeaderActions.js +10 -10
- package/es/LoadingButton/index.js +20 -10
- package/lib/ArrayInput/icon.js +27 -31
- package/lib/ArrayInput/index.js +211 -298
- package/lib/AuthContext.js +2 -13
- package/lib/Columns/index.js +71 -100
- package/lib/DevelopmentLogin/LoginModal.js +79 -141
- package/lib/DevelopmentLogin/index.js +28 -55
- package/lib/Ellipsis/Svg/CopySVG.js +23 -71
- package/lib/Ellipsis/Svg/TickSVG.js +17 -49
- package/lib/Ellipsis/index.js +148 -154
- package/lib/Handle/index.js +72 -109
- package/lib/Icon/fonts/iconfont.js +1 -43
- package/lib/Icon/iconList.js +119 -8
- package/lib/Icon/index.js +13 -45
- package/lib/Img/Contain.js +49 -81
- package/lib/Img/Cover.js +88 -136
- package/lib/Img/index.js +36 -89
- package/lib/Layout/ActionsContext.js +2 -11
- package/lib/Layout/AppList.js +262 -256
- package/lib/Layout/Application.js +119 -135
- package/lib/Layout/Avatar.js +137 -137
- package/lib/Layout/CompatibleLanguage.js +214 -195
- package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
- package/lib/Layout/EnterpriseLayout/Language.js +75 -100
- package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
- package/lib/Layout/EnterpriseLayout/index.js +32 -45
- package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
- package/lib/Layout/GlobalNavigation/index.js +110 -158
- package/lib/Layout/Header.js +165 -116
- package/lib/Layout/HeaderActions.js +132 -129
- package/lib/Layout/HeaderNavs.js +90 -113
- package/lib/Layout/HeaderTabs.js +312 -278
- package/lib/Layout/Iconfont.js +2 -15
- package/lib/Layout/Language.js +63 -102
- package/lib/Layout/Layout.js +272 -261
- package/lib/Layout/Logo.js +132 -87
- package/lib/Layout/OrgAppList.js +440 -319
- package/lib/Layout/SideMenu.js +429 -343
- package/lib/Layout/Theme.js +95 -124
- package/lib/Layout/checkAuth.js +21 -35
- package/lib/Layout/createActions.js +38 -51
- package/lib/Layout/images/index.js +33 -41
- package/lib/Layout/index.js +110 -161
- package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
- package/lib/Layout/paaslayout/Header.js +84 -90
- package/lib/Layout/paaslayout/Logo.js +27 -32
- package/lib/Layout/paaslayout/SideMenu.js +161 -174
- package/lib/Layout/paaslayout/index.js +240 -261
- package/lib/Layout/storage.js +20 -78
- package/lib/Layout/utils.js +93 -143
- package/lib/LoadingButton/index.js +25 -57
- package/lib/Modal/index.js +83 -108
- package/lib/Page/Box.js +56 -81
- package/lib/Page/index.js +151 -173
- package/lib/Page/utils.js +12 -30
- package/lib/QueryForm/Field/Checkbox.js +11 -33
- package/lib/QueryForm/Field/Select.js +63 -99
- package/lib/QueryForm/Field/SelectInput.js +69 -114
- package/lib/QueryForm/Field/fieldsMap.js +30 -52
- package/lib/QueryForm/Field/index.js +76 -158
- package/lib/QueryForm/createActions.js +50 -65
- package/lib/QueryForm/index.js +304 -383
- package/lib/QueryForm/useForm.js +6 -17
- package/lib/QueryListScene/List.js +290 -366
- package/lib/QueryListScene/QueryForm.js +93 -161
- package/lib/QueryListScene/QueryListScene.js +33 -87
- package/lib/QueryListScene/Title.js +10 -20
- package/lib/QueryListScene/Toolbar.js +8 -31
- package/lib/QueryListScene/createActions.js +64 -79
- package/lib/QueryListScene/index.js +23 -40
- package/lib/QueryListScene/useActions.js +6 -17
- package/lib/Select/DropDownWrap.js +60 -124
- package/lib/Select/index.js +425 -561
- package/lib/Table/ResizableTable/index.js +77 -121
- package/lib/Table/index.js +19 -51
- package/lib/Title/index.js +34 -52
- package/lib/index.js +19 -159
- package/lib/locale.js +48 -63
- package/package.json +1 -1
- package/lib/Layout/EnterpriseLayout/Header.js +0 -113
- package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
package/lib/Layout/SideMenu.js
CHANGED
|
@@ -1,367 +1,453 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
37
|
-
|
|
38
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
39
|
-
|
|
40
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
-
|
|
42
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
43
|
-
|
|
44
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
45
|
-
|
|
46
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
47
|
-
|
|
48
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
49
|
-
|
|
50
|
-
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
1
|
+
import { useState, useEffect, useContext } from 'react';
|
|
2
|
+
import styled, { withTheme } from 'styled-components';
|
|
3
|
+
import { Menu } from 'antd';
|
|
4
|
+
import { get } from 'lodash';
|
|
5
|
+
import ActionsContext from './ActionsContext';
|
|
6
|
+
import { getSelectedMenuInfo, isGroupMenu, isNewTabMenu, openInNewTab, traverseTree } from './utils';
|
|
7
|
+
import { setSideMenuStore } from './storage';
|
|
8
|
+
import Iconfont from './Iconfont';
|
|
9
|
+
|
|
10
|
+
const color = 'rgba(255,255,255,.85)';
|
|
11
|
+
const compatibleColor = '#a1d7ff';
|
|
12
|
+
const { SubMenu, Item: MenuItem } = Menu;
|
|
13
|
+
const TNTMenu = styled(Menu)`
|
|
14
|
+
background: none !important;
|
|
15
|
+
&.ant-menu.ant-menu-root {
|
|
16
|
+
position: relative;
|
|
17
|
+
transition: none !important;
|
|
18
|
+
padding-top: 10px;
|
|
19
|
+
border-right: none;
|
|
20
|
+
text-rendering: optimizeLegibility;
|
|
21
|
+
-webkit-font-smoothing: antialiased;
|
|
22
|
+
-moz-osx-font-smoothing: grayscale;
|
|
23
|
+
height: calc(100vh - ${props => `${props.theme.headerHeight}px`});
|
|
24
|
+
overflow-y: auto;
|
|
25
|
+
overflow-x: hidden;
|
|
26
|
+
.collapseIconPlacementBottom & {
|
|
27
|
+
padding-bottom: 36px;
|
|
28
|
+
}
|
|
29
|
+
.tnt-themeS1 & {
|
|
30
|
+
overflow-x: unset;
|
|
31
|
+
box-shadow: 10px 0 10px -5px rgba(0,0,0,0.10);
|
|
32
|
+
z-index: 2;
|
|
33
|
+
}
|
|
34
|
+
scrollbar-width: none;
|
|
35
|
+
-ms-overflow-style: none;
|
|
51
36
|
|
|
52
|
-
|
|
37
|
+
&::-webkit-scrollbar {
|
|
38
|
+
display: none;
|
|
39
|
+
}
|
|
40
|
+
&::-moz-scrollbar {
|
|
41
|
+
display: none;
|
|
42
|
+
}
|
|
53
43
|
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
/** 一级结点是菜单样式开始 */
|
|
45
|
+
& > .ant-menu-item {
|
|
46
|
+
& > .tnt-icon:first-child {
|
|
47
|
+
font-size: 16px
|
|
48
|
+
}
|
|
49
|
+
}
|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
.ant-layout-sider-collapsed & {
|
|
52
|
+
& > .ant-menu-item {
|
|
53
|
+
& > .tnt-icon:first-child {
|
|
54
|
+
padding-left: 8px;
|
|
55
|
+
}
|
|
56
|
+
a {
|
|
57
|
+
visibility: hidden;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** 一级结点是菜单样式结束 */
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
.ant-menu-item:active,
|
|
64
|
+
.ant-menu-submenu-title:active {
|
|
65
|
+
background: none;
|
|
66
|
+
}
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
.ant-menu-submenu .ant-menu-sub {
|
|
69
|
+
background: #212635;
|
|
70
|
+
border-radius: 0 0 2px 2px;
|
|
71
|
+
.compatible & {
|
|
72
|
+
background: #07408d !important;
|
|
73
|
+
}
|
|
74
|
+
.tnt-themeS1 & {
|
|
75
|
+
background: #fff !important;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 蓝色系列 菜单展开区域颜色
|
|
79
|
+
.tnt-themeS3 & {
|
|
80
|
+
background: #07408D !important;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
.ant-menu-submenu.ant-menu-submenu-active,
|
|
84
|
+
.ant-menu-submenu.ant-menu-submenu-selected {
|
|
85
|
+
background: rgba(47,129,247,.25) !important;
|
|
86
|
+
.tnt-themeS1 & {
|
|
87
|
+
background: ${props => props.theme.dividerColor} !important;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 蓝色系 一级菜单的选中效果
|
|
91
|
+
.tnt-themeS3 & {
|
|
92
|
+
background: #204085 !important;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
& > .ant-menu-submenu .ant-menu-submenu.ant-menu-submenu-active,
|
|
96
|
+
& > .ant-menu-submenu .ant-menu-submenu.ant-menu-submenu-selected {
|
|
97
|
+
background: none !important;
|
|
98
|
+
.tnt-themeS1 & {
|
|
99
|
+
background: ${props => props.theme.dividerColor} !important;
|
|
100
|
+
}
|
|
101
|
+
// 蓝色系 子级菜单级的选中效果
|
|
102
|
+
.tnt-themeS3 & {
|
|
103
|
+
background: #204085 !important;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
.ant-menu-item {
|
|
107
|
+
margin: 0;
|
|
108
|
+
font-size: 14px;
|
|
109
|
+
padding-left: 54px !important;
|
|
110
|
+
height: ${({ size }) => size === 'large' ? '40px' : '36px'};
|
|
111
|
+
line-height: ${({ size }) => size === 'large' ? '40px' : '36px'};
|
|
112
|
+
}
|
|
70
113
|
|
|
71
|
-
|
|
72
|
-
|
|
114
|
+
& > .ant-menu-item {
|
|
115
|
+
padding-left: 24px !important;
|
|
116
|
+
width: 100%;
|
|
73
117
|
|
|
74
|
-
|
|
118
|
+
& > .tnt-icon {
|
|
119
|
+
margin-right: 12px;
|
|
120
|
+
}
|
|
121
|
+
& > a {
|
|
122
|
+
display: inline-block;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
75
125
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
return props.theme.compatible ? compatibleColor : color;
|
|
106
|
-
}, function (props) {
|
|
107
|
-
return props.theme.compatible ? compatibleColor : color;
|
|
108
|
-
}, function (props) {
|
|
109
|
-
return props.theme.primaryTextColor;
|
|
110
|
-
}, function (props) {
|
|
111
|
-
return props.theme.primaryColor;
|
|
112
|
-
}, function (props) {
|
|
113
|
-
return props.theme.primaryColor;
|
|
114
|
-
}, function (props) {
|
|
115
|
-
return props.theme.primaryColor;
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
var MenuTitle = _styledComponents["default"].span(_templateObject2(), function (props) {
|
|
119
|
-
return props.theme.primaryTextColor;
|
|
120
|
-
}, function (props) {
|
|
121
|
-
return "".concat(props.theme.iconColor);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
var _default = (0, _styledComponents.withTheme)(function (props) {
|
|
125
|
-
var actions = (0, _react.useContext)(_ActionsContext["default"]);
|
|
126
|
-
var language = props.language,
|
|
127
|
-
_props$menus = props.menus,
|
|
128
|
-
menus = _props$menus === void 0 ? [] : _props$menus,
|
|
129
|
-
formatMenuPath = props.formatMenuPath,
|
|
130
|
-
changeRouter = props.changeRouter,
|
|
131
|
-
selectedKey = props.selectedKey,
|
|
132
|
-
openKeys = props.openKeys,
|
|
133
|
-
onSelect = props.onSelect,
|
|
134
|
-
onBeforeChange = props.onBeforeChange,
|
|
135
|
-
onChange = props.onChange,
|
|
136
|
-
onOpenChange = props.onOpenChange,
|
|
137
|
-
collapsed = props.collapsed;
|
|
138
|
-
|
|
139
|
-
var _getSelectedMenuInfo = (0, _utils.getSelectedMenuInfo)(selectedKey, menus),
|
|
140
|
-
subMenu = _getSelectedMenuInfo.subMenu,
|
|
141
|
-
parentMenus = _getSelectedMenuInfo.parentMenus;
|
|
142
|
-
|
|
143
|
-
var _useState = (0, _react.useState)([(0, _lodash.get)(subMenu, 'code')]),
|
|
144
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
145
|
-
selectedKeys = _useState2[0],
|
|
146
|
-
setSelectedKeys = _useState2[1];
|
|
147
|
-
|
|
148
|
-
var onSelectMenu = function onSelectMenu(param) {
|
|
149
|
-
var _ref5 = (0, _utils.getSelectedMenuInfo)(param.key, menus) || {},
|
|
150
|
-
subMenu = _ref5.subMenu,
|
|
151
|
-
parentMenus = _ref5.parentMenus;
|
|
152
|
-
|
|
153
|
-
var params = _objectSpread({}, param, {
|
|
154
|
-
data: subMenu
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
var defaultBeforeChange = function defaultBeforeChange(_ref6) {
|
|
158
|
-
var data = _ref6.data;
|
|
159
|
-
return !(0, _utils.isNewTabMenu)(data);
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
var defaultSelect = function defaultSelect(_ref7) {
|
|
163
|
-
var _window$location$path;
|
|
164
|
-
|
|
165
|
-
var data = _ref7.data;
|
|
166
|
-
|
|
167
|
-
var _ref8 = data || {},
|
|
168
|
-
path = _ref8.path;
|
|
169
|
-
|
|
170
|
-
var formatPath = formatMenuPath || function (path) {
|
|
171
|
-
return path;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
if ((0, _utils.isNewTabMenu)(data)) {
|
|
175
|
-
(0, _utils.openInNewTab)(formatPath(data == null ? void 0 : data.path, data));
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
var routerPrefix = (_window$location$path = window.location.pathname.match(/(^\/[^\/]+)/i)) == null ? void 0 : _window$location$path[1];
|
|
180
|
-
|
|
181
|
-
if (path == null ? void 0 : path.startsWith(routerPrefix)) {
|
|
182
|
-
var forwardPath = formatPath(path, data);
|
|
183
|
-
changeRouter ? changeRouter(forwardPath, data) : window.history.pushState(data, data == null ? void 0 : data.name, forwardPath);
|
|
184
|
-
} else {
|
|
185
|
-
window.location.href = formatPath(path, data);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
var finalSelect = onSelect || defaultSelect;
|
|
190
|
-
|
|
191
|
-
if (param.key !== (0, _lodash.get)(selectedKeys, '0')) {
|
|
192
|
-
var finalBeforeChange = onBeforeChange || defaultBeforeChange;
|
|
193
|
-
|
|
194
|
-
if (finalBeforeChange(params, (0, _lodash.get)(selectedKeys, '0'))) {
|
|
195
|
-
// SideMenu菜单收起状态
|
|
196
|
-
if (collapsed) {
|
|
197
|
-
var newOpenKeys = parentMenus == null ? void 0 : parentMenus.map(function (_ref9) {
|
|
198
|
-
var code = _ref9.code;
|
|
199
|
-
return code;
|
|
200
|
-
}).reverse();
|
|
201
|
-
onOpenChange(newOpenKeys);
|
|
202
|
-
(0, _storage.setSideMenuStore)({
|
|
203
|
-
openKeys: newOpenKeys,
|
|
204
|
-
beforeOpenKeys: newOpenKeys
|
|
205
|
-
});
|
|
126
|
+
.ant-menu-submenu-title {
|
|
127
|
+
position: relative;
|
|
128
|
+
color: ${props => props.theme.compatible ? compatibleColor : color};
|
|
129
|
+
.tnt-themeS1 & {
|
|
130
|
+
color: ${props => props.theme.primaryTextColor};
|
|
131
|
+
}
|
|
132
|
+
height: ${({ size }) => size === 'large' ? '40px' : '36px'};
|
|
133
|
+
line-height: ${({ size }) => size === 'large' ? '40px' : '36px'};
|
|
134
|
+
.tnt-icon {
|
|
135
|
+
.tnt-themeS1 & {
|
|
136
|
+
color: ${props => props.theme.lightIconColor};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
& > .tnt-icon {
|
|
140
|
+
position: absolute;
|
|
141
|
+
right: 20px;
|
|
142
|
+
top: 1px;
|
|
143
|
+
font-size: 10px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 蓝色系主题
|
|
147
|
+
.tnt-themeS3 & {
|
|
148
|
+
color: #FFF;
|
|
149
|
+
}
|
|
150
|
+
.tnt-icon {
|
|
151
|
+
.tnt-themeS3 & {
|
|
152
|
+
color: #FFF;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
206
155
|
}
|
|
207
156
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
157
|
+
& > .ant-menu-submenu .ant-menu-submenu .ant-menu-submenu-title {
|
|
158
|
+
margin-top: 0;
|
|
159
|
+
margin-bottom: 0;
|
|
160
|
+
padding-left: 54px !important;
|
|
161
|
+
}
|
|
211
162
|
}
|
|
212
163
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
finalSelect(params);
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
var getExpandIcon = function getExpandIcon(code) {
|
|
219
|
-
if (props.theme.compatible) {
|
|
220
|
-
return openKeys.includes(code) ? 'minus' : 'plus';
|
|
164
|
+
&.ant-menu .menu-arrow-right {
|
|
165
|
+
color: ${props => props.theme.compatible ? compatibleColor : color};
|
|
221
166
|
}
|
|
222
167
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
var parentGroupKey;
|
|
235
|
-
(0, _utils.traverseTree)(menus, function (node, pnode) {
|
|
236
|
-
if (node.code === key) {
|
|
237
|
-
if (pnode && openKeys.includes(pnode == null ? void 0 : pnode.code)) {
|
|
238
|
-
parentGroupKey = pnode == null ? void 0 : pnode.code;
|
|
239
|
-
}
|
|
168
|
+
.ant-menu-item, .ant-menu-item > a {
|
|
169
|
+
color: ${props => props.theme.compatible ? compatibleColor : color};
|
|
170
|
+
.tnt-themeS1 & {
|
|
171
|
+
color: ${props => props.theme.primaryTextColor};
|
|
172
|
+
}
|
|
173
|
+
&:hover {
|
|
174
|
+
color: #fff;
|
|
175
|
+
.tnt-themeS1 & {
|
|
176
|
+
color: ${props => props.theme.primaryColor};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
240
179
|
|
|
241
|
-
|
|
180
|
+
// 蓝色系列
|
|
181
|
+
.tnt-themeS3 & {
|
|
182
|
+
color: #fff;
|
|
183
|
+
}
|
|
184
|
+
&:hover {
|
|
185
|
+
.tnt-themeS3 & {
|
|
186
|
+
color: #fff;
|
|
187
|
+
}
|
|
242
188
|
}
|
|
243
|
-
});
|
|
244
|
-
return parentGroupKey;
|
|
245
|
-
}; // 展开openKey
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (openKey) {
|
|
249
|
-
// 父子关系展开
|
|
250
|
-
var parentGroupKey = findParentGroupKey(openKey, openKeys);
|
|
251
|
-
|
|
252
|
-
if (parentGroupKey) {
|
|
253
|
-
newOpenKeys = keys.length > 2 ? [parentGroupKey, openKey] : keys;
|
|
254
|
-
} else {
|
|
255
|
-
newOpenKeys = [openKey];
|
|
256
|
-
}
|
|
257
|
-
} else {
|
|
258
|
-
// 收起closeKey
|
|
259
|
-
newOpenKeys = keys;
|
|
260
189
|
}
|
|
190
|
+
& > .ant-menu-item.ant-menu-item-selected,
|
|
191
|
+
&.ant-menu:not(.ant-menu-horizontal) .ant-menu-item-selected {
|
|
192
|
+
color: rgba(255,255,255,.85);
|
|
193
|
+
background-color: ${props => props.theme.primaryColor};
|
|
194
|
+
.compatible & {
|
|
195
|
+
background-color: #013479;
|
|
196
|
+
}
|
|
197
|
+
& > a {
|
|
198
|
+
.tnt-themeS1 & {
|
|
199
|
+
color: #fff;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
.tnt-themeS1 & {
|
|
203
|
+
color: #fff;
|
|
204
|
+
background-color: ${props => props.theme.primaryColor};
|
|
205
|
+
}
|
|
261
206
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return code;
|
|
272
|
-
}).reverse());
|
|
207
|
+
// 蓝色系 子项选中颜色
|
|
208
|
+
.tnt-themeS3 & {
|
|
209
|
+
color: #fff;
|
|
210
|
+
background: #013479;
|
|
211
|
+
&::after{
|
|
212
|
+
content:"";
|
|
213
|
+
display:none;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
273
216
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
actions.off('menuSelect', onSelectMenu);
|
|
278
|
-
actions.on('menuSelect', onSelectMenu);
|
|
279
|
-
return React.createElement(TNTMenu, {
|
|
280
|
-
mode: "inline",
|
|
281
|
-
defaultSelectedKeys: [],
|
|
282
|
-
openKeys: openKeys,
|
|
283
|
-
selectedKeys: selectedKeys,
|
|
284
|
-
onOpenChange: onOpenKeysChange
|
|
285
|
-
}, menus == null ? void 0 : menus.map(function (menu) {
|
|
286
|
-
var MenuLink = function MenuLink(_ref11) {
|
|
287
|
-
var menuName = _ref11.menuName,
|
|
288
|
-
enName = _ref11.enName,
|
|
289
|
-
path = _ref11.path;
|
|
290
|
-
return React.createElement("a", {
|
|
291
|
-
href: path,
|
|
292
|
-
onClick: function onClick(evt) {
|
|
293
|
-
return evt.preventDefault();
|
|
217
|
+
.ant-menu-submenu.ant-menu-submenu-selected {
|
|
218
|
+
.tnt-themeS2 & {
|
|
219
|
+
background: #141825;
|
|
294
220
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
en: enName
|
|
298
|
-
}[language]);
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
if ((0, _utils.isGroupMenu)(menu)) {
|
|
302
|
-
var _menu$children;
|
|
303
|
-
|
|
304
|
-
var getSubMenuProps = function getSubMenuProps(_ref12) {
|
|
305
|
-
var code = _ref12.code,
|
|
306
|
-
groupIcon = _ref12.groupIcon,
|
|
307
|
-
groupName = _ref12.groupName,
|
|
308
|
-
enName = _ref12.enName;
|
|
309
|
-
var isSubGroup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
310
|
-
return {
|
|
311
|
-
key: code,
|
|
312
|
-
title: React.createElement(MenuTitle, {
|
|
313
|
-
style: collapsed && isSubGroup ? {
|
|
314
|
-
color: props.theme.primaryTextColor
|
|
315
|
-
} : {}
|
|
316
|
-
}, !isSubGroup && React.createElement(_Iconfont["default"], {
|
|
317
|
-
type: groupIcon
|
|
318
|
-
}), collapsed && !isSubGroup ? '' : {
|
|
319
|
-
cn: groupName,
|
|
320
|
-
en: enName
|
|
321
|
-
}[language]),
|
|
322
|
-
expandIcon: collapsed ? null : React.createElement(_Iconfont["default"]
|
|
323
|
-
/* */
|
|
324
|
-
, {
|
|
325
|
-
type: getExpandIcon(code)
|
|
326
|
-
})
|
|
327
|
-
};
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
return React.createElement(SubMenu, _extends({}, getSubMenuProps(menu), {
|
|
331
|
-
onClick: onSelectMenu
|
|
332
|
-
}), menu == null ? void 0 : (_menu$children = menu.children) == null ? void 0 : _menu$children.map(function (menu) {
|
|
333
|
-
if ((0, _utils.isGroupMenu)(menu)) {
|
|
334
|
-
var _menu$children2;
|
|
335
|
-
|
|
336
|
-
return React.createElement(SubMenu, _extends({}, getSubMenuProps(menu, true), {
|
|
337
|
-
onClick: onSelectMenu
|
|
338
|
-
}), menu == null ? void 0 : (_menu$children2 = menu.children) == null ? void 0 : _menu$children2.map(function (_ref13) {
|
|
339
|
-
var code = _ref13.code,
|
|
340
|
-
menu = _objectWithoutProperties(_ref13, ["code"]);
|
|
341
|
-
|
|
342
|
-
return React.createElement(MenuItem, {
|
|
343
|
-
key: code
|
|
344
|
-
}, React.createElement(MenuLink, _extends({}, menu, {
|
|
345
|
-
style: {
|
|
346
|
-
paddingLeft: '24px'
|
|
347
|
-
}
|
|
348
|
-
})));
|
|
349
|
-
}));
|
|
221
|
+
.tnt-themeS2.compatible & {
|
|
222
|
+
background: rgba(47,129,247,.25) !important;
|
|
350
223
|
}
|
|
351
|
-
|
|
352
|
-
return React.createElement(MenuItem, {
|
|
353
|
-
key: menu == null ? void 0 : menu.code
|
|
354
|
-
}, React.createElement(MenuLink, menu));
|
|
355
|
-
}));
|
|
356
224
|
}
|
|
225
|
+
`;
|
|
226
|
+
const MenuTitle = styled.span`
|
|
227
|
+
font-size: 14px;
|
|
228
|
+
.large-size & {
|
|
229
|
+
font-size: 15px;
|
|
230
|
+
}
|
|
231
|
+
color: rgba(255,255,255,.85);
|
|
232
|
+
.compatible & {
|
|
233
|
+
color: #A1D7FF;
|
|
234
|
+
}
|
|
235
|
+
.tnt-themeS1 & {
|
|
236
|
+
color: ${props => props.theme.primaryTextColor};
|
|
237
|
+
}
|
|
238
|
+
.tnt-icon {
|
|
239
|
+
margin-right: 12px;
|
|
240
|
+
font-size: 16px;
|
|
241
|
+
position: relative;
|
|
242
|
+
top: 1px;
|
|
243
|
+
|
|
244
|
+
.large-size & {
|
|
245
|
+
font-size: 18px;
|
|
246
|
+
top: auto;
|
|
247
|
+
}
|
|
248
|
+
.tnt-themeS1 & {
|
|
249
|
+
/* color: #7e8081; */
|
|
250
|
+
color: ${props => `${props.theme.iconColor}`};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
`;
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
export default withTheme(
|
|
257
|
+
props => {
|
|
258
|
+
const actions = useContext(ActionsContext);
|
|
259
|
+
const { language, menus = [], formatMenuPath, changeRouter, selectedKey, openKeys, onSelect, onBeforeChange, onChange, onOpenChange, collapsed } = props;
|
|
260
|
+
const { subMenu, parentMenus } = getSelectedMenuInfo(selectedKey, menus);
|
|
261
|
+
const [selectedKeys, setSelectedKeys] = useState([get(subMenu, 'code')]);
|
|
262
|
+
const onSelectMenu = param => {
|
|
263
|
+
const { subMenu, parentMenus } = getSelectedMenuInfo(param.key, menus) || {};
|
|
264
|
+
const params = {
|
|
265
|
+
...param,
|
|
266
|
+
data: subMenu
|
|
267
|
+
};
|
|
268
|
+
const defaultBeforeChange = ({ data }) => !isNewTabMenu(data);
|
|
269
|
+
const defaultSelect = ({ data }) => {
|
|
270
|
+
const { path } = data || {};
|
|
271
|
+
const formatPath = formatMenuPath || (path => path);
|
|
272
|
+
|
|
273
|
+
if (isNewTabMenu(data)) {
|
|
274
|
+
openInNewTab(formatPath(data?.path, data));
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const routerPrefix = window.location.pathname.match(/(^\/[^\/]+)/i)?.[1];
|
|
279
|
+
|
|
280
|
+
if (path?.startsWith(routerPrefix)) {
|
|
281
|
+
const forwardPath = formatPath(path, data);
|
|
282
|
+
changeRouter ? changeRouter(forwardPath, data) : window.history.pushState(data, data?.name, forwardPath);
|
|
283
|
+
} else {
|
|
284
|
+
window.location.href = formatPath(path, data);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
const finalSelect = onSelect || defaultSelect;
|
|
288
|
+
|
|
289
|
+
if (param.key !== get(selectedKeys, '0')) {
|
|
290
|
+
const finalBeforeChange = onBeforeChange || defaultBeforeChange;
|
|
291
|
+
|
|
292
|
+
if (finalBeforeChange(params, get(selectedKeys, '0'))) {
|
|
293
|
+
// SideMenu菜单收起状态
|
|
294
|
+
if (collapsed) {
|
|
295
|
+
const newOpenKeys = parentMenus?.map(({ code }) => code).reverse();
|
|
296
|
+
|
|
297
|
+
onOpenChange(newOpenKeys);
|
|
298
|
+
setSideMenuStore({
|
|
299
|
+
openKeys: newOpenKeys,
|
|
300
|
+
beforeOpenKeys: newOpenKeys
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
setSelectedKeys([param.key]);
|
|
304
|
+
onChange && onChange(params);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
actions.setSelectedMenuKey(param.key);
|
|
308
|
+
setSelectedKeys([param.key]);
|
|
309
|
+
|
|
310
|
+
finalSelect(params);
|
|
311
|
+
};
|
|
312
|
+
const getExpandIcon = code => {
|
|
313
|
+
if (props.theme.compatible) {
|
|
314
|
+
return openKeys.includes(code) ? 'minus' : 'plus';
|
|
315
|
+
}
|
|
357
316
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
317
|
+
return openKeys.includes(code) ? 'up' : 'down';
|
|
318
|
+
};
|
|
319
|
+
const onOpenKeysChange = keys => {
|
|
320
|
+
const openKey = keys.find(key => !openKeys.includes(key));
|
|
321
|
+
// const closeKey = openKeys.find(key => !keys.includes(key));
|
|
322
|
+
let newOpenKeys = keys;
|
|
323
|
+
|
|
324
|
+
const findParentGroupKey = (key, openKeys) => {
|
|
325
|
+
let parentGroupKey;
|
|
326
|
+
|
|
327
|
+
traverseTree(menus, (node, pnode) => {
|
|
328
|
+
if (node.code === key) {
|
|
329
|
+
if (pnode && openKeys.includes(pnode?.code)) {
|
|
330
|
+
parentGroupKey = pnode?.code;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
return parentGroupKey;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// 展开openKey
|
|
341
|
+
if (openKey) {
|
|
342
|
+
// 父子关系展开
|
|
343
|
+
const parentGroupKey = findParentGroupKey(openKey, openKeys);
|
|
344
|
+
if (parentGroupKey) {
|
|
345
|
+
newOpenKeys = keys.length > 2 ? [parentGroupKey, openKey] : keys;
|
|
346
|
+
} else {
|
|
347
|
+
newOpenKeys = [openKey];
|
|
348
|
+
}
|
|
349
|
+
} else { // 收起closeKey
|
|
350
|
+
newOpenKeys = keys;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
onOpenChange(newOpenKeys);
|
|
354
|
+
};
|
|
366
355
|
|
|
367
|
-
|
|
356
|
+
useEffect(() => {
|
|
357
|
+
setSelectedKeys([selectedKey]);
|
|
358
|
+
if (selectedKey && !collapsed && parentMenus?.length) {
|
|
359
|
+
onOpenChange(parentMenus?.map(({ code }) => code).reverse());
|
|
360
|
+
}
|
|
361
|
+
actions.setSelectedMenuKey(selectedKey);
|
|
362
|
+
}, [selectedKey]);
|
|
363
|
+
|
|
364
|
+
actions.off('menuSelect', onSelectMenu);
|
|
365
|
+
actions.on('menuSelect', onSelectMenu);
|
|
366
|
+
|
|
367
|
+
return (
|
|
368
|
+
<TNTMenu
|
|
369
|
+
mode="inline"
|
|
370
|
+
defaultSelectedKeys={[]}
|
|
371
|
+
openKeys={openKeys}
|
|
372
|
+
selectedKeys={selectedKeys}
|
|
373
|
+
onOpenChange={onOpenKeysChange}
|
|
374
|
+
>
|
|
375
|
+
{
|
|
376
|
+
menus?.map(menu => {
|
|
377
|
+
const MenuLink = ({ menuName, enName, path }) => (
|
|
378
|
+
<a href={path} onClick={evt => evt.preventDefault()}>
|
|
379
|
+
{
|
|
380
|
+
{
|
|
381
|
+
cn: menuName,
|
|
382
|
+
en: enName
|
|
383
|
+
}[language]
|
|
384
|
+
}
|
|
385
|
+
</a>
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
if (isGroupMenu(menu)) {
|
|
389
|
+
const getSubMenuProps = ({ code, groupIcon, groupName, enName }, isSubGroup = false) => ({
|
|
390
|
+
key: code,
|
|
391
|
+
title: (
|
|
392
|
+
<MenuTitle style={(collapsed && isSubGroup) ? { color: props.theme.primaryTextColor } : {}}>
|
|
393
|
+
{!isSubGroup && <Iconfont type={groupIcon} />}
|
|
394
|
+
{
|
|
395
|
+
(collapsed && !isSubGroup) ? '' : {
|
|
396
|
+
cn: groupName,
|
|
397
|
+
en: enName
|
|
398
|
+
}[language]
|
|
399
|
+
}
|
|
400
|
+
</MenuTitle>
|
|
401
|
+
),
|
|
402
|
+
expandIcon: collapsed ? null : (
|
|
403
|
+
<Iconfont/* */ type={getExpandIcon(code)} />
|
|
404
|
+
)
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
return (
|
|
408
|
+
<SubMenu
|
|
409
|
+
{...getSubMenuProps(menu)}
|
|
410
|
+
onClick={onSelectMenu}
|
|
411
|
+
>
|
|
412
|
+
{
|
|
413
|
+
menu?.children?.map(menu => {
|
|
414
|
+
if (isGroupMenu(menu)) {
|
|
415
|
+
return (
|
|
416
|
+
<SubMenu
|
|
417
|
+
{...getSubMenuProps(menu, true)}
|
|
418
|
+
onClick={onSelectMenu}
|
|
419
|
+
>
|
|
420
|
+
{
|
|
421
|
+
menu?.children?.map(({ code, ...menu }) => (
|
|
422
|
+
<MenuItem key={code}>
|
|
423
|
+
<MenuLink {...menu} style={{ paddingLeft: '24px' }}/>
|
|
424
|
+
</MenuItem>
|
|
425
|
+
))
|
|
426
|
+
}
|
|
427
|
+
</SubMenu>
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return (
|
|
432
|
+
<MenuItem key={menu?.code}>
|
|
433
|
+
<MenuLink {...menu} />
|
|
434
|
+
</MenuItem>
|
|
435
|
+
);
|
|
436
|
+
})
|
|
437
|
+
}
|
|
438
|
+
</SubMenu>
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
return (
|
|
443
|
+
<MenuItem key={menu.code} onClick={onSelectMenu}>
|
|
444
|
+
<Iconfont type={menu.icon} />
|
|
445
|
+
<MenuLink {...menu} />
|
|
446
|
+
</MenuItem>
|
|
447
|
+
);
|
|
448
|
+
})
|
|
449
|
+
}
|
|
450
|
+
</TNTMenu>
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
);
|