import React from 'react'; import { Menu, Icon, Button, Switch } from 'antd'; import { BrowserRouter as Router, Route, Link, withRouter } from 'react-router-dom'; import MUtil from 'util/mutil.jsx'; import './index.scss'; const SubMenu = Menu.SubMenu; const _mutil = new MUtil(); class Logo extends React.Component { constructor(props) { super(props); } render() { if (this.props.collapsed) { return ( ); } else { return ( ); } } } class SideNav extends React.Component { constructor(props) { super(props); this.state = { theme: 'dark', current: '/', // defaultOpen: 'product', myTextInput: '', userInfo: _mutil.getStorage('userInfo') || '' }; } handleClick(e) { const pathname = this.props.history.location.pathname; this.setState({ current: e.key }); if (pathname !== '/' && this.state.userInfo === '') { _mutil.doLogin(); } } componentWillMount() { if (this.props.location.pathname !== '/') { if (this.state.userInfo === '') { _mutil.doLogin(); } console.log(this.props.location.pathname.split('-')[0]); this.setState({ current: this.props.location.pathname }); } } render() { return (
); } } export default withRouter(SideNav);