tntd 1.4.4 → 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/components/QueryListScene/QueryForm.js +7 -4
- package/dist/stats.json +4990 -4990
- package/dist/tntd.js +1 -1
- package/es/Layout/HeaderActions.js +10 -10
- package/es/LoadingButton/index.js +20 -10
- package/es/QueryListScene/QueryForm.js +6 -3
- 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 -158
- 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/index.js
CHANGED
|
@@ -1,165 +1,114 @@
|
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
1
|
+
import { ThemeProvider } from 'styled-components';
|
|
2
|
+
import Layout from './Layout';
|
|
3
|
+
import EnterpriseLayout from './EnterpriseLayout';
|
|
4
|
+
import PaasLayout from './paaslayout';
|
|
5
|
+
import HeaderNavs from './HeaderNavs';
|
|
6
|
+
import HeaderTabs from './HeaderTabs';
|
|
7
|
+
import getCheckAuth from './checkAuth';
|
|
8
|
+
import AuthContext from '../AuthContext';
|
|
9
|
+
import { safeParseJSON, findMenuInfoByPath } from './utils';
|
|
10
|
+
import ActionsContext from './ActionsContext';
|
|
11
|
+
import createActions from './createActions';
|
|
12
|
+
import { getLanguageStore } from './storage';
|
|
13
|
+
|
|
14
|
+
export const HeaderActionItem = props => (
|
|
15
|
+
<li {...props}>
|
|
16
|
+
{props.children}
|
|
17
|
+
</li>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export * from './HeaderNavs';
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const TNTLayout = ({ type, config, ...props }) => {
|
|
24
|
+
const headerHeight = props.size === 'large' ? 60 : 50;
|
|
25
|
+
const theme = {
|
|
26
|
+
size: props.size,
|
|
27
|
+
compatible: props.compatible,
|
|
28
|
+
headerHeight,
|
|
29
|
+
primaryColor: '#126BFB',
|
|
30
|
+
secondaryColor: '#005df4',
|
|
31
|
+
primaryTextColor: '#17233D', // 1
|
|
32
|
+
secondaryTextColor: 'rgba(23,35,61,.8)', // .8
|
|
33
|
+
lightIconColor: 'rgba(23,35,61,.7)', // .7
|
|
34
|
+
headerActionsColor: 'rgba(23,35,61,.6)', // .6
|
|
35
|
+
borderColor: '#B2BECD',
|
|
36
|
+
dividerColor: '#E1E6EE',
|
|
37
|
+
lightBgColor: '#F1F2F5',
|
|
38
|
+
blueBgColor: '#1D4295' // 默认的蓝色主题
|
|
39
|
+
};
|
|
40
|
+
const isInIframe = self !== top;
|
|
41
|
+
// 前期拼写错误,导致需要兼容处理
|
|
42
|
+
const extraHeaderActions = props.extraHeaderActions || props.extralHeaderActions;
|
|
43
|
+
const extendMap = typeof props.extendMap === 'string' ? safeParseJSON(props.extendMap, {}) : props.extendMap;
|
|
44
|
+
const { displayType = 'default', menuAlignMode, globalNavigation = false, language = ['cn'], themeSwitch = true } = extendMap || {};
|
|
45
|
+
const userInfo = props.userInfo || {};
|
|
46
|
+
const actionsContextValue = createActions({ language: getLanguageStore() || userInfo.lang || 'cn' });
|
|
47
|
+
const onLanguageChange = language => {
|
|
48
|
+
actionsContextValue.setLanguage(language);
|
|
49
|
+
props?.onLanguageChange(language);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// layout上的指定的属性优先级会高于extendMap中的属性
|
|
53
|
+
type = type || displayType;
|
|
54
|
+
config = Object.assign({
|
|
55
|
+
language: language?.length > 1,
|
|
56
|
+
theme: themeSwitch,
|
|
57
|
+
avatar: true,
|
|
58
|
+
globalNavigation
|
|
59
|
+
}, config);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<ThemeProvider theme={theme}>
|
|
63
|
+
<AuthContext.Provider value={getCheckAuth(props.menus)}>
|
|
64
|
+
<ActionsContext.Provider value={actionsContextValue}>
|
|
65
|
+
{
|
|
66
|
+
type === 'paas' &&
|
|
67
|
+
<PaasLayout
|
|
68
|
+
menuAlignMode={menuAlignMode}
|
|
69
|
+
config={config}
|
|
70
|
+
{...props}
|
|
71
|
+
extraHeaderActions={extraHeaderActions}
|
|
72
|
+
isInIframe={isInIframe}
|
|
73
|
+
userInfo={userInfo}
|
|
74
|
+
onLanguageChange={onLanguageChange}
|
|
75
|
+
/>
|
|
76
|
+
}
|
|
77
|
+
{
|
|
78
|
+
type === 'enterprise' &&
|
|
79
|
+
<EnterpriseLayout
|
|
80
|
+
menuAlignMode={menuAlignMode}
|
|
81
|
+
config={config}
|
|
82
|
+
{...props}
|
|
83
|
+
extraHeaderActions={extraHeaderActions}
|
|
84
|
+
isInIframe={isInIframe}
|
|
85
|
+
userInfo={userInfo}
|
|
86
|
+
onLanguageChange={onLanguageChange}
|
|
87
|
+
/>
|
|
88
|
+
}
|
|
89
|
+
{
|
|
90
|
+
(!type || !['paas','enterprise'].includes(type)) &&
|
|
91
|
+
<Layout
|
|
92
|
+
menuAlignMode={menuAlignMode}
|
|
93
|
+
config={config}
|
|
94
|
+
{...props}
|
|
95
|
+
extraHeaderActions={extraHeaderActions}
|
|
96
|
+
isInIframe={isInIframe}
|
|
97
|
+
userInfo={userInfo}
|
|
98
|
+
onLanguageChange={onLanguageChange}
|
|
99
|
+
/>
|
|
100
|
+
}
|
|
101
|
+
</ActionsContext.Provider>
|
|
102
|
+
</AuthContext.Provider>
|
|
103
|
+
</ThemeProvider>
|
|
104
|
+
);
|
|
62
105
|
};
|
|
63
106
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
config = _ref.config,
|
|
69
|
-
props = _objectWithoutProperties(_ref, ["type", "config"]);
|
|
70
|
-
|
|
71
|
-
var headerHeight = props.size === 'large' ? 60 : 50;
|
|
72
|
-
var theme = {
|
|
73
|
-
size: props.size,
|
|
74
|
-
compatible: props.compatible,
|
|
75
|
-
headerHeight: headerHeight,
|
|
76
|
-
primaryColor: '#126BFB',
|
|
77
|
-
secondaryColor: '#005df4',
|
|
78
|
-
primaryTextColor: '#17233D',
|
|
79
|
-
// 1
|
|
80
|
-
secondaryTextColor: 'rgba(23,35,61,.8)',
|
|
81
|
-
// .8
|
|
82
|
-
lightIconColor: 'rgba(23,35,61,.7)',
|
|
83
|
-
// .7
|
|
84
|
-
headerActionsColor: 'rgba(23,35,61,.6)',
|
|
85
|
-
// .6
|
|
86
|
-
borderColor: '#B2BECD',
|
|
87
|
-
dividerColor: '#E1E6EE',
|
|
88
|
-
lightBgColor: '#F1F2F5',
|
|
89
|
-
blueBgColor: '#1D4295' // 默认的蓝色主题
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
var isInIframe = self !== top; // 前期拼写错误,导致需要兼容处理
|
|
93
|
-
|
|
94
|
-
var extraHeaderActions = props.extraHeaderActions || props.extralHeaderActions;
|
|
95
|
-
var extendMap = typeof props.extendMap === 'string' ? (0, _utils.safeParseJSON)(props.extendMap, {}) : props.extendMap;
|
|
96
|
-
|
|
97
|
-
var _ref2 = extendMap || {},
|
|
98
|
-
_ref2$displayType = _ref2.displayType,
|
|
99
|
-
displayType = _ref2$displayType === void 0 ? 'default' : _ref2$displayType,
|
|
100
|
-
menuAlignMode = _ref2.menuAlignMode,
|
|
101
|
-
_ref2$globalNavigatio = _ref2.globalNavigation,
|
|
102
|
-
globalNavigation = _ref2$globalNavigatio === void 0 ? false : _ref2$globalNavigatio,
|
|
103
|
-
_ref2$language = _ref2.language,
|
|
104
|
-
language = _ref2$language === void 0 ? ['cn'] : _ref2$language,
|
|
105
|
-
_ref2$themeSwitch = _ref2.themeSwitch,
|
|
106
|
-
themeSwitch = _ref2$themeSwitch === void 0 ? true : _ref2$themeSwitch;
|
|
107
|
-
|
|
108
|
-
var userInfo = props.userInfo || {};
|
|
109
|
-
var actionsContextValue = (0, _createActions["default"])({
|
|
110
|
-
language: (0, _storage.getLanguageStore)() || userInfo.lang || 'cn'
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
var onLanguageChange = function onLanguageChange(language) {
|
|
114
|
-
actionsContextValue.setLanguage(language);
|
|
115
|
-
props == null ? void 0 : props.onLanguageChange(language);
|
|
116
|
-
}; // layout上的指定的属性优先级会高于extendMap中的属性
|
|
117
|
-
|
|
107
|
+
TNTLayout.HeaderActionItem = HeaderActionItem;
|
|
108
|
+
TNTLayout.HeaderNavs = HeaderNavs;
|
|
109
|
+
TNTLayout.HeaderTabs = HeaderTabs;
|
|
110
|
+
TNTLayout.AuthContext = AuthContext;
|
|
118
111
|
|
|
119
|
-
|
|
120
|
-
config = Object.assign({
|
|
121
|
-
language: (language == null ? void 0 : language.length) > 1,
|
|
122
|
-
theme: themeSwitch,
|
|
123
|
-
avatar: true,
|
|
124
|
-
globalNavigation: globalNavigation
|
|
125
|
-
}, config);
|
|
126
|
-
return React.createElement(_styledComponents.ThemeProvider, {
|
|
127
|
-
theme: theme
|
|
128
|
-
}, React.createElement(_AuthContext["default"].Provider, {
|
|
129
|
-
value: (0, _checkAuth["default"])(props.menus)
|
|
130
|
-
}, React.createElement(_ActionsContext["default"].Provider, {
|
|
131
|
-
value: actionsContextValue
|
|
132
|
-
}, type === 'paas' && React.createElement(_paaslayout["default"], _extends({
|
|
133
|
-
menuAlignMode: menuAlignMode,
|
|
134
|
-
config: config
|
|
135
|
-
}, props, {
|
|
136
|
-
extraHeaderActions: extraHeaderActions,
|
|
137
|
-
isInIframe: isInIframe,
|
|
138
|
-
userInfo: userInfo,
|
|
139
|
-
onLanguageChange: onLanguageChange
|
|
140
|
-
})), type === 'enterprise' && React.createElement(_EnterpriseLayout["default"], _extends({
|
|
141
|
-
menuAlignMode: menuAlignMode,
|
|
142
|
-
config: config
|
|
143
|
-
}, props, {
|
|
144
|
-
extraHeaderActions: extraHeaderActions,
|
|
145
|
-
isInIframe: isInIframe,
|
|
146
|
-
userInfo: userInfo,
|
|
147
|
-
onLanguageChange: onLanguageChange
|
|
148
|
-
})), (!type || !['paas', 'enterprise'].includes(type)) && React.createElement(_Layout["default"], _extends({
|
|
149
|
-
menuAlignMode: menuAlignMode,
|
|
150
|
-
config: config
|
|
151
|
-
}, props, {
|
|
152
|
-
extraHeaderActions: extraHeaderActions,
|
|
153
|
-
isInIframe: isInIframe,
|
|
154
|
-
userInfo: userInfo,
|
|
155
|
-
onLanguageChange: onLanguageChange
|
|
156
|
-
})))));
|
|
157
|
-
};
|
|
112
|
+
TNTLayout.findMenuInfoByPath = findMenuInfoByPath;
|
|
158
113
|
|
|
159
|
-
|
|
160
|
-
TNTLayout.HeaderNavs = _HeaderNavs["default"];
|
|
161
|
-
TNTLayout.HeaderTabs = _HeaderTabs["default"];
|
|
162
|
-
TNTLayout.AuthContext = _AuthContext["default"];
|
|
163
|
-
TNTLayout.findMenuInfoByPath = _utils.findMenuInfoByPath;
|
|
164
|
-
var _default = TNTLayout;
|
|
165
|
-
exports["default"] = _default;
|
|
114
|
+
export default TNTLayout;
|
|
@@ -1,185 +1,207 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
21
|
-
|
|
22
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
26
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
|
-
|
|
28
|
-
function _templateObject2() {
|
|
29
|
-
var data = _taggedTemplateLiteral(["\n background: #fff;\n list-style: none;\n font-size: 14px;\n color: #17233D;\n margin: 10px 0 0;\n padding: 0;\n li {\n position: relative;\n line-height: 38px;\n cursor: pointer;\n padding-left: 20px;\n & > a {\n color: #17233D;\n & > span {\n padding-left: 10px;\n }\n }\n &.active {\n background: #EAEDF8;\n &:before {\n position: absolute;\n left: 0;\n top: 0;\n content: '';\n width: 4px;\n height: 100%;\n background-color: #4C79FF;\n }\n }\n }\n"]);
|
|
30
|
-
|
|
31
|
-
_templateObject2 = function _templateObject2() {
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return data;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function _templateObject() {
|
|
39
|
-
var data = _taggedTemplateLiteral(["\n background: #fff;\n list-style: none;\n margin: 0;\n padding: 30px 0 20px;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n .isInIframe & {\n display: none;\n }\n \n & > li {\n position: relative;\n cursor: pointer;\n line-height: 38px;\n font-size: 14px;\n color: #17233D;\n letter-spacing: 0;\n\n &.group-menu-item {\n & > span {\n opacity: 0.4;\n }\n }\n\n &.active {\n &:before {\n position: absolute;\n content: \"\";\n left: 0;\n top: 0;\n width: 3px;\n height: 100%;\n background: #126bfb;\n }\n\n span {\n background: rgba(18,107,251,0.10);\n color: #126bfb;\n opacity: 1;\n }\n }\n\n & > span {\n display: inline-block;\n width: 100%;\n color: #17233D;\n padding-left: 20px;\n\n &:hover {\n color: #323232;\n background: #f5f5f5;\n }\n\n & > .tnt-icon {\n margin-right: 7px;\n }\n }\n }\n"]);
|
|
40
|
-
|
|
41
|
-
_templateObject = function _templateObject() {
|
|
42
|
-
return data;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return data;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
49
|
-
|
|
50
|
-
var SideMenu = _styledComponents["default"].ul(_templateObject());
|
|
51
|
-
|
|
52
|
-
var SubMenu = _styledComponents["default"].ul(_templateObject2());
|
|
53
|
-
|
|
54
|
-
var _default = function _default(props) {
|
|
55
|
-
var language = props.language,
|
|
56
|
-
_props$menus = props.menus,
|
|
57
|
-
menus = _props$menus === void 0 ? [] : _props$menus,
|
|
58
|
-
formatMenuPath = props.formatMenuPath,
|
|
59
|
-
selectedKey = props.selectedKey,
|
|
60
|
-
onBeforeChange = props.onBeforeChange,
|
|
61
|
-
onChange = props.onChange,
|
|
62
|
-
onSelect = props.onSelect;
|
|
63
|
-
|
|
64
|
-
var _useState = (0, _react.useState)(selectedKey),
|
|
65
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
66
|
-
activeMenu = _useState2[0],
|
|
67
|
-
setActiveMenu = _useState2[1];
|
|
68
|
-
|
|
69
|
-
var defaultBeforeChange = function defaultBeforeChange(_ref) {
|
|
70
|
-
var data = _ref.data;
|
|
71
|
-
return !(0, _utils.isNewTabMenu)(data);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
var defaultSelect = function defaultSelect(_ref2) {
|
|
75
|
-
var _window$location$path;
|
|
76
|
-
|
|
77
|
-
var data = _ref2.data;
|
|
78
|
-
|
|
79
|
-
var _ref3 = data || {},
|
|
80
|
-
path = _ref3.path;
|
|
81
|
-
|
|
82
|
-
var formatPath = formatMenuPath || function (path) {
|
|
83
|
-
return path;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
if ((0, _utils.isNewTabMenu)(data)) {
|
|
87
|
-
(0, _utils.openInNewTab)(formatPath(data == null ? void 0 : data.path, data));
|
|
88
|
-
return;
|
|
1
|
+
import { useState, useEffect, Component } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import { isNewTabMenu, openInNewTab } from '../utils';
|
|
5
|
+
import Iconfont from '../Iconfont';
|
|
6
|
+
|
|
7
|
+
const SideMenu = styled.ul`
|
|
8
|
+
background: #fff;
|
|
9
|
+
list-style: none;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 30px 0 20px;
|
|
12
|
+
text-rendering: optimizeLegibility;
|
|
13
|
+
-webkit-font-smoothing: antialiased;
|
|
14
|
+
-moz-osx-font-smoothing: grayscale;
|
|
15
|
+
.isInIframe & {
|
|
16
|
+
display: none;
|
|
89
17
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
18
|
+
|
|
19
|
+
& > li {
|
|
20
|
+
position: relative;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
line-height: 38px;
|
|
23
|
+
font-size: 14px;
|
|
24
|
+
color: #17233D;
|
|
25
|
+
letter-spacing: 0;
|
|
26
|
+
|
|
27
|
+
&.group-menu-item {
|
|
28
|
+
& > span {
|
|
29
|
+
opacity: 0.4;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.active {
|
|
34
|
+
&:before {
|
|
35
|
+
position: absolute;
|
|
36
|
+
content: "";
|
|
37
|
+
left: 0;
|
|
38
|
+
top: 0;
|
|
39
|
+
width: 3px;
|
|
40
|
+
height: 100%;
|
|
41
|
+
background: #126bfb;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
span {
|
|
45
|
+
background: rgba(18,107,251,0.10);
|
|
46
|
+
color: #126bfb;
|
|
47
|
+
opacity: 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
& > span {
|
|
52
|
+
display: inline-block;
|
|
53
|
+
width: 100%;
|
|
54
|
+
color: #17233D;
|
|
55
|
+
padding-left: 20px;
|
|
56
|
+
|
|
57
|
+
&:hover {
|
|
58
|
+
color: #323232;
|
|
59
|
+
background: #f5f5f5;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
& > .tnt-icon {
|
|
63
|
+
margin-right: 7px;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
98
66
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
const SubMenu = styled.ul`
|
|
70
|
+
background: #fff;
|
|
71
|
+
list-style: none;
|
|
72
|
+
font-size: 14px;
|
|
73
|
+
color: #17233D;
|
|
74
|
+
margin: 10px 0 0;
|
|
75
|
+
padding: 0;
|
|
76
|
+
li {
|
|
77
|
+
position: relative;
|
|
78
|
+
line-height: 38px;
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
padding-left: 20px;
|
|
81
|
+
& > a {
|
|
82
|
+
color: #17233D;
|
|
83
|
+
& > span {
|
|
84
|
+
padding-left: 10px;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
&.active {
|
|
88
|
+
background: #EAEDF8;
|
|
89
|
+
&:before {
|
|
90
|
+
position: absolute;
|
|
91
|
+
left: 0;
|
|
92
|
+
top: 0;
|
|
93
|
+
content: '';
|
|
94
|
+
width: 4px;
|
|
95
|
+
height: 100%;
|
|
96
|
+
background-color: #4C79FF;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
111
99
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
export default props => {
|
|
103
|
+
const { language, menus = [], formatMenuPath, selectedKey, onBeforeChange, onChange, onSelect } = props;
|
|
104
|
+
const [activeMenu, setActiveMenu] = useState(selectedKey);
|
|
105
|
+
const defaultBeforeChange = ({ data }) => !isNewTabMenu(data);
|
|
106
|
+
const defaultSelect = ({ data }) => {
|
|
107
|
+
const { path } = data || {};
|
|
108
|
+
const formatPath = formatMenuPath || (path => path);
|
|
109
|
+
|
|
110
|
+
if (isNewTabMenu(data)) {
|
|
111
|
+
openInNewTab(formatPath(data?.path, data));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const routerPrefix = window.location.pathname.match(/(^\/[^\/]+)/i)?.[1];
|
|
116
|
+
|
|
117
|
+
if (window.location.pathname.startsWith(routerPrefix)) {
|
|
118
|
+
const forwardPath = formatPath(path, data);
|
|
119
|
+
changeRouter ? changeRouter(forwardPath, data) : window.history.pushState(data, data?.name, forwardPath);
|
|
120
|
+
} else {
|
|
121
|
+
window.location.href = formatPath(path, data);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const selectMenu = (param = {}) => {
|
|
125
|
+
const finalBeforeChange = onBeforeChange || defaultBeforeChange;
|
|
126
|
+
const finalSelect = onSelect || defaultSelect;
|
|
127
|
+
|
|
128
|
+
if (param.key !== activeMenu) {
|
|
129
|
+
if (finalBeforeChange(param, activeMenu)) {
|
|
130
|
+
setActiveMenu(param.key);
|
|
131
|
+
onChange && onChange(param);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
finalSelect(param);
|
|
148
136
|
};
|
|
149
137
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
138
|
+
const MenuItem = ({ item }) => {
|
|
139
|
+
const { code, groupName, enName, children = [] } = item;
|
|
140
|
+
const SubMenuItem = ({ menu }) => {
|
|
141
|
+
const { code, menuName, enName, icon } = menu;
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<li
|
|
145
|
+
key={code}
|
|
146
|
+
onClick={evt => selectMenu({ key: code, data: menu, domEvent: evt })}
|
|
147
|
+
className={cn({ active: code === activeMenu })}
|
|
148
|
+
>
|
|
149
|
+
<span>
|
|
150
|
+
{
|
|
151
|
+
typeof (icon || '') === 'string' ? (
|
|
152
|
+
<Iconfont type={icon} />
|
|
153
|
+
) : icon
|
|
154
|
+
}
|
|
155
|
+
{
|
|
156
|
+
{
|
|
157
|
+
cn: menuName,
|
|
158
|
+
en: enName
|
|
159
|
+
}[language]
|
|
160
|
+
}
|
|
161
|
+
</span>
|
|
162
|
+
</li>
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (groupName && children.length) {
|
|
167
|
+
return (
|
|
168
|
+
<li key={code} className="group-menu-item">
|
|
169
|
+
<span>
|
|
170
|
+
{
|
|
171
|
+
icon instanceof Component ? icon : (
|
|
172
|
+
<Iconfont type={icon} />
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
{
|
|
176
|
+
{
|
|
177
|
+
cn: groupName,
|
|
178
|
+
en: enName
|
|
179
|
+
}[language]
|
|
180
|
+
}
|
|
181
|
+
</span>
|
|
182
|
+
<SubMenu>
|
|
183
|
+
{
|
|
184
|
+
children.map(subItem => <SubMenuItem menu={subItem} key={subItem?.code} />)
|
|
185
|
+
}
|
|
186
|
+
</SubMenu>
|
|
187
|
+
</li>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return <SubMenuItem menu={item} />;
|
|
192
|
+
};
|
|
166
193
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
key: menu.code
|
|
181
|
-
});
|
|
182
|
-
}));
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
setActiveMenu(selectedKey);
|
|
196
|
+
}, [selectedKey]);
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<SideMenu className="tnt-compact-sidemenu">
|
|
200
|
+
{
|
|
201
|
+
menus.map(menu => (
|
|
202
|
+
<MenuItem item={menu} key={menu.code} />
|
|
203
|
+
))
|
|
204
|
+
}
|
|
205
|
+
</SideMenu>
|
|
206
|
+
);
|
|
183
207
|
};
|
|
184
|
-
|
|
185
|
-
exports["default"] = _default;
|