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 } from 'antd'
import loginTypeAction from '../../actions/login';
const ToolUser = (props)=> (
- { props.user }
- 消息{ props.msg.length }
- 退出
);
ToolUser.propTypes={
user:PropTypes.string,
msg:PropTypes.string
};
const ToolGuest = (props)=> (
- props.onLogin(e)}>登录
- props.onReg(e)}>注册
);
ToolGuest.propTypes={
onLogin:PropTypes.func,
onReg:PropTypes.func
}
class Header extends Component {
constructor(props) {
super(props);
this.state={
guestToolShow:true
}
}
handleLogin = (e) => {
e.preventDefault();
this.props.loginTypeAction("1");
this.setState({
guestToolShow:false
})
}
handleReg = (e)=>{
e.preventDefault();
this.props.loginTypeAction("2");
this.setState({
guestToolShow:false
})
}
hideGuestTool = (e)=>{
e.preventDefault();
this.setState({
guestToolShow:true
})
}
render () {
const { login, user, msg } = this.props;
return (
YAPI
{login?:(this.state.guestToolShow?:'')}
)
}
}
Header.propTypes={
user: PropTypes.string,
msg: PropTypes.string,
login:PropTypes.bool,
loginTypeAction:PropTypes.func
};
export default connect(
(state) => {
return{
user: state.login.userName,
msg: "暂无消息",
login:state.login.isLogin
}
},
{loginTypeAction}
)(Header)