-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeader.tsx
58 lines (54 loc) · 1.56 KB
/
Header.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
import React from "react";
import {Layout, Menu} from 'antd';
import {Link} from "react-router-dom";
import menus, {MenuModel} from "@/menu";
function recursiveMenu(menus: MenuModel[], parentKey?: string) {
return menus.map((t: MenuModel, i: number) => {
let key = parentKey ? `${parentKey}-${i}` : `${i}`
if (t.children) {
return (
<Menu.SubMenu
key={key}
title={
<span>
{t.icon}
<span>{t.name}</span>
</span>
}
>
{recursiveMenu(t.children, key)}
</Menu.SubMenu>
)
}
return (
<Menu.Item key={key}>
{t.icon}
<span>{t.name}</span>
{t.path && <Link to={t.path} target={t.redirect ? "_blank" : ""}/>}
</Menu.Item>
)
})
}
const Header: React.FC = () => {
return (
<Layout.Header
style={{
position: 'sticky',
top: 0,
zIndex: 1,
width: '100%',
display: 'flex',
alignItems: 'center',
background: "#ffffff",
}}
>
<Menu theme={"light"} mode="horizontal"
style={{
flex: 1, minWidth: 0,
}}>
{recursiveMenu(menus)}
</Menu>
</Layout.Header>
)
}
export default Header