Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
0eaad1db
Commit
0eaad1db
authored
Jun 26, 2018
by
yoyo837
Committed by
ιεΈ
Jun 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redirect to expected page after logging in
parent
c5df0734
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
3 deletions
+24
-3
src/layouts/UserLayout.js
src/layouts/UserLayout.js
+11
-1
src/models/login.js
src/models/login.js
+12
-1
src/router.js
src/router.js
+1
-1
No files found.
src/layouts/UserLayout.js
View file @
0eaad1db
...
@@ -31,6 +31,16 @@ const copyright = (
...
@@ -31,6 +31,16 @@ const copyright = (
<
/Fragment
>
<
/Fragment
>
);
);
function
getLoginPathWithRedirectPath
()
{
const
routePath
=
'
/user/login
'
;
const
urlParams
=
new
URL
(
window
.
location
.
href
);
const
redirect
=
urlParams
.
searchParams
.
get
(
'
redirect
'
);
if
(
redirect
)
{
return
`
${
routePath
}
?redirect=
${
encodeURIComponent
(
redirect
)}
`
;
}
return
routePath
;
}
class
UserLayout
extends
React
.
PureComponent
{
class
UserLayout
extends
React
.
PureComponent
{
getPageTitle
()
{
getPageTitle
()
{
const
{
routerData
,
location
}
=
this
.
props
;
const
{
routerData
,
location
}
=
this
.
props
;
...
@@ -66,7 +76,7 @@ class UserLayout extends React.PureComponent {
...
@@ -66,7 +76,7 @@ class UserLayout extends React.PureComponent {
exact
=
{
item
.
exact
}
exact
=
{
item
.
exact
}
/
>
/
>
))}
))}
<
Redirect
exact
from
=
"
/user
"
to
=
"
/user/login
"
/>
<
Redirect
from
=
"
/user
"
to
=
{
getLoginPathWithRedirectPath
()}
/
>
<
/Switch
>
<
/Switch
>
<
/div
>
<
/div
>
<
GlobalFooter
links
=
{
links
}
copyright
=
{
copyright
}
/
>
<
GlobalFooter
links
=
{
links
}
copyright
=
{
copyright
}
/
>
...
...
src/models/login.js
View file @
0eaad1db
...
@@ -20,7 +20,18 @@ export default {
...
@@ -20,7 +20,18 @@ export default {
// Login successfully
// Login successfully
if
(
response
.
status
===
'
ok
'
)
{
if
(
response
.
status
===
'
ok
'
)
{
reloadAuthorized
();
reloadAuthorized
();
yield
put
(
routerRedux
.
push
(
'
/
'
));
const
urlParams
=
new
URL
(
window
.
location
.
href
);
let
redirect
=
urlParams
.
searchParams
.
get
(
'
redirect
'
);
if
(
redirect
)
{
const
redirectUrlParams
=
new
URL
(
redirect
);
if
(
redirectUrlParams
.
origin
===
urlParams
.
origin
)
{
redirect
=
redirect
.
substr
(
urlParams
.
origin
.
length
);
}
else
{
window
.
location
.
href
=
redirect
;
return
;
}
}
yield
put
(
routerRedux
.
push
(
redirect
||
'
/
'
));
}
}
},
},
*
logout
(
_
,
{
put
,
select
})
{
*
logout
(
_
,
{
put
,
select
})
{
...
...
src/router.js
View file @
0eaad1db
...
@@ -26,7 +26,7 @@ function RouterConfig({ history, app }) {
...
@@ -26,7 +26,7 @@ function RouterConfig({ history, app }) {
path
=
"
/
"
path
=
"
/
"
render
=
{
props
=>
<
BasicLayout
{...
props
}
/>
}
render
=
{
props
=>
<
BasicLayout
{...
props
}
/>
}
authority
=
{[
'
admin
'
,
'
user
'
]}
authority
=
{[
'
admin
'
,
'
user
'
]}
redirectPath
=
"
/user/login
"
redirectPath
=
{
`/user/login?redirect=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
}
/
>
/
>
<
/Switch
>
<
/Switch
>
<
/ConnectedRouter
>
<
/ConnectedRouter
>
...
...
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