tntd 1.3.66 → 1.4.2
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/babel.config.js +1 -1
- package/dist/0645cf743e4e44ca9da321d689897f07.png +0 -0
- package/dist/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
- package/dist/1.tntd.js +12 -0
- package/dist/1d0b52448de217857b270af807e9360d.png +0 -0
- package/dist/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
- package/dist/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
- package/dist/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
- package/dist/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
- package/dist/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
- package/dist/4abe481e130d7be0574e45573de8beb7.png +0 -0
- package/dist/95ee2260a509cd630d89c5367ed1973b.png +0 -0
- package/dist/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
- package/dist/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
- package/dist/stats.json +45855 -0
- package/dist/tntd.css +1 -0
- package/dist/tntd.js +15 -0
- package/es/ArrayInput/README.md +129 -0
- package/es/ArrayInput/icon.js +24 -0
- package/es/ArrayInput/index.js +282 -0
- package/es/ArrayInput/index.less +20 -0
- package/es/AuthContext.js +4 -0
- package/es/Columns/README.md +149 -0
- package/es/Columns/index.js +86 -0
- package/es/Columns/index.less +75 -0
- package/es/DevelopmentLogin/LoginModal.js +126 -0
- package/es/DevelopmentLogin/README.md +49 -0
- package/es/DevelopmentLogin/index.js +40 -0
- package/es/Ellipsis/README.md +104 -0
- package/es/Ellipsis/Svg/CopySVG.js +63 -0
- package/es/Ellipsis/Svg/TickSVG.js +41 -0
- package/es/Ellipsis/index.js +143 -0
- package/es/Ellipsis/index.less +56 -0
- package/es/Handle/README.md +104 -0
- package/es/Handle/index.js +92 -0
- package/es/Handle/index.less +9 -0
- package/es/Icon/README.md +119 -0
- package/es/Icon/fonts/demo.css +539 -0
- package/es/Icon/fonts/demo_index.html +3345 -0
- package/es/Icon/fonts/iconfont.css +569 -0
- package/es/Icon/fonts/iconfont.eot +0 -0
- package/es/Icon/fonts/iconfont.js +41 -0
- package/es/Icon/fonts/iconfont.json +975 -0
- package/es/Icon/fonts/iconfont.svg +440 -0
- package/es/Icon/fonts/iconfont.ttf +0 -0
- package/es/Icon/fonts/iconfont.woff +0 -0
- package/es/Icon/fonts/iconfont.woff2 +0 -0
- package/es/Icon/iconList.js +1 -0
- package/es/Icon/index.js +26 -0
- package/es/Icon/index.less +9 -0
- package/es/Img/Contain.js +69 -0
- package/es/Img/Cover.js +126 -0
- package/es/Img/README.md +131 -0
- package/es/Img/index.js +76 -0
- package/es/Layout/ActionsContext.js +3 -0
- package/es/Layout/AppList.js +233 -0
- package/es/Layout/Application.js +115 -0
- package/es/Layout/Avatar.js +116 -0
- package/es/Layout/CompatibleLanguage.js +179 -0
- package/es/Layout/EnterpriseLayout/Avatar.js +144 -0
- package/es/Layout/EnterpriseLayout/Language.js +81 -0
- package/es/Layout/EnterpriseLayout/Theme.js +77 -0
- package/es/Layout/EnterpriseLayout/index.js +31 -0
- package/es/Layout/GlobalNavigation/NavigationPopup.js +396 -0
- package/es/Layout/GlobalNavigation/index.js +137 -0
- package/es/Layout/Header.js +95 -0
- package/es/Layout/HeaderActions.js +107 -0
- package/es/Layout/HeaderNavs.js +93 -0
- package/es/Layout/HeaderTabs.js +264 -0
- package/es/Layout/Iconfont.js +4 -0
- package/es/Layout/Language.js +81 -0
- package/es/Layout/Layout.js +234 -0
- package/es/Layout/Logo.js +86 -0
- package/es/Layout/OrgAppList.js +310 -0
- package/es/Layout/README.md +783 -0
- package/es/Layout/SideMenu.js +340 -0
- package/es/Layout/Theme.js +107 -0
- package/es/Layout/checkAuth.js +29 -0
- package/es/Layout/createActions.js +39 -0
- package/es/Layout/images/avatar/empty.png +0 -0
- package/es/Layout/images/avatar/female1.png +0 -0
- package/es/Layout/images/avatar/female2.png +0 -0
- package/es/Layout/images/avatar/female3.png +0 -0
- package/es/Layout/images/avatar/female4.png +0 -0
- package/es/Layout/images/avatar/female5.png +0 -0
- package/es/Layout/images/avatar/female6.png +0 -0
- package/es/Layout/images/avatar/male1.png +0 -0
- package/es/Layout/images/avatar/male2.png +0 -0
- package/es/Layout/images/avatar/male3.png +0 -0
- package/es/Layout/images/avatar/male4.png +0 -0
- package/es/Layout/images/avatar/male5.png +0 -0
- package/es/Layout/images/avatar/male6.png +0 -0
- package/es/Layout/images/index.js +35 -0
- package/es/Layout/images/logo/baldur.svg +14 -0
- package/es/Layout/images/logo/bi.svg +14 -0
- package/es/Layout/images/logo/bridge.svg +15 -0
- package/es/Layout/images/logo/convert.svg +18 -0
- package/es/Layout/images/logo/dataocean.svg +31 -0
- package/es/Layout/images/logo/default.svg +19 -0
- package/es/Layout/images/logo/dispatch.svg +14 -0
- package/es/Layout/images/logo/graph.svg +26 -0
- package/es/Layout/images/logo/handle.svg +10 -0
- package/es/Layout/images/logo/indicator.svg +41 -0
- package/es/Layout/images/logo/kafka.svg +12 -0
- package/es/Layout/images/logo/logo-custom.svg +13 -0
- package/es/Layout/images/logo/model.svg +17 -0
- package/es/Layout/images/logo/mysql.svg +15 -0
- package/es/Layout/images/logo/orion.svg +24 -0
- package/es/Layout/images/logo/salaxy.svg +11 -0
- package/es/Layout/images/logo/storage.svg +16 -0
- package/es/Layout/images/logo/tnt_cli_identify.svg +19 -0
- package/es/Layout/images/logo/turing.svg +35 -0
- package/es/Layout/images/theme/theme1.svg +35 -0
- package/es/Layout/images/theme/theme2.svg +33 -0
- package/es/Layout/index.js +122 -0
- package/es/Layout/paaslayout/CompactSideMenu.js +167 -0
- package/es/Layout/paaslayout/Header.js +77 -0
- package/es/Layout/paaslayout/Logo.js +22 -0
- package/es/Layout/paaslayout/SideMenu.js +168 -0
- package/es/Layout/paaslayout/index.js +235 -0
- package/es/Layout/storage.js +47 -0
- package/es/Layout/utils.js +136 -0
- package/es/LoadingButton/README.md +75 -0
- package/es/LoadingButton/index.js +45 -0
- package/es/Modal/README.md +59 -0
- package/es/Modal/index.js +96 -0
- package/es/Modal/index.less +86 -0
- package/es/Page/Box.js +74 -0
- package/es/Page/README.md +180 -0
- package/es/Page/index.js +165 -0
- package/es/Page/index.less +144 -0
- package/es/Page/utils.js +23 -0
- package/es/QueryForm/Field/Checkbox.js +21 -0
- package/es/QueryForm/Field/Select.js +80 -0
- package/es/QueryForm/Field/SelectInput.js +92 -0
- package/es/QueryForm/Field/fieldsMap.js +32 -0
- package/es/QueryForm/Field/index.js +157 -0
- package/es/QueryForm/README.md +512 -0
- package/es/QueryForm/createActions.js +53 -0
- package/es/QueryForm/index.js +384 -0
- package/es/QueryForm/index.less +133 -0
- package/es/QueryForm/useForm.js +7 -0
- package/es/QueryListScene/List.js +378 -0
- package/es/QueryListScene/QueryForm.js +166 -0
- package/es/QueryListScene/QueryListScene.js +76 -0
- package/es/QueryListScene/README.md +790 -0
- package/es/QueryListScene/Title.js +12 -0
- package/es/QueryListScene/Toolbar.js +20 -0
- package/es/QueryListScene/createActions.js +72 -0
- package/es/QueryListScene/index.js +19 -0
- package/es/QueryListScene/index.less +97 -0
- package/es/QueryListScene/useActions.js +7 -0
- package/es/Select/DropDownWrap.js +116 -0
- package/es/Select/README.md +68 -0
- package/es/Select/index.js +622 -0
- package/es/Table/README.md +109 -0
- package/es/Table/ResizableTable/index.js +110 -0
- package/es/Table/ResizableTable/index.less +36 -0
- package/es/Table/index.js +35 -0
- package/es/Title/README.md +106 -0
- package/es/Title/index.js +40 -0
- package/es/Title/index.less +170 -0
- package/es/index.js +19 -0
- package/es/locale.js +60 -0
- package/package.json +1 -1
- package/doc-scripts.config.js +0 -37
- package/doc-scripts.renderer.js +0 -11
- package/docs/README.md +0 -1643
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import "antd/lib/layout/style";
|
|
2
|
+
import _Layout from "antd/lib/layout";
|
|
3
|
+
|
|
4
|
+
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; }
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
8
|
+
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; }
|
|
9
|
+
|
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
11
|
+
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
|
|
18
|
+
function _templateObject() {
|
|
19
|
+
var data = _taggedTemplateLiteral(["\n position: relative;\n height: 100vh;\n overflow: hidden;\n & > .ant-layout {\n flex-direction: row;\n & > .ant-layout-content {\n overflow-x: hidden;\n flex: 1;\n }\n }\n .tnt-layout-sider {\n overflow-x: hidden;\n background: #fff !important;\n box-shadow: 0 1px 10px 0 rgba(0,0,0,0.10);\n z-index: 8;\n }\n &.isInIframe, &.isEmptyLayout {\n .tnt-layout-sider {\n display: none;\n }\n }\n &.tnt-themeS1 .tnt-layout-sider {\n background: #fff !important;\n }\n .tnt-layout-content {\n background: ", ";\n }\n"]);
|
|
20
|
+
|
|
21
|
+
_templateObject = function _templateObject() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
29
|
+
|
|
30
|
+
import { useState, useEffect } from 'react';
|
|
31
|
+
import styled, { withTheme } from 'styled-components';
|
|
32
|
+
import cn from 'classnames';
|
|
33
|
+
import { get, reduce, isUndefined } from 'lodash';
|
|
34
|
+
import { getSelectedMenuInfo } from '../utils';
|
|
35
|
+
import HeaderNavs from '../HeaderNavs';
|
|
36
|
+
import Header from './Header';
|
|
37
|
+
import SideMenu from './SideMenu';
|
|
38
|
+
import CompactSideMenu from './CompactSideMenu';
|
|
39
|
+
import { getLanguageStore, getThemeStore } from '../storage';
|
|
40
|
+
var Content = _Layout.Content,
|
|
41
|
+
Sider = _Layout.Sider;
|
|
42
|
+
var TNTPaasLayout = styled(_Layout)(_templateObject(), function (props) {
|
|
43
|
+
return props.theme.lightBgColor;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var noop = function noop() {
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default withTheme(function (props) {
|
|
51
|
+
var appKey = props.appKey,
|
|
52
|
+
logo = props.logo,
|
|
53
|
+
name = props.name,
|
|
54
|
+
enName = props.enName,
|
|
55
|
+
isInIframe = props.isInIframe,
|
|
56
|
+
isEmptyLayout = props.isEmptyLayout,
|
|
57
|
+
selectedAppKey = props.selectedAppKey,
|
|
58
|
+
appList = props.appList,
|
|
59
|
+
_props$config = props.config,
|
|
60
|
+
config = _props$config === void 0 ? {} : _props$config,
|
|
61
|
+
extraHeaderActions = props.extraHeaderActions,
|
|
62
|
+
headerNavs = props.headerNavs,
|
|
63
|
+
sideMenu = props.sideMenu,
|
|
64
|
+
selectedMenuKey = props.selectedMenuKey,
|
|
65
|
+
_props$menuAlignMode = props.menuAlignMode,
|
|
66
|
+
menuAlignMode = _props$menuAlignMode === void 0 ? 'side' : _props$menuAlignMode,
|
|
67
|
+
_props$menus = props.menus,
|
|
68
|
+
menus = _props$menus === void 0 ? [] : _props$menus,
|
|
69
|
+
formatMenuPath = props.formatMenuPath,
|
|
70
|
+
changeRouter = props.changeRouter,
|
|
71
|
+
_props$onLogoClick = props.onLogoClick,
|
|
72
|
+
onLogoClick = _props$onLogoClick === void 0 ? noop : _props$onLogoClick,
|
|
73
|
+
_props$onThemeChange = props.onThemeChange,
|
|
74
|
+
_onThemeChange = _props$onThemeChange === void 0 ? noop : _props$onThemeChange,
|
|
75
|
+
_props$onLanguageChan = props.onLanguageChange,
|
|
76
|
+
_onLanguageChange = _props$onLanguageChan === void 0 ? noop : _props$onLanguageChan,
|
|
77
|
+
_props$onApplicationC = props.onApplicationChange,
|
|
78
|
+
_onApplicationChange = _props$onApplicationC === void 0 ? noop : _props$onApplicationC,
|
|
79
|
+
_props$onAppChange = props.onAppChange,
|
|
80
|
+
onAppChange = _props$onAppChange === void 0 ? noop : _props$onAppChange,
|
|
81
|
+
onLogout = props.onLogout,
|
|
82
|
+
_props$onBeforeMenuCh = props.onBeforeMenuChange,
|
|
83
|
+
onBeforeMenuChange = _props$onBeforeMenuCh === void 0 ? noop : _props$onBeforeMenuCh,
|
|
84
|
+
_props$onMenuChange = props.onMenuChange,
|
|
85
|
+
onMenuChange = _props$onMenuChange === void 0 ? noop : _props$onMenuChange,
|
|
86
|
+
_props$onMenuSelect = props.onMenuSelect,
|
|
87
|
+
onMenuSelect = _props$onMenuSelect === void 0 ? noop : _props$onMenuSelect,
|
|
88
|
+
_props$onHeaderNavCha = props.onHeaderNavChange,
|
|
89
|
+
onHeaderNavChange = _props$onHeaderNavCha === void 0 ? noop : _props$onHeaderNavCha;
|
|
90
|
+
|
|
91
|
+
var _useState = useState(props.userInfo || {}),
|
|
92
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
93
|
+
userInfo = _useState2[0],
|
|
94
|
+
setUserInfo = _useState2[1];
|
|
95
|
+
|
|
96
|
+
var theme = getThemeStore() || userInfo.theme || 'themeS2'; // theme === 'default' ? 'themeS2' : theme;
|
|
97
|
+
|
|
98
|
+
theme = ['default', 'themeS3'].includes(theme) ? 'themeS2' : theme;
|
|
99
|
+
var language = getLanguageStore() || userInfo.lang || 'cn';
|
|
100
|
+
var menusMapByApp = menus.reduce(function (acc, menu) {
|
|
101
|
+
var subMenus = menu.children || [];
|
|
102
|
+
var singleGroupMap = subMenus.reduce(function (acc, subMenu) {
|
|
103
|
+
var path = subMenu.path;
|
|
104
|
+
var appKey = !/^http/i.test(path) ? path == null ? void 0 : path.match(/\/([^\/]+)/)[1] : '';
|
|
105
|
+
|
|
106
|
+
if (appKey) {
|
|
107
|
+
acc[appKey] = acc[appKey] || _objectSpread({}, menu, {
|
|
108
|
+
children: []
|
|
109
|
+
});
|
|
110
|
+
acc[appKey].children.push(subMenu);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return acc;
|
|
114
|
+
}, {});
|
|
115
|
+
|
|
116
|
+
for (var _appKey in singleGroupMap) {
|
|
117
|
+
acc[_appKey] = acc[_appKey] || [];
|
|
118
|
+
|
|
119
|
+
acc[_appKey].push(singleGroupMap[_appKey]);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return acc;
|
|
123
|
+
}, {});
|
|
124
|
+
|
|
125
|
+
var _useState3 = useState(appKey),
|
|
126
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
127
|
+
currentAppKey = _useState4[0],
|
|
128
|
+
setCurrentAppKey = _useState4[1];
|
|
129
|
+
|
|
130
|
+
var apps = reduce(menusMapByApp, function (acc, value, key) {
|
|
131
|
+
acc.push({
|
|
132
|
+
appKey: key,
|
|
133
|
+
name: key
|
|
134
|
+
});
|
|
135
|
+
return acc;
|
|
136
|
+
}, []);
|
|
137
|
+
var isMenusTop = menuAlignMode === 'top';
|
|
138
|
+
var headerNavMenus = headerNavs;
|
|
139
|
+
var currentSystemMenus = menusMapByApp[currentAppKey] || [];
|
|
140
|
+
|
|
141
|
+
var _useState5 = useState(get(currentSystemMenus, '0.code')),
|
|
142
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
143
|
+
currentHeaderNavKey = _useState6[0],
|
|
144
|
+
setCurrentHeaderNavKey = _useState6[1];
|
|
145
|
+
|
|
146
|
+
var sideMenus = isMenusTop ? get(currentSystemMenus.find(function (_ref) {
|
|
147
|
+
var code = _ref.code;
|
|
148
|
+
return currentHeaderNavKey === code;
|
|
149
|
+
}), 'children', []) : currentSystemMenus;
|
|
150
|
+
var FinalSideMenu = isMenusTop ? CompactSideMenu : SideMenu; // 一级菜单放在顶部(Header里面菜单作为一级导航)
|
|
151
|
+
|
|
152
|
+
if (isMenusTop) {
|
|
153
|
+
headerNavMenus = React.createElement(HeaderNavs, {
|
|
154
|
+
selectedKey: currentHeaderNavKey,
|
|
155
|
+
navs: currentSystemMenus.map(function (item) {
|
|
156
|
+
return _objectSpread({}, item, {
|
|
157
|
+
key: item.code,
|
|
158
|
+
name: item.groupName
|
|
159
|
+
});
|
|
160
|
+
}),
|
|
161
|
+
onChange: function onChange(item) {
|
|
162
|
+
setCurrentHeaderNavKey(item.key);
|
|
163
|
+
onHeaderNavChange(item);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
useEffect(function () {
|
|
169
|
+
setUserInfo(props.userInfo);
|
|
170
|
+
}, [props.userInfo]);
|
|
171
|
+
useEffect(function () {
|
|
172
|
+
if (isMenusTop) {
|
|
173
|
+
setCurrentHeaderNavKey(get(getSelectedMenuInfo(selectedMenuKey, menus), 'menu.code'));
|
|
174
|
+
}
|
|
175
|
+
}, [menus, selectedMenuKey]);
|
|
176
|
+
return React.createElement(TNTPaasLayout, {
|
|
177
|
+
className: cn("tnt-".concat(theme, " ").concat(props.className || ''), {
|
|
178
|
+
'large-size': props.theme.size === 'large',
|
|
179
|
+
compatible: props.theme.compatible,
|
|
180
|
+
isInIframe: isInIframe,
|
|
181
|
+
isEmptyLayout: isEmptyLayout,
|
|
182
|
+
noAppList: !appList
|
|
183
|
+
})
|
|
184
|
+
}, React.createElement(Header, {
|
|
185
|
+
logo: logo,
|
|
186
|
+
name: name,
|
|
187
|
+
enName: enName,
|
|
188
|
+
language: language,
|
|
189
|
+
theme: theme,
|
|
190
|
+
userInfo: userInfo,
|
|
191
|
+
config: config,
|
|
192
|
+
appKey: currentAppKey,
|
|
193
|
+
selectedAppKey: selectedAppKey,
|
|
194
|
+
menus: menus,
|
|
195
|
+
appList: appList,
|
|
196
|
+
apps: apps,
|
|
197
|
+
extraActions: extraHeaderActions,
|
|
198
|
+
onLogoClick: onLogoClick,
|
|
199
|
+
onAppChange: onAppChange,
|
|
200
|
+
onThemeChange: function onThemeChange(theme) {
|
|
201
|
+
setUserInfo(_objectSpread({}, userInfo, {
|
|
202
|
+
theme: theme
|
|
203
|
+
}));
|
|
204
|
+
_onThemeChange && _onThemeChange(theme);
|
|
205
|
+
},
|
|
206
|
+
onLanguageChange: function onLanguageChange(lang) {
|
|
207
|
+
setUserInfo(_objectSpread({}, userInfo, {
|
|
208
|
+
lang: lang
|
|
209
|
+
}));
|
|
210
|
+
_onLanguageChange && _onLanguageChange(lang);
|
|
211
|
+
},
|
|
212
|
+
onApplicationChange: function onApplicationChange(appKey) {
|
|
213
|
+
setCurrentAppKey(appKey);
|
|
214
|
+
|
|
215
|
+
_onApplicationChange(appKey);
|
|
216
|
+
},
|
|
217
|
+
onLogout: onLogout
|
|
218
|
+
}, headerNavMenus), React.createElement(_Layout, null, !isUndefined(sideMenu) ? sideMenu : React.createElement(Sider, {
|
|
219
|
+
breakpoint: "md",
|
|
220
|
+
className: "tnt-layout-sider",
|
|
221
|
+
width: 220,
|
|
222
|
+
trigger: null
|
|
223
|
+
}, React.createElement(FinalSideMenu, {
|
|
224
|
+
language: language,
|
|
225
|
+
selectedKey: selectedMenuKey,
|
|
226
|
+
menus: sideMenus,
|
|
227
|
+
formatMenuPath: formatMenuPath,
|
|
228
|
+
changeRouter: changeRouter,
|
|
229
|
+
onBeforeChange: onBeforeMenuChange,
|
|
230
|
+
onChange: onMenuChange,
|
|
231
|
+
onSelect: onMenuSelect
|
|
232
|
+
})), React.createElement(Content, {
|
|
233
|
+
className: "tnt-layout-content"
|
|
234
|
+
}, props.children)));
|
|
235
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
import { safeParseJSON } from './utils';
|
|
8
|
+
export var getSideMenuStore = function getSideMenuStore() {
|
|
9
|
+
return safeParseJSON(localStorage.getItem('sideMenu'), {});
|
|
10
|
+
};
|
|
11
|
+
export var setSideMenuStore = function setSideMenuStore() {
|
|
12
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
13
|
+
localStorage.setItem('sideMenu', JSON.stringify(_objectSpread({}, getSideMenuStore(), {}, params)));
|
|
14
|
+
};
|
|
15
|
+
export var setCurrentAppStore = function setCurrentAppStore() {
|
|
16
|
+
var currentApp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17
|
+
localStorage.setItem('currentApp', JSON.stringify(currentApp));
|
|
18
|
+
};
|
|
19
|
+
export var getCurrentAppStore = function getCurrentAppStore() {
|
|
20
|
+
return safeParseJSON(localStorage.getItem('currentApp'), {});
|
|
21
|
+
};
|
|
22
|
+
export var setCurrentOrgStore = function setCurrentOrgStore() {
|
|
23
|
+
var currentOrg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
24
|
+
localStorage.setItem('currentOrg', JSON.stringify(currentOrg));
|
|
25
|
+
};
|
|
26
|
+
export var getCurrentOrgStore = function getCurrentOrgStore() {
|
|
27
|
+
return safeParseJSON(localStorage.getItem('currentOrg'), {});
|
|
28
|
+
};
|
|
29
|
+
export var setCurrentOrgTreeStore = function setCurrentOrgTreeStore() {
|
|
30
|
+
var currentOrgTree = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
31
|
+
localStorage.setItem('currentOrgTree', JSON.stringify(currentOrgTree));
|
|
32
|
+
};
|
|
33
|
+
export var getCurrentOrgTreeStore = function getCurrentOrgTreeStore() {
|
|
34
|
+
return safeParseJSON(localStorage.getItem('currentOrgTree'), []);
|
|
35
|
+
};
|
|
36
|
+
export var setLanguageStore = function setLanguageStore(lang) {
|
|
37
|
+
return localStorage.setItem('lang', lang);
|
|
38
|
+
};
|
|
39
|
+
export var getLanguageStore = function getLanguageStore() {
|
|
40
|
+
return localStorage.getItem('lang');
|
|
41
|
+
};
|
|
42
|
+
export var setThemeStore = function setThemeStore(theme) {
|
|
43
|
+
return localStorage.setItem('theme', theme);
|
|
44
|
+
};
|
|
45
|
+
export var getThemeStore = function getThemeStore() {
|
|
46
|
+
return localStorage.getItem('theme');
|
|
47
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
4
|
+
|
|
5
|
+
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
|
6
|
+
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
|
8
|
+
|
|
9
|
+
export var isGroupMenu = function isGroupMenu(menu) {
|
|
10
|
+
return (menu == null ? void 0 : menu.children) && !(menu == null ? void 0 : menu.path);
|
|
11
|
+
};
|
|
12
|
+
export var getSelectedMenuInfo = function getSelectedMenuInfo(selectedKey) {
|
|
13
|
+
var menus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
14
|
+
var subMenu;
|
|
15
|
+
var menu;
|
|
16
|
+
var parentMenus = [];
|
|
17
|
+
|
|
18
|
+
if (selectedKey) {
|
|
19
|
+
traverseTree(menus, function (node, pnode, pnodes) {
|
|
20
|
+
if (!isGroupMenu(node) && node.code === selectedKey) {
|
|
21
|
+
subMenu = node;
|
|
22
|
+
menu = pnode;
|
|
23
|
+
parentMenus = pnodes;
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
// 默认找到第一个菜单项
|
|
29
|
+
traverseTree(menus, function (node, pnode, pnodes) {
|
|
30
|
+
if (!isGroupMenu(node)) {
|
|
31
|
+
subMenu = node;
|
|
32
|
+
menu = pnode;
|
|
33
|
+
parentMenus = pnodes;
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
subMenu: subMenu,
|
|
41
|
+
menu: menu,
|
|
42
|
+
parentMenus: parentMenus
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export var findMenuInfoByPath = function findMenuInfoByPath(menuTree, path, matchFunc) {
|
|
46
|
+
var menu;
|
|
47
|
+
var subMenu;
|
|
48
|
+
var matchedSubMenu;
|
|
49
|
+
var parentMenus;
|
|
50
|
+
|
|
51
|
+
if (path) {
|
|
52
|
+
traverseTree(menuTree, function (menu, pnode, pnodes) {
|
|
53
|
+
if (!isGroupMenu(menu)) {
|
|
54
|
+
var _menu;
|
|
55
|
+
|
|
56
|
+
if (((_menu = menu) == null ? void 0 : _menu.path) === path) {
|
|
57
|
+
subMenu = menu;
|
|
58
|
+
menu = pnode;
|
|
59
|
+
parentMenus = pnodes;
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!matchedSubMenu && matchFunc && matchFunc(menu)) {
|
|
64
|
+
matchedSubMenu = menu;
|
|
65
|
+
menu = pnode;
|
|
66
|
+
parentMenus = pnodes;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
subMenu: subMenu,
|
|
72
|
+
matchedSubMenu: matchedSubMenu,
|
|
73
|
+
menu: menu,
|
|
74
|
+
parentMenus: parentMenus
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
subMenu: subMenu,
|
|
80
|
+
menu: menu,
|
|
81
|
+
parentMenus: parentMenus
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export var hasLevel3 = function hasLevel3(menus) {
|
|
85
|
+
return menus == null ? void 0 : menus.some(function (menu) {
|
|
86
|
+
var _menu$children;
|
|
87
|
+
|
|
88
|
+
return menu == null ? void 0 : (_menu$children = menu.children) == null ? void 0 : _menu$children.some(function (item) {
|
|
89
|
+
var _item$children;
|
|
90
|
+
|
|
91
|
+
return item == null ? void 0 : (_item$children = item.children) == null ? void 0 : _item$children.length;
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
export var isNewTabMenu = function isNewTabMenu(menu) {
|
|
96
|
+
var _ref = menu || {},
|
|
97
|
+
target = _ref.target,
|
|
98
|
+
path = _ref.path;
|
|
99
|
+
|
|
100
|
+
return target === '_blank' || /^http/i.test(path) && /blankType=newTarget/.test(path);
|
|
101
|
+
};
|
|
102
|
+
export var openInNewTab = function openInNewTab(path) {
|
|
103
|
+
window.open(path, '_blank');
|
|
104
|
+
};
|
|
105
|
+
export var traverseTree = function traverseTree(treeData, callback, pnode) {
|
|
106
|
+
var pnodes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
107
|
+
(treeData || []).every(function (node, index) {
|
|
108
|
+
var result;
|
|
109
|
+
|
|
110
|
+
if (callback) {
|
|
111
|
+
result = callback(node, pnode, (pnodes == null ? void 0 : pnodes.length) ? pnodes : [pnode].filter(function (item) {
|
|
112
|
+
return !!item;
|
|
113
|
+
}), index);
|
|
114
|
+
} // 回调函数返回false则终止遍历
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if (result !== false) {
|
|
118
|
+
node && traverseTree(node.children || [], callback, node, [node].concat(_toConsumableArray(pnodes)));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return result !== false;
|
|
122
|
+
});
|
|
123
|
+
return treeData;
|
|
124
|
+
};
|
|
125
|
+
export var safeParseJSON = function safeParseJSON(str, defaultObj) {
|
|
126
|
+
var result;
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
result = JSON.parse(str);
|
|
130
|
+
} catch (err) {
|
|
131
|
+
console.warn('json parse error:', err);
|
|
132
|
+
result = typeof defaultObj === 'undefined' ? str : defaultObj;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return result || defaultObj;
|
|
136
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
## LoadingButton
|
|
2
|
+
主要用于点击需要与后端有数据交互的场景,自动添加loading状态及防止重复提交问题,支持两种使用方式:
|
|
3
|
+
- onClick 方法返回一个promise[推荐方式],不需要额外代码
|
|
4
|
+
- onClick 返回的如果不是一个promise时,需要业务自己调用 hideLoading
|
|
5
|
+
具体用法见下面代码演示部分。
|
|
6
|
+
|
|
7
|
+
### 代码演示
|
|
8
|
+
```jsx
|
|
9
|
+
import { Fragment, useState } from 'react';
|
|
10
|
+
import ReactDOM from 'react-dom';
|
|
11
|
+
import { createGlobalStyle } from 'styled-components';
|
|
12
|
+
import { LoadingButton } from 'tntd';
|
|
13
|
+
import 'antd/dist/antd.css';
|
|
14
|
+
|
|
15
|
+
const GlobalStyle = createGlobalStyle`
|
|
16
|
+
.site-body {
|
|
17
|
+
.ichYgh {
|
|
18
|
+
padding: 0;
|
|
19
|
+
overflow: visible;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
ReactDOM.render(
|
|
25
|
+
<Fragment>
|
|
26
|
+
<LoadingButton
|
|
27
|
+
type="primary"
|
|
28
|
+
onClick={() => {
|
|
29
|
+
console.log('onClick resolve...');
|
|
30
|
+
return new Promise(resolve => {
|
|
31
|
+
setTimeout(resolve, 2000);
|
|
32
|
+
});
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
resolve
|
|
36
|
+
</LoadingButton>
|
|
37
|
+
<LoadingButton
|
|
38
|
+
type="primary"
|
|
39
|
+
onClick={() => {
|
|
40
|
+
console.log('onClick reject...');
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
setTimeout(reject, 2000);
|
|
43
|
+
});
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
reject
|
|
47
|
+
</LoadingButton>
|
|
48
|
+
<LoadingButton
|
|
49
|
+
type="primary"
|
|
50
|
+
loadingText="提交中..."
|
|
51
|
+
onClick={(evt, hideLoading) => {
|
|
52
|
+
console.log('onClick 2...');
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
// do your logic here
|
|
55
|
+
hideLoading();
|
|
56
|
+
}, 2000);
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
回调方式
|
|
60
|
+
</LoadingButton>
|
|
61
|
+
<GlobalStyle />
|
|
62
|
+
</Fragment>,
|
|
63
|
+
document.getElementById('root')
|
|
64
|
+
);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### API
|
|
69
|
+
#### LoadingButton
|
|
70
|
+
同antd Button
|
|
71
|
+
|
|
72
|
+
| 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
|
|
73
|
+
| :---------- | :------------------------------ | :------- | :---------- | :------- |
|
|
74
|
+
| loadingText | 按钮加载状态显示的文字 | string | 按钮文字 | 否 |
|
|
75
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "antd/lib/button/style";
|
|
2
|
+
import _Button from "antd/lib/button";
|
|
3
|
+
|
|
4
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
|
+
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
7
|
+
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
|
|
14
|
+
import { useState, useEffect } from 'react';
|
|
15
|
+
export default (function (props) {
|
|
16
|
+
var _useState = useState(props.loading),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
loading = _useState2[0],
|
|
19
|
+
setLoading = _useState2[1];
|
|
20
|
+
|
|
21
|
+
var onClick = function onClick(evt) {
|
|
22
|
+
if (!loading) {
|
|
23
|
+
setLoading(true);
|
|
24
|
+
var returnVal = props.onClick && props.onClick(evt, function () {
|
|
25
|
+
return setLoading(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (returnVal instanceof Promise) {
|
|
29
|
+
returnVal.then(function () {
|
|
30
|
+
return setLoading(false);
|
|
31
|
+
})["catch"](function () {
|
|
32
|
+
return setLoading(false);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
setLoading(props.loading);
|
|
40
|
+
}, [props.loading]);
|
|
41
|
+
return React.createElement(_Button, _extends({}, props, {
|
|
42
|
+
loading: loading,
|
|
43
|
+
onClick: onClick
|
|
44
|
+
}), loading ? props.loadingText || props.children : props.children);
|
|
45
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
## Modal全屏浮层组件
|
|
2
|
+
### 代码演示
|
|
3
|
+
```jsx
|
|
4
|
+
import { Fragment, useState } from 'react';
|
|
5
|
+
import ReactDOM from 'react-dom';
|
|
6
|
+
import { createGlobalStyle } from 'styled-components';
|
|
7
|
+
import { Button } from 'antd';
|
|
8
|
+
import { Modal as TntModal } from 'tntd';
|
|
9
|
+
import 'antd/dist/antd.css';
|
|
10
|
+
|
|
11
|
+
const GlobalStyle = createGlobalStyle`
|
|
12
|
+
.site-body {
|
|
13
|
+
.ichYgh {
|
|
14
|
+
padding: 0;
|
|
15
|
+
overflow: visible;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
const FullscreenModalDemo = props => {
|
|
21
|
+
const [visible, setVisible] = useState(false);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Fragment>
|
|
25
|
+
<Button type="primary" onClick={() => setVisible(true)}>带全屏Modal</Button>
|
|
26
|
+
<TntModal
|
|
27
|
+
visible={visible}
|
|
28
|
+
title="司南"
|
|
29
|
+
fullscreen
|
|
30
|
+
logo="https://sinan.tongdun.me/cdn/bucket/20191127134944493_favicon.png"
|
|
31
|
+
onCancel={() => setVisible(false)}
|
|
32
|
+
onToggleFullscreen={isFullscreen => {
|
|
33
|
+
console.log(`isFullscreen: ${isFullscreen}`);
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<iframe src="https://sinan.tongdun.me/project/45?versionId=5" />
|
|
37
|
+
</TntModal>
|
|
38
|
+
<GlobalStyle />
|
|
39
|
+
</Fragment>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
ReactDOM.render(
|
|
45
|
+
<FullscreenModalDemo />,
|
|
46
|
+
document.getElementById('root')
|
|
47
|
+
);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### API
|
|
52
|
+
#### TntModal
|
|
53
|
+
同antd Modal
|
|
54
|
+
|
|
55
|
+
| 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
|
|
56
|
+
| :---------- | :------------------------------ | :------- | :---------- | :------- |
|
|
57
|
+
| logo | logo 地址 | string | 无 | 是 |
|
|
58
|
+
| supportFullscreen | 是否支持全屏 | boolean | true | 否 |
|
|
59
|
+
| onToggleFullscreen | 全屏切换事件 | Function | null | 否 |
|