tntd 1.4.10 → 1.4.11
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/AppList.js +1 -1
- package/components/Layout/GlobalNavigation/NavigationPopup.js +8 -8
- package/components/Layout/GlobalNavigation/index.js +2 -2
- package/components/Layout/OrgAppList.js +14 -15
- package/components/Layout/SideMenu.js +2 -2
- package/components/Layout/index.js +4 -5
- package/components/Layout/paaslayout/CompactSideMenu.js +1 -1
- package/components/Layout/paaslayout/index.js +2 -2
- package/components/Layout/storage.js +1 -1
- package/components/index.js +1 -0
- package/components/{Layout → utils}/checkAuth.js +3 -1
- package/components/utils/findMenuInfoByPath.js +39 -0
- package/components/{Layout/utils.js → utils/index.js} +3 -35
- package/dist/stats.json +9760 -9514
- package/dist/tntd.js +1 -1
- package/es/Layout/AppList.js +1 -1
- package/es/Layout/GlobalNavigation/NavigationPopup.js +1 -1
- package/es/Layout/GlobalNavigation/index.js +1 -1
- package/es/Layout/OrgAppList.js +3 -4
- package/es/Layout/SideMenu.js +1 -1
- package/es/Layout/index.js +5 -4
- package/es/Layout/paaslayout/CompactSideMenu.js +1 -1
- package/es/Layout/paaslayout/index.js +1 -1
- package/es/Layout/storage.js +1 -1
- package/es/index.js +2 -1
- package/es/utils/checkAuth.js +30 -0
- package/es/utils/findMenuInfoByPath.js +41 -0
- package/es/utils/index.js +99 -0
- package/lib/Layout/AppList.js +1 -1
- package/lib/Layout/GlobalNavigation/NavigationPopup.js +1 -1
- package/lib/Layout/GlobalNavigation/index.js +1 -1
- package/lib/Layout/OrgAppList.js +5 -6
- package/lib/Layout/SideMenu.js +1 -1
- package/lib/Layout/index.js +6 -6
- package/lib/Layout/paaslayout/CompactSideMenu.js +1 -1
- package/lib/Layout/paaslayout/index.js +1 -1
- package/lib/Layout/storage.js +1 -1
- package/lib/index.js +34 -0
- package/lib/utils/checkAuth.js +41 -0
- package/lib/utils/findMenuInfoByPath.js +52 -0
- package/lib/utils/index.js +159 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { Dropdown, Menu, Input, Select, TreeSelect } from 'antd';
|
|
|
4
4
|
import { get } from 'lodash';
|
|
5
5
|
import Icon from '../Icon';
|
|
6
6
|
import { getCurrentAppStore, setCurrentAppStore } from './storage';
|
|
7
|
-
import { traverseTree } from '
|
|
7
|
+
import { traverseTree } from '../utils';
|
|
8
8
|
|
|
9
9
|
const { Option } = Select;
|
|
10
10
|
const MenuList = styled(Menu)`
|
|
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';
|
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { debounce } from 'lodash';
|
|
5
|
-
import { traverseTree, hasLevel3 } from '
|
|
5
|
+
import { traverseTree, hasLevel3 } from '../../utils';
|
|
6
6
|
import Icon from '../Iconfont';
|
|
7
7
|
import { getText } from '../../locale';
|
|
8
8
|
|
|
@@ -169,7 +169,7 @@ export default ({ theme, menus = [], close, actions, popupRef, containerRef }) =
|
|
|
169
169
|
|
|
170
170
|
return menus?.reduce((acc, cur) => {
|
|
171
171
|
const column = Math.max(1, ~~((containerRef.current.clientWidth - 32) / 210));
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
if (!acc.length) {
|
|
174
174
|
acc.push([cur]);
|
|
175
175
|
} else {
|
|
@@ -183,7 +183,7 @@ export default ({ theme, menus = [], close, actions, popupRef, containerRef }) =
|
|
|
183
183
|
const findMinHeightGroup = groups => {
|
|
184
184
|
let minHeight = Infinity;
|
|
185
185
|
let index = 0;
|
|
186
|
-
|
|
186
|
+
|
|
187
187
|
for (let i = 0; i < groups.length; i++) {
|
|
188
188
|
const height = calcColumnHeight(groups[i]);
|
|
189
189
|
if (height < minHeight) {
|
|
@@ -191,10 +191,10 @@ export default ({ theme, menus = [], close, actions, popupRef, containerRef }) =
|
|
|
191
191
|
minHeight = height;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
|
|
194
|
+
|
|
195
195
|
return groups[index];
|
|
196
196
|
};
|
|
197
|
-
|
|
197
|
+
|
|
198
198
|
if (acc.length >= column) {
|
|
199
199
|
const minHeightGroup = findMinHeightGroup(acc);
|
|
200
200
|
minHeightGroup?.push(cur);
|
|
@@ -206,7 +206,7 @@ export default ({ theme, menus = [], close, actions, popupRef, containerRef }) =
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
|
|
209
|
+
|
|
210
210
|
return acc;
|
|
211
211
|
}, []);
|
|
212
212
|
};
|
|
@@ -299,7 +299,7 @@ export default ({ theme, menus = [], close, actions, popupRef, containerRef }) =
|
|
|
299
299
|
{
|
|
300
300
|
menus?.map(menu => (
|
|
301
301
|
<li
|
|
302
|
-
className={cn({ active: menu.code === activeTopMenu?.code})}
|
|
302
|
+
className={cn({ active: menu.code === activeTopMenu?.code })}
|
|
303
303
|
onClick={() => onSelectAppTab(menu)}
|
|
304
304
|
>
|
|
305
305
|
{menu?.[language === 'cn' ? 'groupName' : 'enName']}
|
|
@@ -322,7 +322,7 @@ export default ({ theme, menus = [], close, actions, popupRef, containerRef }) =
|
|
|
322
322
|
(group.children || []).map(menu => (
|
|
323
323
|
<MenuItem
|
|
324
324
|
key={menu.code}
|
|
325
|
-
className={cn({ active: selectedMenuKey === menu.code})}
|
|
325
|
+
className={cn({ active: selectedMenuKey === menu.code })}
|
|
326
326
|
theme={theme}
|
|
327
327
|
onClick={() => onMenuClick(menu)}
|
|
328
328
|
>
|
|
@@ -4,7 +4,7 @@ import cn from 'classnames';
|
|
|
4
4
|
import styled, { createGlobalStyle, withTheme } from 'styled-components';
|
|
5
5
|
import { uniq } from 'lodash';
|
|
6
6
|
import ActionsContext from '../ActionsContext';
|
|
7
|
-
import { hasLevel3 } from '
|
|
7
|
+
import { hasLevel3 } from '../../utils';
|
|
8
8
|
import Icon from '../Iconfont';
|
|
9
9
|
import NavigationPopup from './NavigationPopup';
|
|
10
10
|
|
|
@@ -110,7 +110,7 @@ export default withTheme(
|
|
|
110
110
|
>
|
|
111
111
|
<Icon type="unordered-list" />
|
|
112
112
|
<span>{getText('globalNavigation')}</span>
|
|
113
|
-
<GlobalStyle hasLevel3={hasLevel3(menus)}/>
|
|
113
|
+
<GlobalStyle hasLevel3={hasLevel3(menus)} />
|
|
114
114
|
</Navigation>
|
|
115
115
|
);
|
|
116
116
|
}
|
|
@@ -2,15 +2,14 @@ import { useState, useEffect } from 'react';
|
|
|
2
2
|
import styled, { withTheme, createGlobalStyle } from 'styled-components';
|
|
3
3
|
import { Input, Select, TreeSelect } from 'antd';
|
|
4
4
|
import { get } from 'lodash';
|
|
5
|
-
import { getCurrentAppStore, setCurrentAppStore, getCurrentOrgStore, setCurrentOrgStore, getCurrentOrgTreeStore,setCurrentOrgTreeStore
|
|
6
|
-
import { traverseTree } from '
|
|
5
|
+
import { getCurrentAppStore, setCurrentAppStore, getCurrentOrgStore, setCurrentOrgStore, getCurrentOrgTreeStore, setCurrentOrgTreeStore } from './storage';
|
|
6
|
+
import { traverseTree } from '../utils';
|
|
7
7
|
|
|
8
|
-
const { Group:InputGroup } = Input;
|
|
9
|
-
const { TreeNode } = TreeSelect;
|
|
8
|
+
const { Group: InputGroup } = Input;
|
|
10
9
|
const { Option } = Select;
|
|
11
10
|
|
|
12
11
|
// 机构+应用UI
|
|
13
|
-
const OrgAppsInputGroup= styled(InputGroup)`
|
|
12
|
+
const OrgAppsInputGroup = styled(InputGroup)`
|
|
14
13
|
display: inline-block !important;
|
|
15
14
|
width:auto !important;
|
|
16
15
|
min-width: 260px;
|
|
@@ -259,14 +258,14 @@ export default withTheme(
|
|
|
259
258
|
return find;
|
|
260
259
|
};
|
|
261
260
|
const current = findByKey(selectedKey || get(currentStore, 'key'));
|
|
262
|
-
if(type){
|
|
261
|
+
if (type) {
|
|
263
262
|
return current;
|
|
264
263
|
}
|
|
265
264
|
return current || dataList[0];
|
|
266
265
|
};
|
|
267
266
|
// 初始化数据函数机构树
|
|
268
267
|
const getInitialSelectedTree = (selecteds, dataList) => {
|
|
269
|
-
if(selecteds.length){
|
|
268
|
+
if (selecteds.length) {
|
|
270
269
|
return selecteds;
|
|
271
270
|
} else {
|
|
272
271
|
const temp = dataList.map(res => {
|
|
@@ -290,7 +289,7 @@ export default withTheme(
|
|
|
290
289
|
|
|
291
290
|
// 机构树
|
|
292
291
|
const [selectedOrgTree, setSelectedOrgTree] = useState(getInitialSelectedTree(
|
|
293
|
-
getCurrentOrgTreeStore(),
|
|
292
|
+
getCurrentOrgTreeStore(),
|
|
294
293
|
orgListFormatData
|
|
295
294
|
));
|
|
296
295
|
|
|
@@ -303,7 +302,7 @@ export default withTheme(
|
|
|
303
302
|
));
|
|
304
303
|
|
|
305
304
|
// org变化事件
|
|
306
|
-
const changeOrg = (org={}) => {
|
|
305
|
+
const changeOrg = (org = {}) => {
|
|
307
306
|
setSelectedOrg(org);
|
|
308
307
|
setCurrentOrgStore({
|
|
309
308
|
name: org?.name,
|
|
@@ -314,7 +313,7 @@ export default withTheme(
|
|
|
314
313
|
};
|
|
315
314
|
|
|
316
315
|
const changeOrgTree = (val = []) => {
|
|
317
|
-
if (!val.length){
|
|
316
|
+
if (!val.length) {
|
|
318
317
|
val = orgListFormatData.map(res => {
|
|
319
318
|
return {
|
|
320
319
|
label: res.title,
|
|
@@ -357,16 +356,16 @@ export default withTheme(
|
|
|
357
356
|
}, [orgList, selectedOrgKey, selectedAppKey, orgAppList]);
|
|
358
357
|
|
|
359
358
|
// 如果是多签页的模式 则居右对齐
|
|
360
|
-
let [treeSelectPosition,selectPosition] = [{},{}];
|
|
361
|
-
if(headerTabs){
|
|
359
|
+
let [treeSelectPosition, selectPosition] = [{}, {}];
|
|
360
|
+
if (headerTabs) {
|
|
362
361
|
treeSelectPosition = {
|
|
363
|
-
dropdownPopupAlign:{
|
|
362
|
+
dropdownPopupAlign: {
|
|
364
363
|
points: ['tr', 'br']
|
|
365
364
|
}
|
|
366
365
|
};
|
|
367
366
|
|
|
368
367
|
selectPosition = {
|
|
369
|
-
dropdownAlign:{
|
|
368
|
+
dropdownAlign: {
|
|
370
369
|
points: ['tr', 'br']
|
|
371
370
|
}
|
|
372
371
|
};
|
|
@@ -402,7 +401,7 @@ export default withTheme(
|
|
|
402
401
|
};
|
|
403
402
|
}
|
|
404
403
|
|
|
405
|
-
if(!orgAppShow){
|
|
404
|
+
if (!orgAppShow) {
|
|
406
405
|
return (
|
|
407
406
|
<>
|
|
408
407
|
<AppTreeSelect
|
|
@@ -3,7 +3,7 @@ import styled, { withTheme } from 'styled-components';
|
|
|
3
3
|
import { Menu } from 'antd';
|
|
4
4
|
import { get } from 'lodash';
|
|
5
5
|
import ActionsContext from './ActionsContext';
|
|
6
|
-
import { getSelectedMenuInfo, isGroupMenu, isNewTabMenu, openInNewTab, traverseTree } from '
|
|
6
|
+
import { getSelectedMenuInfo, isGroupMenu, isNewTabMenu, openInNewTab, traverseTree } from '../utils';
|
|
7
7
|
import { setSideMenuStore } from './storage';
|
|
8
8
|
import Iconfont from './Iconfont';
|
|
9
9
|
|
|
@@ -420,7 +420,7 @@ export default withTheme(
|
|
|
420
420
|
{
|
|
421
421
|
menu?.children?.map(({ code, ...menu }) => (
|
|
422
422
|
<MenuItem key={code}>
|
|
423
|
-
<MenuLink {...menu} style={{ paddingLeft: '24px' }}/>
|
|
423
|
+
<MenuLink {...menu} style={{ paddingLeft: '24px' }} />
|
|
424
424
|
</MenuItem>
|
|
425
425
|
))
|
|
426
426
|
}
|
|
@@ -4,9 +4,8 @@ import EnterpriseLayout from './EnterpriseLayout';
|
|
|
4
4
|
import PaasLayout from './paaslayout';
|
|
5
5
|
import HeaderNavs from './HeaderNavs';
|
|
6
6
|
import HeaderTabs from './HeaderTabs';
|
|
7
|
-
import getCheckAuth from './checkAuth';
|
|
8
7
|
import AuthContext from '../AuthContext';
|
|
9
|
-
import { safeParseJSON, findMenuInfoByPath } from '
|
|
8
|
+
import { safeParseJSON, findMenuInfoByPath, getCheckAuth } from '../utils';
|
|
10
9
|
import ActionsContext from './ActionsContext';
|
|
11
10
|
import createActions from './createActions';
|
|
12
11
|
import { getLanguageStore } from './storage';
|
|
@@ -20,7 +19,7 @@ export const HeaderActionItem = props => (
|
|
|
20
19
|
export * from './HeaderNavs';
|
|
21
20
|
|
|
22
21
|
|
|
23
|
-
const TNTLayout = ({ type, config, ...props }) => {
|
|
22
|
+
const TNTLayout = ({ type, config, showMenuInIframe = false, ...props }) => {
|
|
24
23
|
const headerHeight = props.size === 'large' ? 60 : 50;
|
|
25
24
|
const theme = {
|
|
26
25
|
size: props.size,
|
|
@@ -37,7 +36,7 @@ const TNTLayout = ({ type, config, ...props }) => {
|
|
|
37
36
|
lightBgColor: '#F1F2F5',
|
|
38
37
|
blueBgColor: '#1D4295' // 默认的蓝色主题
|
|
39
38
|
};
|
|
40
|
-
const isInIframe = self !== top;
|
|
39
|
+
const isInIframe = showMenuInIframe ? false : (self !== top && !window.navigator.userAgent.includes('mo-fang-app'));
|
|
41
40
|
// 前期拼写错误,导致需要兼容处理
|
|
42
41
|
const extraHeaderActions = props.extraHeaderActions || props.extralHeaderActions;
|
|
43
42
|
const extendMap = typeof props.extendMap === 'string' ? safeParseJSON(props.extendMap, {}) : props.extendMap;
|
|
@@ -87,7 +86,7 @@ const TNTLayout = ({ type, config, ...props }) => {
|
|
|
87
86
|
/>
|
|
88
87
|
}
|
|
89
88
|
{
|
|
90
|
-
(!type || !['paas','enterprise'].includes(type)) &&
|
|
89
|
+
(!type || !['paas', 'enterprise'].includes(type)) &&
|
|
91
90
|
<Layout
|
|
92
91
|
menuAlignMode={menuAlignMode}
|
|
93
92
|
config={config}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useEffect, Component } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import cn from 'classnames';
|
|
4
|
-
import { isNewTabMenu, openInNewTab } from '
|
|
4
|
+
import { isNewTabMenu, openInNewTab } from '../../utils';
|
|
5
5
|
import Iconfont from '../Iconfont';
|
|
6
6
|
|
|
7
7
|
const SideMenu = styled.ul`
|
|
@@ -3,7 +3,7 @@ import styled, { withTheme } from 'styled-components';
|
|
|
3
3
|
import cn from 'classnames';
|
|
4
4
|
import { Layout } from 'antd';
|
|
5
5
|
import { get, reduce, isUndefined } from 'lodash';
|
|
6
|
-
import { getSelectedMenuInfo } from '
|
|
6
|
+
import { getSelectedMenuInfo } from '../../utils';
|
|
7
7
|
import HeaderNavs from '../HeaderNavs';
|
|
8
8
|
import Header from './Header';
|
|
9
9
|
import SideMenu from './SideMenu';
|
|
@@ -76,7 +76,7 @@ export default withTheme(
|
|
|
76
76
|
const [userInfo, setUserInfo] = useState(props.userInfo || {});
|
|
77
77
|
let theme = getThemeStore() || userInfo.theme || 'themeS2';
|
|
78
78
|
// theme === 'default' ? 'themeS2' : theme;
|
|
79
|
-
theme = ['default','themeS3'].includes(theme) ? 'themeS2' : theme;
|
|
79
|
+
theme = ['default', 'themeS3'].includes(theme) ? 'themeS2' : theme;
|
|
80
80
|
|
|
81
81
|
const language = getLanguageStore() || userInfo.lang || 'cn';
|
|
82
82
|
const menusMapByApp = menus.reduce((acc, menu) => {
|
package/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { get } from 'lodash';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export const getCheckAuth = menus => {
|
|
4
4
|
const getAuthMap = (menus = [], authMap = {}) => {
|
|
5
5
|
return menus.reduce(
|
|
6
6
|
(acc, { code, groupName, functionList, children }) => {
|
|
@@ -23,3 +23,5 @@ export default menus => {
|
|
|
23
23
|
|
|
24
24
|
return (menuCode, funCode) => !!get(authMap, `${menuCode}${funCode ? `.${funCode}` : ''}`);
|
|
25
25
|
};
|
|
26
|
+
|
|
27
|
+
export default getCheckAuth;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { traverseTree, isGroupMenu } from '.';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const findMenuInfoByPath = (menuTree, path, matchFunc) => {
|
|
5
|
+
let menu;
|
|
6
|
+
let subMenu;
|
|
7
|
+
let matchedSubMenu;
|
|
8
|
+
let parentMenus;
|
|
9
|
+
|
|
10
|
+
if (path) {
|
|
11
|
+
traverseTree(menuTree, (menu, pnode, pnodes) => {
|
|
12
|
+
if (!isGroupMenu(menu)) {
|
|
13
|
+
if (menu?.path === path) {
|
|
14
|
+
subMenu = menu;
|
|
15
|
+
menu = pnode;
|
|
16
|
+
parentMenus = pnodes;
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!matchedSubMenu && matchFunc && matchFunc(menu)) {
|
|
21
|
+
matchedSubMenu = menu;
|
|
22
|
+
menu = pnode;
|
|
23
|
+
parentMenus = pnodes;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
subMenu,
|
|
30
|
+
matchedSubMenu,
|
|
31
|
+
menu,
|
|
32
|
+
parentMenus
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return { subMenu, menu, parentMenus };
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default findMenuInfoByPath;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export * from './checkAuth';
|
|
2
|
+
export * from './findMenuInfoByPath';
|
|
3
|
+
|
|
1
4
|
export const isGroupMenu = menu => menu?.children && !menu?.path;
|
|
2
5
|
|
|
3
6
|
export const getSelectedMenuInfo = (selectedKey, menus = []) => {
|
|
@@ -32,41 +35,6 @@ export const getSelectedMenuInfo = (selectedKey, menus = []) => {
|
|
|
32
35
|
};
|
|
33
36
|
};
|
|
34
37
|
|
|
35
|
-
export const findMenuInfoByPath = (menuTree, path, matchFunc) => {
|
|
36
|
-
let menu;
|
|
37
|
-
let subMenu;
|
|
38
|
-
let matchedSubMenu;
|
|
39
|
-
let parentMenus;
|
|
40
|
-
|
|
41
|
-
if (path) {
|
|
42
|
-
traverseTree(menuTree, (menu, pnode, pnodes) => {
|
|
43
|
-
if (!isGroupMenu(menu)) {
|
|
44
|
-
if (menu?.path === path) {
|
|
45
|
-
subMenu = menu;
|
|
46
|
-
menu = pnode;
|
|
47
|
-
parentMenus = pnodes;
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!matchedSubMenu && matchFunc && matchFunc(menu)) {
|
|
52
|
-
matchedSubMenu = menu;
|
|
53
|
-
menu = pnode;
|
|
54
|
-
parentMenus = pnodes;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
subMenu,
|
|
61
|
-
matchedSubMenu,
|
|
62
|
-
menu,
|
|
63
|
-
parentMenus
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return { subMenu, menu, parentMenus };
|
|
68
|
-
};
|
|
69
|
-
|
|
70
38
|
export const hasLevel3 = menus => {
|
|
71
39
|
return menus?.some(
|
|
72
40
|
menu => menu?.children?.some(item => item?.children?.length)
|