import React from 'react'; import {Link} from 'react-router-dom'; import './index.css'; import slonik from 'image/slonik.png' import PGUtil from 'util/util.jsx' const _util = new PGUtil(); import User from 'service/user-service.jsx' const _user = new User(); class NavTop extends React.Component { constructor(props) { super(props); this.state = { // username: _util.getStorage('userInfo').username || '', userinfo: _util.getStorage('userInfo')|| {}, isLoggedIn: true } } // logout onLogout() { _util.removeStorage('userInfo'); window.location.href = '/login'; } componentWillMount(){ this.setState({ isLoggedIn: this.isLoggedIn(), }); } isLoggedIn() { if(this.state.userinfo.token){ return true; } return false; } render() { let isLoggedIn = this.state.isLoggedIn; let button = null; if (isLoggedIn) { button =