forked from huge/frontEnd/hugeDyh2.0

ldh
2022-02-17 904c44b4a2283f74e56814db0cc2e511f7a6674f
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-02-14 14:22:07
 * @LastEditTime: 2022-02-17 15:12:00
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description: 导航菜单
 */
import React from 'react';
import { useLocation, Outlet, Link } from 'react-router-dom';
import { Menu, Badge, Avatar, Dropdown } from 'antd';
import {
    TeamOutlined,
    ShoppingCartOutlined,
    SafetyCertificateOutlined,
    DeploymentUnitOutlined,
    QuestionCircleOutlined,
    BellOutlined,
    UserOutlined,
    LogoutOutlined,
} from '@ant-design/icons';
import './index.less';
 
// 头部导航菜单
const headerMenu = [
    {
        key: 'operation',
        title: '运营中心',
    },
];
 
const userMenu = (
    <Menu>
        <Menu.Item key="loginOut">
            <Link to="/login">
                <LogoutOutlined style={{ marginRight: '8px' }} />
                退出登录
            </Link>
        </Menu.Item>
    </Menu>
);
 
function urlString(str) {
    let arr = str.split('/');
    return arr[arr.length - 1];
}
 
const Navigation = () => {
    const location = useLocation() || {};
 
    let menuKey = urlString(location.pathname);
 
    return (
        <div className="layout">
            <div className="layout-header">
                <div className="layout-header-logo">logo</div>
                <div className="layout-header-menu">
                    {headerMenu.map((x, t) => {
                        return (
                            <div className={`layout-header-menu-item ${location.pathname?.indexOf(x.key) != -1 ? 'layout-header-menu-active' : ''}`} key={x.key}>
                                {x.title}
                            </div>
                        );
                    })}
                </div>
                <div className="layout-header-user">
                    <div className="layout-header-user-item">
                        <QuestionCircleOutlined />
                    </div>
                    <div className="layout-header-user-item">
                        <Badge>
                            <BellOutlined />
                        </Badge>
                    </div>
                    <Dropdown overlay={userMenu}>
                        <div className="layout-header-user-avatar">
                            <Avatar style={{ backgroundColor: '#1089ff' }} icon={<UserOutlined />} />
                            <div>
                                <div className="layout-header-user-name">xxxx</div>
                                <div className="layout-header-user-unit">某某某单位</div>
                            </div>
                        </div>
                    </Dropdown>
                </div>
            </div>
            <div className="layout-main">
                <nav className="layout-nva">
                    <Menu style={{ width: '200px' }} mode="inline" selectedKeys={[menuKey]}>
                        <Menu.Item key="customer" icon={<TeamOutlined />}>
                            客户管理
                        </Menu.Item>
                        <Menu.Item key="edition" icon={<ShoppingCartOutlined />}>
                            版本管理
                        </Menu.Item>
                        <Menu.Item key="power" icon={<SafetyCertificateOutlined />}>
                            功能管理
                        </Menu.Item>
                        <Menu.Item key="equipment" icon={<DeploymentUnitOutlined />}>
                            设备管理
                        </Menu.Item>
                    </Menu>
                </nav>
                <main className="layout-child">
                    <Outlet />
                </main>
            </div>
        </div>
    );
};
 
export default Navigation;