index.js
2.35 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
87
88
89
90
91
92
import React, {PropTypes} from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Affix, Row, Col, Icon} from 'antd';
import NavPath from '../../components/NavPath';
import Header from '../../components/Header';
import Sidebar from '../../components/Sidebar';
import Footer from '../../components/Footer';
import { fetchProfile, logout } from '../../store/modules/user/user_action';
// import 'antd/dist/antd.less';
import styles from './index.less';
class App extends React.Component {
constructor(props) {
super(props);
}
/**
* 判断登入权限
*/
componentWillMount() {
const {actions} = this.props;
actions.fetchProfile();
}
/**
* 监听porps
*
* 1、监听注销字段,刷新页面
*
* @param {any} nextProps
*/
componentWillReceiveProps(nextProps) {
const loggingOut = nextProps.loggingOut;
if (loggingOut) {
window.location.href = '/';
}
}
render() {
const {user, actions} = this.props;
const { collapse } = this.props; // 判断侧边栏隐藏显示
return (
// <div className={collapse ? styles["ant-layout-aside"] + ' ' + styles["ant-layout-aside-collapse"] : styles["ant-layout-aside"]}>
// <Sidebar />
// <div className={styles["ant-layout-main"]}>
// <Header user={user} />
// <NavPath />
// <div className={styles["ant-layout-container"]}>
// <div className={styles["ant-layout-content"]}>
// {this.props.children}
// </div>
// </div>
// <Footer />
// </div>
// </div>
<div className={styles["ant-layout-container"]}>
<div className={styles["ant-layout-content"]}>
{this.props.children}
</div>
</div>
);
}
}
App.propTypes = {
user: PropTypes.object,
children: PropTypes.node.isRequired
};
App.contextTypes = {
history: PropTypes.object.isRequired,
store: PropTypes.object.isRequired
};
const mapStateToProps = (state) => {
const {user} = state;
return {
user: user ? user : null,
loggingOut: user.loggingOut,
// collapse: state.menu.collapse
};
};
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({ fetchProfile, logout }, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(App);