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, Dropdown } from 'antd' import { checkLoginState, logoutActions, loginTypeAction} from '../../actions/login' import { changeMenuItem } from '../../actions/menu' import { withRouter } from 'react-router'; import Srch from './Search/Search' const { Header } = Layout; const MenuUser = (props) => (
); MenuUser.propTypes={ user:PropTypes.string, msg:PropTypes.string, uid: PropTypes.number, relieveLink:PropTypes.func, logout:PropTypes.func } const ToolUser = (props)=> ( ); ToolUser.propTypes={ user:PropTypes.string, msg:PropTypes.string, uid: PropTypes.number, relieveLink:PropTypes.func, logout:PropTypes.func, groupList: PropTypes.array }; @withRouter class HeaderCom extends Component { constructor(props) { super(props); } static propTypes ={ router: PropTypes.object, user: PropTypes.string, msg: PropTypes.string, uid: PropTypes.number, login:PropTypes.bool, curKey:PropTypes.string, relieveLink:PropTypes.func, logoutActions:PropTypes.func, checkLoginState:PropTypes.func, loginTypeAction:PropTypes.func, changeMenuItem:PropTypes.func, history: PropTypes.object, location: PropTypes.object } linkTo = (e) =>{ this.props.changeMenuItem(e.key); // this.props.curKey = e.key; // this.setState({ // current : e.key // }) } relieveLink = () => { this.props.changeMenuItem(""); // this.setState({ // current : "" // }) } logout = (e) => { e.preventDefault(); this.props.logoutActions(); this.props.history.push('/'); this.props.changeMenuItem("/"); // this.setState({ // current : "/" // }) } 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 () { const { login, user, msg, uid, curKey } = this.props; return (