UNPKG

1.8 kBJavaScriptView Raw
1import React from 'react';
2import { Layout, Menu, Icon } from 'antd';
3import {
4 BrowserRouter as Router,
5 Route,
6 HashRouter,
7 Link
8} from 'react-router-dom';
9
10const { SubMenu } = Menu;
11const { Sider } = Layout;
12
13export default class SiderView extends React.Component {
14
15 constructor(props) {
16 super(props);
17 }
18
19 $renderItem(db) {
20
21 const{md, config} = db;
22
23 const res = [];
24
25 const category = config.category.slice();
26
27 const to = `page + ${item.page}`;
28
29 category.forEach((cg, i) => {
30 const list = md[cg];
31 const items = list.map((item, i) => {
32 return(
33 <Menu.Item key={item.page}>
34 <Link to={"page/" + item.page}>
35 {item.page}
36 </Link>
37 </Menu.Item>
38 )
39 });
40
41 res.push((
42 <SubMenu key={cg + '-key'} title={cg}>
43 {items}
44 </SubMenu>
45 ));
46 });
47 return res;
48 }
49
50 componentDidMount() {
51 // const{md, config} =this.props.db;
52 // const cg = config.category[0];
53 // if(cg) PubSub.publish('SET_PAGE', md[cg][0].page);
54 }
55
56 render() {
57 const menuItems = this.$renderItem(this.props.db);
58 const{md, config} =this.props.db;
59
60 const defaultKeys = config.category.map(item => {
61 return item + '-key';
62 })
63
64 return (
65 <Menu
66 mode="inline"
67 defaultSelectedKeys={['0']}
68 defaultOpenKeys={defaultKeys}
69 style={{ height: '100%' }}
70 >
71 {menuItems}
72
73 </Menu>
74 )
75 }
76}
\No newline at end of file