@arcblock/ux 2.1.13 → 2.1.16
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/lib/Header/header.js +4 -3
- package/lib/Header/responsive-header.js +1 -1
- package/lib/Layout/dashboard/index.js +121 -100
- package/lib/Layout/dashboard/sidebar.js +23 -64
- package/lib/Layout/{dashboard → dashboard-legacy}/header.js +1 -1
- package/lib/Layout/dashboard-legacy/index.js +154 -0
- package/lib/Layout/dashboard-legacy/sidebar.js +117 -0
- package/lib/NavMenu/nav-menu.js +1 -3
- package/lib/Wallet/Open.js +1 -1
- package/lib/WechatPrompt/index.js +2 -2
- package/package.json +4 -4
- package/src/Header/header.js +12 -4
- package/src/Header/responsive-header.js +1 -1
- package/src/Layout/dashboard/index.js +117 -116
- package/src/Layout/dashboard/sidebar.js +69 -84
- package/src/Layout/{dashboard → dashboard-legacy}/header.js +0 -0
- package/src/Layout/dashboard-legacy/index.js +150 -0
- package/src/Layout/dashboard-legacy/sidebar.js +120 -0
- package/src/NavMenu/nav-menu.js +1 -3
- package/src/Wallet/Open.js +1 -1
- package/src/WechatPrompt/index.js +2 -2
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _withTheme = _interopRequireDefault(require("@mui/styles/withTheme"));
|
|
15
|
+
|
|
16
|
+
var _reactRouterDom = require("react-router-dom");
|
|
17
|
+
|
|
18
|
+
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
19
|
+
|
|
20
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
21
|
+
|
|
22
|
+
var _colors = require("@mui/material/colors");
|
|
23
|
+
|
|
24
|
+
var _image = _interopRequireDefault(require("../../Icon/image"));
|
|
25
|
+
|
|
26
|
+
var _Logo = _interopRequireDefault(require("../../Logo"));
|
|
27
|
+
|
|
28
|
+
const _excluded = ["location", "theme", "images", "links", "prefix", "addons", "logo"];
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
function Sidebar(_ref) {
|
|
37
|
+
let {
|
|
38
|
+
location,
|
|
39
|
+
theme,
|
|
40
|
+
images,
|
|
41
|
+
links,
|
|
42
|
+
prefix,
|
|
43
|
+
addons,
|
|
44
|
+
logo
|
|
45
|
+
} = _ref,
|
|
46
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
47
|
+
|
|
48
|
+
const isSelected = (url, name) => {
|
|
49
|
+
const pattern = new RegExp("/".concat(name));
|
|
50
|
+
return pattern.test(location.pathname);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(MenuItems, rest, /*#__PURE__*/_react.default.createElement(_reactRouterDom.Link, {
|
|
54
|
+
to: "/",
|
|
55
|
+
className: "sidebar-logo"
|
|
56
|
+
}, logo || /*#__PURE__*/_react.default.createElement(_Logo.default, {
|
|
57
|
+
showText: false,
|
|
58
|
+
size: 20
|
|
59
|
+
})), links.map(_ref2 => {
|
|
60
|
+
let {
|
|
61
|
+
url,
|
|
62
|
+
name,
|
|
63
|
+
title,
|
|
64
|
+
showBadge
|
|
65
|
+
} = _ref2;
|
|
66
|
+
const selected = isSelected(url, name);
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(MenuItem, {
|
|
68
|
+
component: _reactRouterDom.Link,
|
|
69
|
+
key: url,
|
|
70
|
+
selected: selected,
|
|
71
|
+
to: url
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(_image.default, {
|
|
73
|
+
name: images[name],
|
|
74
|
+
size: 36,
|
|
75
|
+
color: selected ? '#00c2c4' : theme.typography.color.main,
|
|
76
|
+
prefix: prefix,
|
|
77
|
+
showBadge: showBadge
|
|
78
|
+
}), /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
79
|
+
component: "span",
|
|
80
|
+
className: "menu-title"
|
|
81
|
+
}, title));
|
|
82
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
83
|
+
style: {
|
|
84
|
+
flex: 1
|
|
85
|
+
}
|
|
86
|
+
}), addons);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
Sidebar.propTypes = {
|
|
90
|
+
location: _propTypes.default.object.isRequired,
|
|
91
|
+
theme: _propTypes.default.object.isRequired,
|
|
92
|
+
images: _propTypes.default.object.isRequired,
|
|
93
|
+
links: _propTypes.default.array.isRequired,
|
|
94
|
+
prefix: _propTypes.default.string,
|
|
95
|
+
addons: _propTypes.default.any,
|
|
96
|
+
logo: _propTypes.default.any
|
|
97
|
+
};
|
|
98
|
+
Sidebar.defaultProps = {
|
|
99
|
+
prefix: '/images',
|
|
100
|
+
addons: null,
|
|
101
|
+
logo: null
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const MenuItems = /*#__PURE__*/_react.default.memo(_styledComponents.default.div.withConfig({
|
|
105
|
+
displayName: "sidebar__MenuItems",
|
|
106
|
+
componentId: "sc-gtwxx4-0"
|
|
107
|
+
})(["flex:1;display:flex;flex-direction:column;&& .sidebar-logo{display:none;border-bottom:1px solid #eee;background:", ";position:sticky;top:0;z-index:1;padding:10px 0;text-align:center;font-size:0;}", "{&& .sidebar-logo{display:block;}}"], props => props.theme.palette.background.default, props => props.theme.breakpoints.down('md')));
|
|
108
|
+
|
|
109
|
+
const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255, 230, 0))';
|
|
110
|
+
const MenuItem = (0, _styledComponents.default)(_Button.default).withConfig({
|
|
111
|
+
displayName: "sidebar__MenuItem",
|
|
112
|
+
componentId: "sc-gtwxx4-1"
|
|
113
|
+
})(["&&{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;transition:all 200ms ease-in-out;background:", ";padding:24px 0;border-left:2px solid ", ";border-radius:0;&:hover{background:", ";border-left-color:", ";}.menu-title{margin-top:8px;font-size:12px;font-weight:500;text-align:center;text-transform:capitalize;letter-spacing:normal;width:80%;color:", ";}}"], props => props.selected ? gradient : '', props => props.selected ? _colors.teal.A700 : 'transparent', gradient, _colors.teal.A700, props => props.theme.palette.text.primary);
|
|
114
|
+
|
|
115
|
+
var _default = (0, _reactRouterDom.withRouter)((0, _withTheme.default)(Sidebar));
|
|
116
|
+
|
|
117
|
+
exports.default = _default;
|
package/lib/NavMenu/nav-menu.js
CHANGED
|
@@ -189,7 +189,7 @@ function Item(_ref2) {
|
|
|
189
189
|
if (active) {
|
|
190
190
|
activate(id);
|
|
191
191
|
}
|
|
192
|
-
}, []);
|
|
192
|
+
}, [active]);
|
|
193
193
|
|
|
194
194
|
const handleClick = () => {
|
|
195
195
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
@@ -214,8 +214,6 @@ Item.propTypes = {
|
|
|
214
214
|
id: _propTypes.default.string,
|
|
215
215
|
icon: _propTypes.default.element,
|
|
216
216
|
label: _propTypes.default.node,
|
|
217
|
-
// 未显式指定各个 item#id 时, 不方便设置 NavMenu#defaultActiveId, 此时可以给 item 指定 active, 表示 nav menu 默认激活该 item
|
|
218
|
-
// (仅在初始化时有效, 后续更新无效)
|
|
219
217
|
active: _propTypes.default.bool,
|
|
220
218
|
onClick: _propTypes.default.func
|
|
221
219
|
};
|
package/lib/Wallet/Open.js
CHANGED
|
@@ -22,7 +22,7 @@ function OpenInWallet(_ref) {
|
|
|
22
22
|
locale,
|
|
23
23
|
link
|
|
24
24
|
} = _ref;
|
|
25
|
-
const buttonText = locale === 'zh' ? '在
|
|
25
|
+
const buttonText = locale === 'zh' ? '在 DID 钱包打开' : 'Open in DID Wallet';
|
|
26
26
|
const browser = (0, _useBrowser.default)();
|
|
27
27
|
|
|
28
28
|
if (browser.mobile.any && !browser.wallet && !browser.wechat) {
|
|
@@ -42,7 +42,7 @@ function WechatPrompt() {
|
|
|
42
42
|
className: "wechat-tip"
|
|
43
43
|
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
44
44
|
className: "wechat-tip-text"
|
|
45
|
-
}, "2. \u70B9\u51FB\u201C\u5728\u6D4F\u89C8\u5668\u6253\u5F00\u201D\uFF0C\u624D\u80FD\u8C03\u8D77
|
|
45
|
+
}, "2. \u70B9\u51FB\u201C\u5728\u6D4F\u89C8\u5668\u6253\u5F00\u201D\uFF0C\u624D\u80FD\u8C03\u8D77 DID \u94B1\u5305"), /*#__PURE__*/_react.default.createElement("img", {
|
|
46
46
|
className: "wechat-tip-img",
|
|
47
47
|
src: _android.default,
|
|
48
48
|
alt: "Open in Android Browser"
|
|
@@ -58,7 +58,7 @@ function WechatPrompt() {
|
|
|
58
58
|
className: "wechat-tip"
|
|
59
59
|
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
60
60
|
className: "wechat-tip-text"
|
|
61
|
-
}, "2. \u70B9\u51FB\u201C\u5728Safari\u4E2D\u6253\u5F00\u201D\uFF0C\u624D\u80FD\u8C03\u8D77
|
|
61
|
+
}, "2. \u70B9\u51FB\u201C\u5728Safari\u4E2D\u6253\u5F00\u201D\uFF0C\u624D\u80FD\u8C03\u8D77 DID \u94B1\u5305"), /*#__PURE__*/_react.default.createElement("img", {
|
|
62
62
|
className: "wechat-tip-img",
|
|
63
63
|
src: _ios.default,
|
|
64
64
|
alt: "Open in Safari"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.16",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"react": ">=18.1.0",
|
|
53
53
|
"react-ga": "^2.7.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "70976be9540deaa5997240659cd5c1dcee44e54f",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^2.1.
|
|
58
|
-
"@arcblock/react-hooks": "^2.1.
|
|
57
|
+
"@arcblock/icons": "^2.1.16",
|
|
58
|
+
"@arcblock/react-hooks": "^2.1.16",
|
|
59
59
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
60
|
"@emotion/react": "^11.9.0",
|
|
61
61
|
"@emotion/styled": "^11.8.1",
|
package/src/Header/header.js
CHANGED
|
@@ -32,9 +32,10 @@ function Header({ logo, brand, brandAddon, description, children, addons, prepen
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
Header.propTypes = {
|
|
35
|
+
// logo img/svg, 可以包裹一个 a 标签
|
|
35
36
|
logo: PropTypes.node,
|
|
36
|
-
// 相当于 Title
|
|
37
|
-
brand: PropTypes.
|
|
37
|
+
// 相当于 Title, 可以包裹一个 a 标签
|
|
38
|
+
brand: PropTypes.node,
|
|
38
39
|
// brand 右侧的内容区域, 可显示一个 badge 或 tag
|
|
39
40
|
brandAddon: PropTypes.node,
|
|
40
41
|
// brand 下方的描述
|
|
@@ -58,7 +59,7 @@ Header.defaultProps = {
|
|
|
58
59
|
|
|
59
60
|
const Root = styled.div`
|
|
60
61
|
position: relative;
|
|
61
|
-
z-index: ${props => props.$theme.zIndex.
|
|
62
|
+
z-index: ${props => props.$theme.zIndex.appBar};
|
|
62
63
|
font-size: 14px;
|
|
63
64
|
background: ${props => props.$theme.palette.common.white};
|
|
64
65
|
.header-container {
|
|
@@ -68,7 +69,6 @@ const Root = styled.div`
|
|
|
68
69
|
}
|
|
69
70
|
.header-logo {
|
|
70
71
|
display: inline-flex;
|
|
71
|
-
justify-content: center;
|
|
72
72
|
position: relative;
|
|
73
73
|
height: 40px;
|
|
74
74
|
margin-right: 16px;
|
|
@@ -96,10 +96,15 @@ const Root = styled.div`
|
|
|
96
96
|
flex-direction: column;
|
|
97
97
|
flex-shrink: 0;
|
|
98
98
|
margin-right: 16px;
|
|
99
|
+
a {
|
|
100
|
+
color: inherit;
|
|
101
|
+
text-decoration: none;
|
|
102
|
+
}
|
|
99
103
|
.header-brand-title {
|
|
100
104
|
display: flex;
|
|
101
105
|
align-items: center;
|
|
102
106
|
h2 {
|
|
107
|
+
margin: 0;
|
|
103
108
|
font-size: 16px;
|
|
104
109
|
}
|
|
105
110
|
.header-brand-addon {
|
|
@@ -113,6 +118,9 @@ const Root = styled.div`
|
|
|
113
118
|
.header-addons {
|
|
114
119
|
display: flex;
|
|
115
120
|
align-items: center;
|
|
121
|
+
> *:last-child {
|
|
122
|
+
padding-right: 0;
|
|
123
|
+
}
|
|
116
124
|
}
|
|
117
125
|
${props => props.$theme.breakpoints.down('lg')} {
|
|
118
126
|
.header-brand {
|
|
@@ -49,7 +49,7 @@ function ResponsiveHeader({ menu, prepend, children, ...rest }) {
|
|
|
49
49
|
<Drawer
|
|
50
50
|
open={drawerOpen}
|
|
51
51
|
onClose={() => setDrawerOpen(false)}
|
|
52
|
-
ModalProps={{ disablePortal:
|
|
52
|
+
ModalProps={{ disablePortal: false, keepMounted: true }}>
|
|
53
53
|
<Sidebar>
|
|
54
54
|
<div className="header-sidebar-head">
|
|
55
55
|
<div className="header-sidebar-logo">{logo}</div>
|
|
@@ -1,15 +1,89 @@
|
|
|
1
|
-
import React, { useEffect,
|
|
1
|
+
import React, { useEffect, useMemo } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import { withRouter, Link, useLocation, matchPath } from 'react-router-dom';
|
|
3
4
|
import Helmet from 'react-helmet';
|
|
4
5
|
import styled from 'styled-components';
|
|
6
|
+
import useTheme from '@mui/styles/useTheme';
|
|
5
7
|
import Container from '@mui/material/Container';
|
|
8
|
+
import Hidden from '@mui/material/Hidden';
|
|
6
9
|
import Box from '@mui/material/Box';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import Sidebar from './sidebar';
|
|
11
|
-
import Header from './header';
|
|
10
|
+
import DashboardLegacy from '../dashboard-legacy';
|
|
11
|
+
import { ResponsiveHeader } from '../../Header';
|
|
12
|
+
import NavMenu from '../../NavMenu';
|
|
12
13
|
import Footer from '../../Footer';
|
|
14
|
+
import Sidebar from './sidebar';
|
|
15
|
+
|
|
16
|
+
// 监听 location 变化并关闭 header 中的 menu (确保 drawer - disablePortal:false, keepMounted:true)
|
|
17
|
+
// 直接监听 menu 中 link 点击来触发 closeMenu 会有问题 (Suspense & lazy)
|
|
18
|
+
// eslint-disable-next-line react/prop-types
|
|
19
|
+
function NavMenuWrapper({ closeMenu, ...rest }) {
|
|
20
|
+
const location = useLocation();
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
closeMenu();
|
|
23
|
+
}, [location]);
|
|
24
|
+
return <NavMenu {...rest} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function Dashboard({ children, title, headerProps, links, ...rest }) {
|
|
28
|
+
const theme = useTheme();
|
|
29
|
+
const location = useLocation();
|
|
30
|
+
const navItems = useMemo(
|
|
31
|
+
() =>
|
|
32
|
+
links.map(link => ({
|
|
33
|
+
...link,
|
|
34
|
+
label: <Link to={link.url}>{link.title}</Link>,
|
|
35
|
+
active: !!matchPath(location.pathname, { path: link.url, exact: false }),
|
|
36
|
+
})),
|
|
37
|
+
[location, links]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Wrapper {...rest} className={`dashboard ${rest.className}`}>
|
|
42
|
+
<Helmet title={title} key={title} />
|
|
43
|
+
|
|
44
|
+
<StyledUxHeader {...headerProps}>
|
|
45
|
+
{({ isMobile, closeMenu }) => {
|
|
46
|
+
if (isMobile) {
|
|
47
|
+
return (
|
|
48
|
+
<NavMenuWrapper
|
|
49
|
+
mode="inline"
|
|
50
|
+
items={navItems}
|
|
51
|
+
closeMenu={closeMenu}
|
|
52
|
+
bgColor="transparent"
|
|
53
|
+
activeTextColor={theme.palette.primary.main}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}}
|
|
59
|
+
</StyledUxHeader>
|
|
60
|
+
|
|
61
|
+
<Box display="flex" className="dashboard-body">
|
|
62
|
+
<Hidden mdDown>
|
|
63
|
+
<Box className="dashboard-sidebar">
|
|
64
|
+
<Sidebar links={links} />
|
|
65
|
+
</Box>
|
|
66
|
+
</Hidden>
|
|
67
|
+
<Box className="dashboard-main">
|
|
68
|
+
<Container className="dashboard-content">{children}</Container>
|
|
69
|
+
<Footer className="dashboard-footer" />
|
|
70
|
+
</Box>
|
|
71
|
+
</Box>
|
|
72
|
+
</Wrapper>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Dashboard.propTypes = {
|
|
77
|
+
children: PropTypes.any.isRequired,
|
|
78
|
+
title: PropTypes.string,
|
|
79
|
+
links: PropTypes.array.isRequired,
|
|
80
|
+
headerProps: PropTypes.object,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
Dashboard.defaultProps = {
|
|
84
|
+
title: 'Home',
|
|
85
|
+
headerProps: {},
|
|
86
|
+
};
|
|
13
87
|
|
|
14
88
|
const Wrapper = styled.div`
|
|
15
89
|
&.dashboard {
|
|
@@ -17,134 +91,61 @@ const Wrapper = styled.div`
|
|
|
17
91
|
flex-direction: column;
|
|
18
92
|
height: 100vh;
|
|
19
93
|
}
|
|
20
|
-
.
|
|
94
|
+
.dashboard-body {
|
|
21
95
|
overflow: hidden;
|
|
22
96
|
flex: 1;
|
|
23
97
|
}
|
|
24
|
-
.
|
|
98
|
+
.dashboard-sidebar {
|
|
99
|
+
box-sizing: border-box;
|
|
100
|
+
flex: 0 0 auto;
|
|
101
|
+
width: 104px;
|
|
102
|
+
padding: 0 24px;
|
|
103
|
+
&:hover {
|
|
104
|
+
overflow-y: auto;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
.dashboard-main {
|
|
25
108
|
display: flex;
|
|
26
109
|
flex-direction: column;
|
|
27
110
|
overflow: auto;
|
|
28
111
|
flex: 1;
|
|
29
112
|
}
|
|
30
|
-
.
|
|
113
|
+
.dashboard-content {
|
|
31
114
|
flex: 1;
|
|
32
115
|
}
|
|
33
|
-
.
|
|
116
|
+
.dashboard-footer {
|
|
34
117
|
padding-left: 30px;
|
|
35
118
|
}
|
|
119
|
+
`;
|
|
36
120
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
121
|
+
const StyledUxHeader = styled(ResponsiveHeader)`
|
|
122
|
+
.header-container {
|
|
123
|
+
max-width: 100%;
|
|
124
|
+
}
|
|
125
|
+
.header-logo {
|
|
126
|
+
display: flex;
|
|
127
|
+
justify-content: center;
|
|
128
|
+
/* logo 与 sidebar 中的 icon 垂直对齐, 104 - 24 * 2 = 56 */
|
|
129
|
+
width: 56px;
|
|
45
130
|
}
|
|
46
131
|
`;
|
|
47
132
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
headerAddon,
|
|
55
|
-
images,
|
|
56
|
-
links,
|
|
57
|
-
prefix,
|
|
58
|
-
fullWidth,
|
|
59
|
-
contentLayout,
|
|
60
|
-
className,
|
|
61
|
-
homeUrl,
|
|
62
|
-
logo,
|
|
63
|
-
...rest
|
|
64
|
-
}) {
|
|
65
|
-
const breakpoint = 960;
|
|
66
|
-
const { width } = useWindowSize();
|
|
67
|
-
const [drawerMode, setDrawerMode] = useState(width >= breakpoint ? 'permanent' : 'temporary');
|
|
68
|
-
const [drawerOpen, setDrawerOpen] = useState(drawerMode === 'permanent');
|
|
69
|
-
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
const newMode = width >= breakpoint ? 'permanent' : 'temporary';
|
|
72
|
-
setDrawerMode(newMode);
|
|
73
|
-
setDrawerOpen(newMode !== 'temporary');
|
|
74
|
-
}, [width]);
|
|
75
|
-
|
|
76
|
-
const onToggleDrawer = () => {
|
|
77
|
-
setDrawerOpen(!drawerOpen);
|
|
78
|
-
};
|
|
79
|
-
const isFullWidth = fullWidth || contentLayout === 'row';
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<Wrapper className={`dashboard ${className}`} {...rest}>
|
|
83
|
-
<Helmet title={`${title}-${brand}`} />
|
|
84
|
-
|
|
85
|
-
<Header
|
|
86
|
-
className="dashboard__header"
|
|
87
|
-
onToggleMenu={onToggleDrawer}
|
|
88
|
-
brand={brand}
|
|
89
|
-
brandAddon={brandAddon}
|
|
90
|
-
description={description}
|
|
91
|
-
addons={headerAddon}
|
|
92
|
-
homeUrl={homeUrl}
|
|
93
|
-
logo={logo}
|
|
94
|
-
/>
|
|
95
|
-
<Box display="flex" className="dashboard__body">
|
|
96
|
-
<Drawer
|
|
97
|
-
variant={drawerMode}
|
|
98
|
-
className="drawer"
|
|
99
|
-
classes={{ paper: 'drawerPaper' }}
|
|
100
|
-
open={drawerOpen}
|
|
101
|
-
onClose={onToggleDrawer}
|
|
102
|
-
ModalProps={{ disablePortal: true, keepMounted: true }}>
|
|
103
|
-
<Sidebar
|
|
104
|
-
className="dashboard__sidebar"
|
|
105
|
-
images={images}
|
|
106
|
-
links={links}
|
|
107
|
-
prefix={prefix}
|
|
108
|
-
logo={logo}
|
|
109
|
-
/>
|
|
110
|
-
</Drawer>
|
|
111
|
-
<Box className="dashboard__main">
|
|
112
|
-
<Container maxWidth={isFullWidth ? false : 'lg'} className="dashboard__content">
|
|
113
|
-
{children}
|
|
114
|
-
</Container>
|
|
115
|
-
<Footer className="dashboard__footer" />
|
|
116
|
-
</Box>
|
|
117
|
-
</Box>
|
|
118
|
-
</Wrapper>
|
|
119
|
-
);
|
|
133
|
+
// 兼容旧版 dashboard
|
|
134
|
+
function DashboardWrapper({ legacy, ...rest }) {
|
|
135
|
+
if (legacy) {
|
|
136
|
+
return <DashboardLegacy {...rest} />;
|
|
137
|
+
}
|
|
138
|
+
return <Dashboard {...rest} />;
|
|
120
139
|
}
|
|
121
140
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
brand: PropTypes.string.isRequired,
|
|
126
|
-
links: PropTypes.array.isRequired,
|
|
127
|
-
images: PropTypes.object.isRequired,
|
|
128
|
-
brandAddon: PropTypes.object,
|
|
129
|
-
description: PropTypes.any.isRequired,
|
|
130
|
-
headerAddon: PropTypes.any,
|
|
131
|
-
prefix: PropTypes.string,
|
|
132
|
-
// 兼容旧版的设置,新版使用 fullWidth 进行设置
|
|
133
|
-
contentLayout: PropTypes.oneOf(['row', 'column']),
|
|
134
|
-
fullWidth: PropTypes.bool,
|
|
135
|
-
className: PropTypes.string,
|
|
136
|
-
homeUrl: PropTypes.string,
|
|
137
|
-
logo: PropTypes.any,
|
|
141
|
+
DashboardWrapper.propTypes = {
|
|
142
|
+
...Dashboard.propTypes,
|
|
143
|
+
legacy: PropTypes.bool,
|
|
138
144
|
};
|
|
139
145
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
headerAddon: null,
|
|
144
|
-
brandAddon: null,
|
|
145
|
-
prefix: '/images',
|
|
146
|
-
fullWidth: false,
|
|
147
|
-
className: '',
|
|
148
|
-
homeUrl: '/',
|
|
149
|
-
logo: null,
|
|
146
|
+
DashboardWrapper.defaultProps = {
|
|
147
|
+
...Dashboard.defaultProps,
|
|
148
|
+
legacy: true,
|
|
150
149
|
};
|
|
150
|
+
|
|
151
|
+
export default withRouter(DashboardWrapper);
|