From 77f6943456e21d535a6356d3371b482aa8efd77c Mon Sep 17 00:00:00 2001 From: suxiaoxin Date: Fri, 21 Jul 2017 10:04:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4app.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/app.js | 97 --------------------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 client/app.js diff --git a/client/app.js b/client/app.js deleted file mode 100644 index 9d354d9f..00000000 --- a/client/app.js +++ /dev/null @@ -1,97 +0,0 @@ -import React, { Component } from 'react' -import { connect } from 'react-redux' -import PropTypes from 'prop-types' -import { Route, HashRouter, Redirect, Switch } from 'react-router-dom' -import { Home, ProjectGroups, Interface, News, AddInterface } from './containers/index' -import User from './containers/User/User.js' -import Header from './components/Header/Header' -import { checkLoginState } from './actions/login' - -const LOADING_STATUS = 0; -const GUEST_STATUS = 1; -const MEMBER_STATUS = 2; - - -class App extends Component { - - constructor(props) { - super(props); - this.state = { - login: LOADING_STATUS - } - } - static propTypes = { - checkLoginState:PropTypes.func - } - route = (status) => { - let r; - if (status === LOADING_STATUS) { - return loading... - } else if (status === GUEST_STATUS) { - r = ( - -
-
- - - - -
-
- ) - } else { - r = ( - -
-
- - - - - - -
-
- ) - } - return r - - } - - componentDidMount() { - this.props.checkLoginState().then((res) => { - console.log(res); - if (res.payload.data.errcode === 0 && res.payload.data.data._id > 0) { - this.setState({ - login: MEMBER_STATUS - }) - } else { - this.setState({ - login: GUEST_STATUS - }) - } - }).catch((err) => { - this.setState({ - login: GUEST_STATUS - }); - console.log(err) - }); - } - - render() { - return this.route(this.state.login) - } -} - -export default connect( - state => { - return{ - login:state.login.isLogin - } - }, - { - checkLoginState - } -)(App)