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
c9d71c91
Commit
c9d71c91
authored
Jun 26, 2018
by
yoyo837
Committed by
陈帅
Jun 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抽取 getQueryPath 方法封装路径和查询参数拼接
parent
63c8ceb2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
10 deletions
+23
-10
src/layouts/UserLayout.js
src/layouts/UserLayout.js
+4
-6
src/models/login.js
src/models/login.js
+6
-2
src/router.js
src/router.js
+4
-1
src/utils/utils.js
src/utils/utils.js
+9
-1
No files found.
src/layouts/UserLayout.js
View file @
c9d71c91
...
@@ -5,7 +5,7 @@ import { Icon } from 'antd';
...
@@ -5,7 +5,7 @@ import { Icon } from 'antd';
import
GlobalFooter
from
'
../components/GlobalFooter
'
;
import
GlobalFooter
from
'
../components/GlobalFooter
'
;
import
styles
from
'
./UserLayout.less
'
;
import
styles
from
'
./UserLayout.less
'
;
import
logo
from
'
../assets/logo.svg
'
;
import
logo
from
'
../assets/logo.svg
'
;
import
{
getRoutes
,
getPageQuery
}
from
'
../utils/utils
'
;
import
{
getRoutes
,
getPageQuery
,
getQueryPath
}
from
'
../utils/utils
'
;
const
links
=
[
const
links
=
[
{
{
...
@@ -32,13 +32,11 @@ const copyright = (
...
@@ -32,13 +32,11 @@ const copyright = (
);
);
function
getLoginPathWithRedirectPath
()
{
function
getLoginPathWithRedirectPath
()
{
const
routePath
=
'
/user/login
'
;
const
params
=
getPageQuery
();
const
params
=
getPageQuery
();
const
{
redirect
}
=
params
;
const
{
redirect
}
=
params
;
if
(
redirect
)
{
return
getQueryPath
(
'
/user/login
'
,
{
return
`
${
routePath
}
?redirect=
${
encodeURIComponent
(
redirect
)}
`
;
redirect
,
}
});
return
routePath
;
}
}
class
UserLayout
extends
React
.
PureComponent
{
class
UserLayout
extends
React
.
PureComponent
{
...
...
src/models/login.js
View file @
c9d71c91
...
@@ -2,7 +2,7 @@ import { routerRedux } from 'dva/router';
...
@@ -2,7 +2,7 @@ import { routerRedux } from 'dva/router';
import
{
fakeAccountLogin
}
from
'
../services/api
'
;
import
{
fakeAccountLogin
}
from
'
../services/api
'
;
import
{
setAuthority
}
from
'
../utils/authority
'
;
import
{
setAuthority
}
from
'
../utils/authority
'
;
import
{
reloadAuthorized
}
from
'
../utils/Authorized
'
;
import
{
reloadAuthorized
}
from
'
../utils/Authorized
'
;
import
{
getPageQuery
}
from
'
../utils/utils
'
;
import
{
getPageQuery
,
getQueryPath
}
from
'
../utils/utils
'
;
export
default
{
export
default
{
namespace
:
'
login
'
,
namespace
:
'
login
'
,
...
@@ -49,7 +49,11 @@ export default {
...
@@ -49,7 +49,11 @@ export default {
});
});
reloadAuthorized
();
reloadAuthorized
();
yield
put
(
yield
put
(
routerRedux
.
push
(
`/user/login?redirect=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
)
routerRedux
.
push
(
getQueryPath
(
'
/user/login
'
,
{
redirect
:
window
.
location
.
href
,
})
)
);
);
},
},
},
},
...
...
src/router.js
View file @
c9d71c91
...
@@ -5,6 +5,7 @@ import zhCN from 'antd/lib/locale-provider/zh_CN';
...
@@ -5,6 +5,7 @@ import zhCN from 'antd/lib/locale-provider/zh_CN';
import
dynamic
from
'
dva/dynamic
'
;
import
dynamic
from
'
dva/dynamic
'
;
import
{
getRouterData
}
from
'
./common/router
'
;
import
{
getRouterData
}
from
'
./common/router
'
;
import
Authorized
from
'
./utils/Authorized
'
;
import
Authorized
from
'
./utils/Authorized
'
;
import
{
getQueryPath
}
from
'
./utils/utils
'
;
import
styles
from
'
./index.less
'
;
import
styles
from
'
./index.less
'
;
const
{
ConnectedRouter
}
=
routerRedux
;
const
{
ConnectedRouter
}
=
routerRedux
;
...
@@ -26,7 +27,9 @@ function RouterConfig({ history, app }) {
...
@@ -26,7 +27,9 @@ function RouterConfig({ history, app }) {
path
=
"
/
"
path
=
"
/
"
render
=
{
props
=>
<
BasicLayout
{...
props
}
/>
}
render
=
{
props
=>
<
BasicLayout
{...
props
}
/>
}
authority
=
{[
'
admin
'
,
'
user
'
]}
authority
=
{[
'
admin
'
,
'
user
'
]}
redirectPath
=
{
`/user/login?redirect=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
}
redirectPath
=
{
getQueryPath
(
'
/user/login
'
,
{
redirect
:
window
.
location
.
href
,
})}
/
>
/
>
<
/Switch
>
<
/Switch
>
<
/ConnectedRouter
>
<
/ConnectedRouter
>
...
...
src/utils/utils.js
View file @
c9d71c91
import
moment
from
'
moment
'
;
import
moment
from
'
moment
'
;
import
{
parse
}
from
'
qs
'
;
import
{
parse
,
stringify
}
from
'
qs
'
;
export
function
fixedZero
(
val
)
{
export
function
fixedZero
(
val
)
{
return
val
*
1
<
10
?
`0
${
val
}
`
:
val
;
return
val
*
1
<
10
?
`0
${
val
}
`
:
val
;
...
@@ -166,6 +166,14 @@ export function getPageQuery() {
...
@@ -166,6 +166,14 @@ export function getPageQuery() {
return
parse
(
window
.
location
.
href
.
split
(
'
?
'
)[
1
]);
return
parse
(
window
.
location
.
href
.
split
(
'
?
'
)[
1
]);
}
}
export
function
getQueryPath
(
path
=
''
,
query
=
{})
{
const
search
=
stringify
(
query
);
if
(
search
.
length
)
{
return
`
${
path
}
?
${
search
}
`
;
}
return
path
;
}
/* eslint no-useless-escape:0 */
/* eslint no-useless-escape:0 */
const
reg
=
/
(((
^https
?
:
(?:\/\/)?)(?:[
-;:&=
\+\$
,
\w]
+@
)?[
A-Za-z0-9.-
]
+
(?:
:
\d
+
)?
|
(?:
www.|
[
-;:&=
\+\$
,
\w]
+@
)[
A-Za-z0-9.-
]
+
)((?:\/[\+
~%
\/
.
\w
-_
]
*
)?\??(?:[
-
\+
=&;%@.
\w
_
]
*
)
#
?(?:[\w]
*
))?)
$/
;
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