|
1 | 1 | import * as React from 'react'
|
2 |
| -import { NavLink, Link, withRouter, RouteComponentProps } from 'react-router-dom' |
3 |
| -import { Layout, Menu, Icon } from 'antd' |
| 2 | +import { Link, withRouter } from 'react-router-dom' |
| 3 | +import { Layout, Menu } from 'antd' |
| 4 | +import { |
| 5 | + HomeOutlined, AreaChartOutlined, MehOutlined, FrownOutlined, FormOutlined, UserOutlined, |
| 6 | + BookOutlined, SmileOutlined, StockOutlined, BulbOutlined, DollarOutlined, FundOutlined, BarChartOutlined, ExperimentOutlined, FileSearchOutlined |
| 7 | +} from '@ant-design/icons' |
| 8 | +import { LeftMenuConfig } from '../../../routes/pageRoutes' |
4 | 9 |
|
5 | 10 | const { Sider } = Layout
|
6 | 11 | const {Item, SubMenu} = Menu
|
7 | 12 |
|
8 |
| -interface ISiderProps extends RouteComponentProps { |
| 13 | +interface ISiderProps extends ICommonProps { |
9 | 14 | collapsed?: boolean
|
10 | 15 | }
|
11 | 16 |
|
12 | 17 | const MenuList = [
|
13 | 18 | {
|
14 |
| - key: '1', title: 'Home', path: '/home', icon: 'home' |
| 19 | + key: '1', title: 'Home', path: '/home', icon: <HomeOutlined/> |
15 | 20 | },
|
16 | 21 | {
|
17 |
| - key: '2', title: 'Charts', path: '/home/charts', icon: 'area-chart' |
| 22 | + key: '2', title: 'Charts', path: '/home/charts', icon: <AreaChartOutlined/> |
18 | 23 | },
|
19 | 24 | {
|
20 |
| - key: '3', title: 'Log', icon: 'file-search', |
| 25 | + key: '3', title: 'Log', icon: <FileSearchOutlined/>, |
21 | 26 | children: [
|
22 |
| - { key: '3-0', title: 'API', path: '/home/log-api', icon: 'meh' }, |
23 |
| - { key: '3-1', title: 'Errors', path: '/home/log-errors', icon: 'frown' } |
| 27 | + { key: '3-0', title: 'API', path: '/home/log-api', icon: <MehOutlined/> }, |
| 28 | + { key: '3-1', title: 'Errors', path: '/home/log-errors', icon: <FrownOutlined/> } |
24 | 29 | ]
|
25 | 30 | },
|
26 | 31 | {
|
27 |
| - key: '4', title: 'Essay', icon: 'book', |
| 32 | + key: '4', title: 'Essay', icon: <BookOutlined/>, |
28 | 33 | children: [
|
29 |
| - { key: '4-0', title: '文章', path: '/home/blog-article', icon: 'form' }, |
30 |
| - { key: '4-1', title: '文章类型', path: '/home/blog-type', icon: 'form' }, |
31 |
| - { key: '4-2', title: '标签', path: '/home/blog-tag', icon: 'form' }, |
32 |
| - { key: '4-3', title: '评论', path: '/home/blog-comment', icon: 'form' }, |
33 |
| - { key: '4-4', title: '留言', path: '/home/blog-message', icon: 'form' }, |
34 |
| - { key: '4-5', title: '用户', path: '/home/blog-user', icon: 'user' } |
| 34 | + { key: '4-0', title: '文章', path: '/home/blog-article', icon: <FormOutlined/> }, |
| 35 | + { key: '4-1', title: '文章类型', path: '/home/blog-type', icon: <FormOutlined/> }, |
| 36 | + { key: '4-2', title: '标签', path: '/home/blog-tag', icon: <FormOutlined/> }, |
| 37 | + { key: '4-3', title: '评论', path: '/home/blog-comment', icon: <FormOutlined/> }, |
| 38 | + { key: '4-4', title: '留言', path: '/home/blog-message', icon: <FormOutlined/> }, |
| 39 | + { key: '4-5', title: '用户', path: '/home/blog-user', icon: <UserOutlined/> } |
35 | 40 | ]
|
36 | 41 | },
|
37 | 42 | {
|
38 |
| - key: '5', title: 'Lottery', icon: 'smile', |
| 43 | + key: '5', title: 'Lottery', icon: <SmileOutlined/>, |
39 | 44 | children: [
|
40 |
| - { y: '5-0', title: '双色球', path: '/home/lottery-balls', icon: 'dollar' }, |
41 |
| - { key: '5-1', title: '趋势图', path: '/home/lottery-trend', icon: 'fund' }, |
42 |
| - { key: '5-2', title: '统计图', path: '/home/lottery-chart', icon: 'bar-chart' } |
| 45 | + { y: '5-0', title: '双色球', path: '/home/lottery-balls', icon: <DollarOutlined/> }, |
| 46 | + { key: '5-1', title: '趋势图', path: '/home/lottery-trend', icon: <FundOutlined/> }, |
| 47 | + { key: '5-2', title: '统计图', path: '/home/lottery-chart', icon: <BarChartOutlined/> } |
43 | 48 | ]
|
44 | 49 | },
|
45 | 50 | {
|
46 |
| - key: '6', title: 'Stocks', icon: 'stock', |
| 51 | + key: '6', title: 'Stocks', icon: <StockOutlined/>, |
47 | 52 | children: [
|
48 |
| - { key: '6-0', title: 'Stock', path: '/home/stocks', icon: 'dollar' }, |
49 |
| - { key: '6-1', title: 'Stock History', path: '/home/stocks-history', icon: 'fund' } |
| 53 | + { key: '6-0', title: 'Stock', path: '/home/stocks', icon: <DollarOutlined/> }, |
| 54 | + { key: '6-1', title: 'Stock History', path: '/home/stocks-history', icon: <FundOutlined/> } |
50 | 55 | ]
|
51 | 56 | },
|
52 | 57 | {
|
53 |
| - key: '99', title: 'Demo', icon: 'bulb', |
| 58 | + key: '99', title: 'Demo', icon: <BulbOutlined/>, |
54 | 59 | children: [
|
55 |
| - { key: '99-0', title: '示例', path: '/home/demos', icon: 'experiment' }, |
56 |
| - { key: '99-1', title: '示例mobx', path: '/home/demo-mobx', icon: 'experiment' }, |
57 |
| - { key: '99-2', title: '示例redux', path: '/home/demo-redux', icon: 'experiment' } |
| 60 | + { key: '99-0', title: '示例', path: '/home/demos', icon: <ExperimentOutlined/> }, |
| 61 | + { key: '99-1', title: '示例mobx', path: '/home/demo-mobx', icon: <ExperimentOutlined/> }, |
| 62 | + { key: '99-2', title: '示例redux', path: '/home/demo-redux', icon: <ExperimentOutlined/> } |
58 | 63 | ]
|
59 | 64 | }
|
60 | 65 | ]
|
@@ -99,21 +104,20 @@ class SiderComponent extends React.Component<ISiderProps> {
|
99 | 104 | return m.children ?
|
100 | 105 | <SubMenu
|
101 | 106 | key={m.key}
|
102 |
| - title={<span><Icon type={m.icon} /><span>{m.title}</span></span>}> |
| 107 | + icon={m.icon} |
| 108 | + title={<span>{m.title}</span>}> |
103 | 109 | {
|
104 | 110 | m.children.map(mc => {
|
105 |
| - return <Item key={mc.key}> |
| 111 | + return <Item key={mc.key} icon={m.icon}> |
106 | 112 | <Link to={mc.path}>
|
107 |
| - <Icon type={mc.icon} /> |
108 | 113 | <span>{mc.title}</span>
|
109 | 114 | </Link>
|
110 | 115 | </Item>
|
111 | 116 | })
|
112 | 117 | }
|
113 | 118 | </SubMenu> :
|
114 |
| - <Item key={m.key}> |
| 119 | + <Item key={m.key} icon={m.icon}> |
115 | 120 | <Link to={m.path}>
|
116 |
| - <Icon type={m.icon} /> |
117 | 121 | <span>{m.title}</span>
|
118 | 122 | </Link>
|
119 | 123 | </Item>
|
|
0 commit comments