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
63c8ceb2
Commit
63c8ceb2
authored
Jun 26, 2018
by
yoyo837
Committed by
陈帅
Jun 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兼容hash 路由模式
parent
f904467d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
src/layouts/UserLayout.js
src/layouts/UserLayout.js
+3
-3
src/models/login.js
src/models/login.js
+6
-1
src/utils/utils.js
src/utils/utils.js
+5
-0
No files found.
src/layouts/UserLayout.js
View file @
63c8ceb2
...
...
@@ -5,7 +5,7 @@ import { Icon } from 'antd';
import
GlobalFooter
from
'
../components/GlobalFooter
'
;
import
styles
from
'
./UserLayout.less
'
;
import
logo
from
'
../assets/logo.svg
'
;
import
{
getRoutes
}
from
'
../utils/utils
'
;
import
{
getRoutes
,
getPageQuery
}
from
'
../utils/utils
'
;
const
links
=
[
{
...
...
@@ -33,8 +33,8 @@ const copyright = (
function
getLoginPathWithRedirectPath
()
{
const
routePath
=
'
/user/login
'
;
const
urlParams
=
new
URL
(
window
.
location
.
href
);
const
redirect
=
urlParams
.
searchParams
.
get
(
'
redirect
'
)
;
const
params
=
getPageQuery
(
);
const
{
redirect
}
=
params
;
if
(
redirect
)
{
return
`
${
routePath
}
?redirect=
${
encodeURIComponent
(
redirect
)}
`
;
}
...
...
src/models/login.js
View file @
63c8ceb2
...
...
@@ -2,6 +2,7 @@ import { routerRedux } from 'dva/router';
import
{
fakeAccountLogin
}
from
'
../services/api
'
;
import
{
setAuthority
}
from
'
../utils/authority
'
;
import
{
reloadAuthorized
}
from
'
../utils/Authorized
'
;
import
{
getPageQuery
}
from
'
../utils/utils
'
;
export
default
{
namespace
:
'
login
'
,
...
...
@@ -21,11 +22,15 @@ export default {
if
(
response
.
status
===
'
ok
'
)
{
reloadAuthorized
();
const
urlParams
=
new
URL
(
window
.
location
.
href
);
let
redirect
=
urlParams
.
searchParams
.
get
(
'
redirect
'
);
const
params
=
getPageQuery
();
let
{
redirect
}
=
params
;
if
(
redirect
)
{
const
redirectUrlParams
=
new
URL
(
redirect
);
if
(
redirectUrlParams
.
origin
===
urlParams
.
origin
)
{
redirect
=
redirect
.
substr
(
urlParams
.
origin
.
length
);
if
(
redirect
.
startsWith
(
'
/#
'
))
{
redirect
=
redirect
.
substr
(
2
);
}
}
else
{
window
.
location
.
href
=
redirect
;
return
;
...
...
src/utils/utils.js
View file @
63c8ceb2
import
moment
from
'
moment
'
;
import
{
parse
}
from
'
qs
'
;
export
function
fixedZero
(
val
)
{
return
val
*
1
<
10
?
`0
${
val
}
`
:
val
;
...
...
@@ -161,6 +162,10 @@ export function getRoutes(path, routerData) {
return
renderRoutes
;
}
export
function
getPageQuery
()
{
return
parse
(
window
.
location
.
href
.
split
(
'
?
'
)[
1
]);
}
/* eslint no-useless-escape:0 */
const
reg
=
/
(((
^https
?
:
(?:\/\/)?)(?:[
-;:&=
\+\$
,
\w]
+@
)?[
A-Za-z0-9.-
]
+
(?:
:
\d
+
)?
|
(?:
www.|
[
-;:&=
\+\$
,
\w]
+@
)[
A-Za-z0-9.-
]
+
)((?:\/[\+
~%
\/
.
\w
-_
]
*
)?\??(?:[
-
\+
=&;%@.
\w
_
]
*
)
#
?(?:[\w]
*
))?)
$/
;
...
...
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