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, message, Tooltip } from 'antd' import { checkLoginState, logoutActions, loginTypeAction} from '../../reducer/modules/login' import { changeMenuItem } from '../../reducer/modules/menu' import { withRouter } from 'react-router'; import Srch from './Search/Search' const { Header } = Layout; const headerStyle = { 'height': '.56rem', 'lineHeight': '.56rem', 'padding': 0 }; 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 }; @connect( (state) => { return{ avatar: state.login.avatar, user: state.login.userName, uid: state.login.uid, msg: null, login:state.login.isLogin } }, { loginTypeAction, logoutActions, checkLoginState, changeMenuItem } ) @withRouter export default 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, relieveLink:PropTypes.func, logoutActions:PropTypes.func, checkLoginState:PropTypes.func, loginTypeAction:PropTypes.func, changeMenuItem:PropTypes.func, history: PropTypes.object, location: PropTypes.object } linkTo = (e) =>{ if(e.key != '/doc'){ this.props.changeMenuItem(e.key); if(!this.props.login){ message.info('请先登录',1); } } } relieveLink = () => { this.props.changeMenuItem(""); } logout = (e) => { e.preventDefault(); this.props.logoutActions().then((res) => { if (res.payload.data.errcode == 0) { this.props.history.push('/'); this.props.changeMenuItem("/"); message.success('退出成功! '); } else { message.error(res.payload.data.errmsg); } }).catch((err) => { message.error(err); }); } 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 } = this.props; return (
YAPI
{login? :""}
) } }