import './Header.scss' import React, { Component } from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import { Link } from 'react-router-dom' import { Icon, Layout, Menu} from 'antd' import { checkLoginState, logoutActions, loginTypeAction} from '../../actions/login' import { withRouter } from 'react-router'; const { Header } = Layout; const ToolUser = (props)=> ( ); ToolUser.propTypes={ user:PropTypes.string, msg:PropTypes.string, relieveLink:PropTypes.func, logout:PropTypes.func }; @withRouter class HeaderCom extends Component { constructor(props) { super(props); this.state = { current : window.location.hash.split("#")[1] } } static propTypes ={ router: PropTypes.object, user: PropTypes.string, msg: PropTypes.string, login:PropTypes.bool, relieveLink:PropTypes.func, logoutActions:PropTypes.func, checkLoginState:PropTypes.func, loginTypeAction:PropTypes.func, history: PropTypes.object, location: PropTypes.object } componentDidMount() { const { router } = this.props; console.log(router); } linkTo = (e) =>{ this.setState({ current : e.key }) } relieveLink = () => { this.setState({ current : "" }) } logout = (e) => { e.preventDefault(); this.props.logoutActions(); } handleLogin = (e) => { e.preventDefault(); this.props.loginTypeAction("1"); } handleReg = (e)=>{ e.preventDefault(); this.props.loginTypeAction("2"); } checkLoginState = () => { this.props.checkLoginState().then((res) => { if (res.payload.data.errcode !== 0) { this.props.history.push('/'); } }).catch((err) => { console.log(err); }) } render () { this.checkLoginState(); const { login, user, msg } = this.props; return (
YAPI
首页 分组 接口 文档
{login?:""}
) } } export default connect( (state) => { return{ user: state.login.userName, msg: null, login:state.login.isLogin } }, { loginTypeAction, logoutActions, checkLoginState } )(HeaderCom)