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
18fc7851
Commit
18fc7851
authored
Sep 23, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
record
parent
db32d9e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
src/App.js
+21
-21
src/components/passport/index.js
+1
-1
No files found.
src/App.js
View file @
18fc7851
import
React
,
{
Component
}
from
'react'
import
React
,
{
Component
}
from
'react'
import
Routes
from
'./router'
import
cookie
from
'js-cookie'
import
{
connect
}
from
"react-redux"
;
import
{
setCurrentUser
,
startFetchUser
}
from
"@/store/userAction"
;
import
{
withRouter
}
from
'react-router-dom'
import
{
compose
}
from
'redux'
import
{
getParam
,
http
,
browser
}
from
"@/utils"
;
import
{
Toast
}
from
"antd-mobile"
;
import
{
addDays
}
from
'date-fns'
import
{
connect
}
from
"react-redux"
;
import
{
setCurrentUser
,
startFetchUser
}
from
"@/store/userAction"
;
import
{
withRouter
}
from
'react-router-dom'
import
{
compose
}
from
'redux'
import
{
getParam
,
http
,
browser
}
from
"@/utils"
;
import
{
Toast
}
from
"antd-mobile"
;
import
{
addDays
}
from
'date-fns'
//拦截ajax请求,返回mock数据
...
...
@@ -65,6 +65,7 @@ class App extends Component {
history
.
listen
((
location
,
action
)
=>
{
this
.
firstLoad
=
false
this
.
setNavigationRecord
(
location
,
action
)
this
.
setPreviousLocation
()
if
(
cookie
.
get
(
'uid'
)
&&
this
.
props
.
user
.
hasError
)
{
this
.
getUser
()
}
...
...
@@ -82,13 +83,13 @@ class App extends Component {
setNavigationRecord
=
(
location
,
action
)
=>
{
const
{
pathname
,
search
,
hash
}
=
location
let
isLastRecord
=
location
.
pathname
===
this
.
records
.
length
&&
this
.
records
[
this
.
records
.
length
-
1
].
pathname
let
isLastRecord
=
location
.
pathname
===
(
this
.
records
.
length
&&
this
.
records
[
this
.
records
.
length
-
1
].
pathname
)
switch
(
action
)
{
case
'POP'
:
this
.
firstLoad
?
this
.
records
.
push
({
pathname
,
search
,
hash
})
:
this
.
records
.
pop
()
break
case
'REPLACE'
:
this
.
records
[
this
.
records
.
length
-
1
]
=
{
pathname
,
search
,
hash
}
this
.
records
.
length
>
1
&&
(
this
.
records
[
this
.
records
.
length
-
1
]
=
{
pathname
,
search
,
hash
})
break
default
:
!
isLastRecord
&&
this
.
records
.
push
({
pathname
,
search
,
hash
})
...
...
@@ -136,8 +137,6 @@ class App extends Component {
componentDidUpdate
()
{
this
.
setPreviousLocation
()
if
(
!
this
.
props
.
user
.
hasError
&&
getParam
(
'redirect'
))
{
window
.
location
.
href
=
getParam
(
'redirect'
)
}
...
...
@@ -145,22 +144,23 @@ class App extends Component {
setPreviousLocation
=
()
=>
{
const
{
location
,
history
:
{
action
}}
=
this
.
props
if
(
location
.
pathname
.
startsWith
(
'/passport'
))
{
let
index
=
this
.
records
.
findIndex
(
item
=>
item
.
pathname
.
startsWith
(
'/passport'
))
/*
let index = this.records.findIndex(item => item.pathname.startsWith('/passport'))
this.previousLocation = index > 0
? this.records[index - 1]
: this.records.length
? this.records[this.records.length - 1]
:
null
: null
*/
}
else
{
if
(
action
===
'POP'
||
action
===
'REPLACE'
)
{
let
index
=
this
.
records
.
findIndex
(
item
=>
item
.
pathname
.
startsWith
(
'/passport'
))
this
.
previousLocation
=
index
>
0
?
this
.
records
[
index
-
1
]
:
this
.
records
[
this
.
records
.
length
-
1
]
}
else
{
this
.
previousLocation
=
location
}
if
(
action
===
'POP'
||
action
===
'REPLACE'
)
{
let
index
=
this
.
records
.
findIndex
(
item
=>
item
.
pathname
.
startsWith
(
'/passport'
))
this
.
previousLocation
=
index
>
0
?
this
.
records
[
index
-
1
]
:
this
.
records
[
this
.
records
.
length
-
1
]
}
else
{
this
.
previousLocation
=
location
}
}
}
transformUser
=
res
=>
{
...
...
src/components/passport/index.js
View file @
18fc7851
...
...
@@ -75,7 +75,7 @@ class Passport extends Component {
if
(
history
.
action
===
'POP'
&&
history
.
length
<=
3
)
{
history
.
push
(
'/'
)
}
else
{
const
from
=
location
.
state
&&
location
.
state
.
from
||
{
from
:
{
pathname
:
'/'
,
search
:
''
}
};
const
from
=
location
.
state
&&
location
.
state
.
from
||
{
pathname
:
'/'
,
search
:
''
};
const
redirectURI
=
getParam
(
'redirect'
)
redirectURI
?
(
window
.
location
.
href
=
redirectURI
)
:
history
.
replace
(
from
);
}
...
...
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