Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baiguangyao
mr-julyedu
Commits
39f37417
Commit
39f37417
authored
Jun 11, 2019
by
xuzhenghua
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.julyedu.com:baiguangyao/mr-julyedu into detail
parents
b0203108
a90316df
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
13 deletions
+36
-13
src/App.js
+1
-8
src/components/passport/accountLogin/index.js
+6
-1
src/router/loading.js
+27
-0
src/router/privateRoute.js
+2
-4
No files found.
src/App.js
View file @
39f37417
...
...
@@ -26,14 +26,7 @@ class App extends Component {
cookie
.
set
(
'plat'
,
'5'
)
http
.
get
(
`
${
api
.
home
}
/m/user_info`
).
then
(
res
=>
{
if
(
res
.
data
.
code
===
4040
)
{
if
(
!
location
.
pathname
.
includes
(
'/passport'
))
{
location
.
assign
(
'/passport'
)
}
}
else
{
this
.
props
.
setCurrentUser
(
this
.
storeUser
(
res
))
}
this
.
props
.
setCurrentUser
(
this
.
storeUser
(
res
))
})
}
...
...
src/components/passport/accountLogin/index.js
View file @
39f37417
...
...
@@ -15,7 +15,12 @@ import PasswordInput from '../common/passwordInput'
// import LoginWays from '../common/LoginWays'
class
AccountLogin
extends
PureComponent
{
componentDidMount
(){
console
.
log
(
this
.
props
.
location
)
}
render
()
{
return
(
<
div
className
=
{
'account-login'
}
>
...
...
src/router/loading.js
0 → 100644
View file @
39f37417
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
src/router/privateRoute.js
View file @
39f37417
...
...
@@ -2,6 +2,7 @@ import React from 'react';
import
{
Route
,
Redirect
}
from
"react-router-dom"
;
import
{
connect
}
from
"react-redux"
;
import
jsCookie
from
'js-cookie'
import
Loading
from
'./loading'
const
PrivateRoute
=
({
component
:
Component
,
path
,
user
,
...
rest
})
=>
{
...
...
@@ -10,10 +11,7 @@ const PrivateRoute = ({component: Component, path, user, ...rest}) => {
<
Route
{...
rest
}
render
=
{
props
=>
{
return
authenticated
?
<
Component
{...
props
}
/
>
:
<
Redirect
to
=
{{
pathname
:
'/passport'
,
state
:
{
from
:
props
.
location
}
}}
/
>
:
<
Loading
state
=
{{
from
:
props
.
location
}}
/
>
}}
/
>
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment