index.tsx
2.1 KB
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
import React, { memo, useState } from 'react'
import {
SnippetsOutlined,
AppstoreOutlined,
ContainerOutlined,
DesktopOutlined,
MailOutlined,
MenuFoldOutlined,
MenuUnfoldOutlined,
PieChartOutlined
} from '@ant-design/icons'
import type { FC, ReactNode } from 'react'
import { useNavigate } from 'react-router-dom'
import type { MenuProps } from 'antd'
import { Button, Menu } from 'antd'
import { AppMenyWrapper } from './styled'
type MenuItem = Required<MenuProps>['items'][number]
interface IProps {
children?: ReactNode
}
function getItem(label: React.ReactNode, key: React.Key, icon?: React.ReactNode, children?: MenuItem[], type?: 'group'): MenuItem {
return {
key,
icon,
children,
label,
type
} as MenuItem
}
const items: MenuItem[] = [
getItem('我的订单', '1', <SnippetsOutlined />),
getItem('暂不开放', '2', <DesktopOutlined />)
// getItem('Option 3', '3', <ContainerOutlined />),
// getItem('Navigation One', 'sub1', <MailOutlined />, [getItem('Option 5', '5'), getItem('Option 6', '6'), getItem('Option 7', '7'), getItem('Option 8', '8')]),
// getItem('Navigation Two', 'sub2', <AppstoreOutlined />, [
// getItem('Option 9', '9'),
// getItem('Option 10', '10'),
// getItem('Submenu', 'sub3', null, [getItem('Option 11', '11'), getItem('Option 12', '12')])
// ])
]
type ObjectString = {
[key: string]: string
}
const navigateUrl: ObjectString = {
'1': '/discover/ConsultationOrder',
'2': '/discover/xx'
}
const AppMenu: FC<IProps> = memo(() => {
const navigate = useNavigate()
const [collapsed, setCollapsed] = useState(false)
const toggleCollapsed = () => {
setCollapsed(!collapsed)
}
const onselectHandler = (e: any) => {
console.log(e, 'eee')
navigate(navigateUrl[e.key])
}
return (
<AppMenyWrapper style={{ width: 256 }}>
<Menu
defaultSelectedKeys={['1']}
defaultOpenKeys={['sub1']}
mode="inline"
theme="dark"
inlineCollapsed={collapsed}
items={items}
onSelect={(e) => onselectHandler(e)}
/>
</AppMenyWrapper>
)
})
export default AppMenu