Commit 39f37417 by xuzhenghua

Merge branch 'master' of gitlab.julyedu.com:baiguangyao/mr-julyedu into detail

parents b0203108 a90316df
...@@ -26,14 +26,7 @@ class App extends Component { ...@@ -26,14 +26,7 @@ class App extends Component {
cookie.set('plat', '5') cookie.set('plat', '5')
http.get(`${api.home}/m/user_info`).then(res => { http.get(`${api.home}/m/user_info`).then(res => {
if (res.data.code === 4040) { this.props.setCurrentUser(this.storeUser(res))
if (!location.pathname.includes('/passport')) {
location.assign('/passport')
}
} else {
this.props.setCurrentUser(this.storeUser(res))
}
}) })
} }
......
...@@ -15,7 +15,12 @@ import PasswordInput from '../common/passwordInput' ...@@ -15,7 +15,12 @@ import PasswordInput from '../common/passwordInput'
// import LoginWays from '../common/LoginWays' // import LoginWays from '../common/LoginWays'
class AccountLogin extends PureComponent { class AccountLogin extends PureComponent {
componentDidMount(){
console.log(this.props.location)
}
render() { render() {
return ( return (
<div className={'account-login'}> <div className={'account-login'}>
......
import React from 'react';
import { connect } from 'react-redux';
import { withRouter } from "react-router-dom";
import { compose } from "redux";
const Loading = ({user, history, state}) => {
if (Object.values(user.data).filter(item => !!item).length !== 0) {
history.replace(location.pathname)
} else {
history.replace('/passport', {...state})
}
return (
<div className={'loading'}>
loading...
</div>
);
};
export default compose(
connect(
state => ({user: state.user}),
null
),
withRouter
)(Loading);
\ No newline at end of file
...@@ -2,6 +2,7 @@ import React from 'react'; ...@@ -2,6 +2,7 @@ import React from 'react';
import { Route, Redirect } from "react-router-dom"; import { Route, Redirect } from "react-router-dom";
import { connect } from "react-redux"; import { connect } from "react-redux";
import jsCookie from 'js-cookie' import jsCookie from 'js-cookie'
import Loading from './loading'
const PrivateRoute = ({component: Component, path, user, ...rest}) => { const PrivateRoute = ({component: Component, path, user, ...rest}) => {
...@@ -10,10 +11,7 @@ const PrivateRoute = ({component: Component, path, user, ...rest}) => { ...@@ -10,10 +11,7 @@ const PrivateRoute = ({component: Component, path, user, ...rest}) => {
<Route {...rest} render={props => { <Route {...rest} render={props => {
return authenticated return authenticated
? <Component {...props}/> ? <Component {...props}/>
: <Redirect to={{ : <Loading state={{from: props.location}}/>
pathname: '/passport',
state: {from: props.location}
}}/>
}}/> }}/>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment