This repository has been archived by the owner on Aug 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 238
/
BasicLayout.tsx
94 lines (89 loc) 路 2.48 KB
/
BasicLayout.tsx
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Ant Design Pro v4 use `@ant-design/pro-layout` to handle Layout.
* You can view component api by:
* https://github.com/ant-design/ant-design-pro-layout
*/
import ProLayout, {
MenuDataItem,
BasicLayoutProps as ProLayoutProps,
Settings,
SettingDrawer,
PageHeaderWrapper,
} from '../../../src/';
import React, { useState } from 'react';
import { Icon } from 'antd';
import Link from 'umi/link';
import history from 'umi/router';
import RightContent from '@/components/GlobalHeader/RightContent';
import logo from '../assets/logo.svg';
export interface BasicLayoutProps extends ProLayoutProps {
breadcrumbNameMap: {
[path: string]: MenuDataItem;
};
}
export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & {
breadcrumbNameMap: {
[path: string]: MenuDataItem;
};
};
const BasicLayout: React.FC<BasicLayoutProps> = props => {
const [collapsed, handleMenuCollapse] = useState<boolean>(true);
const [settings, setSettings] = useState<Partial<Settings>>({
fixSiderbar: true,
fixedHeader: true,
navTheme: 'light',
});
return (
<>
<ProLayout
layout="topmenu"
className="chenshuai2144"
disableMobile
fixSiderbar
rightContentRender={rightProps => (
<RightContent {...rightProps} {...settings} />
)}
disableContentMargin
{...props}
>
<ProLayout
menuHeaderRender={false}
logo={logo}
siderWidth={200}
collapsed={collapsed}
links={[
<span>
<Icon type="smile" />
name
</span>,
]}
onCollapse={handleMenuCollapse}
menuItemRender={(menuItemProps, defaultDom) =>
menuItemProps.isUrl ? (
defaultDom
) : (
<Link className="qixian-menuItem" to={menuItemProps.path}>
{defaultDom}
</Link>
)
}
subMenuItemRender={(_, defaultDom) => (
<a className="qixian-subMenuItem">{defaultDom}</a>
)}
onMenuHeaderClick={() => history.push('/')}
{...props}
{...settings}
>
<PageHeaderWrapper content="娆㈣繋鎮ㄧ殑浣跨敤">
{props.children}
</PageHeaderWrapper>
</ProLayout>
<SettingDrawer
settings={settings}
onSettingChange={config => setSettings(config)}
/>
</ProLayout>
</>
);
};
export default BasicLayout;