1 | import React from 'react';
|
2 | import { Layout, Menu, Icon } from 'antd';
|
3 |
|
4 | const { SubMenu } = Menu;
|
5 | const { Sider } = Layout;
|
6 |
|
7 | import PubSub from 'pubsub-js';
|
8 |
|
9 |
|
10 | export default class SiderView extends React.Component {
|
11 |
|
12 | constructor(props) {
|
13 | super(props);
|
14 | }
|
15 |
|
16 |
|
17 | $renderItem(db) {
|
18 |
|
19 | const{md, config} = db;
|
20 |
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | }
|
38 |
|
39 | componentDidMount() {
|
40 |
|
41 | const{md, config} =this.props.db;
|
42 | const cg = config.category[0];
|
43 |
|
44 | console.log(config);
|
45 |
|
46 |
|
47 |
|
48 | if(cg) PubSub.publish('SET_PAGE', md[cg][0].page);
|
49 | setTimeout(()=> {
|
50 |
|
51 |
|
52 | }, 10)
|
53 | }
|
54 |
|
55 | handleMenuClick({item, key, keyPath}) {
|
56 | console.log(item, key);
|
57 |
|
58 | PubSub.publish('SET_PAGE', key);
|
59 |
|
60 | }
|
61 |
|
62 | render() {
|
63 |
|
64 | const menuItems = this.$renderItem(this.props.db);
|
65 | const{md, config} =this.props.db;
|
66 |
|
67 | return (
|
68 | <Menu
|
69 | mode="inline"
|
70 | defaultSelectedKeys={['0']}
|
71 | defaultOpenKeys={config.category}
|
72 | style={{ height: '100%' }}
|
73 | onClick={this.handleMenuClick.bind(this)}
|
74 | >
|
75 | {menuItems}
|
76 |
|
77 |
|
78 | </Menu>
|
79 | )
|
80 | }
|
81 | } |
\ | No newline at end of file |