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
62dd228b
Commit
62dd228b
authored
Jun 28, 2019
by
duanledexianxianxian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync
parent
19001b76
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
13 deletions
+47
-13
src/pages/user/login/index.js
src/pages/user/login/index.js
+2
-8
src/pages/user/login/models/index.js
src/pages/user/login/models/index.js
+37
-3
src/utils/index.js
src/utils/index.js
+8
-2
No files found.
src/pages/user/login/index.js
View file @
62dd228b
...
...
@@ -2,8 +2,10 @@ import React from 'react';
import
{
connect
}
from
'
dva
'
;
import
router
from
'
umi/router
'
;
import
store
from
'
@/utils/store
'
;
import
{
Input
,
Icon
,
Button
,
message
}
from
'
antd
'
;
import
config
from
'
@/config
'
;
import
styles
from
'
./index.less
'
;
@
connect
()
...
...
@@ -27,14 +29,6 @@ class Login extends React.Component {
dispatch
({
type
:
'
userLogin/login
'
,
payload
:
{
userName
:
username
,
password
},
}).
then
(({
code
,
data
})
=>
{
if
(
code
===
'
sys.success
'
)
{
const
{
token
,
userId
}
=
data
;
// message.success("登录成功");
store
.
set
(
'
token
'
,
token
);
store
.
set
(
'
userId
'
,
userId
);
router
.
push
(
config
.
home
||
'
/profile/message
'
);
}
});
};
...
...
src/pages/user/login/models/index.js
View file @
62dd228b
import
{
login
}
from
'
../services
'
;
import
store
from
'
@/utils/store
'
;
import
{
routerRedux
}
from
'
dva/router
'
;
import
{
getPageQuery
}
from
'
@/utils
'
;
const
initData
=
{};
export
default
{
...
...
@@ -7,12 +10,43 @@ export default {
...
initData
,
},
effects
:
{
*
login
({
payload
},
{
call
})
{
const
res
=
yield
call
(
login
,
payload
);
return
res
;
*
login
({
payload
},
{
call
,
put
})
{
const
{
code
,
data
}
=
yield
call
(
login
,
payload
);
if
(
code
===
'
sys.success
'
)
{
const
{
token
,
userId
}
=
data
;
store
.
set
(
'
token
'
,
token
);
store
.
set
(
'
userId
'
,
userId
);
const
urlParams
=
new
URL
(
window
.
location
.
href
);
const
params
=
getPageQuery
();
// 是否需要重定向
let
{
redirect
}
=
params
;
if
(
redirect
)
{
const
redirectUrlParams
=
new
URL
(
redirect
);
// origin相同
if
(
redirectUrlParams
.
origin
===
urlParams
.
origin
)
{
redirect
=
redirect
.
substr
(
urlParams
.
origin
.
length
);
if
(
redirect
.
match
(
/^
\/
.*#/
))
{
redirect
=
redirect
.
substr
(
redirect
.
indexOf
(
'
#
'
)
+
1
);
}
}
else
{
window
.
location
.
href
=
redirect
;
return
;
}
}
yield
put
(
routerRedux
.
replace
(
redirect
||
'
/
'
));
}
},
},
reducers
:
{
clearData
:
()
=>
({
...
initData
}),
changeLoginStatus
(
state
,
{
payload
})
{
// setAuthority(payload.currentAuthority);
// return {
// ...state,
// status: payload.status,
// type: payload.type,
// };
},
},
};
src/utils/index.js
View file @
62dd228b
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable no-bitwise */
// 工具类已经转移到solomon-utils下,如果需要添加工具部分,请先考虑是否需要添加到solomon-utils下
import
pathToRegexp
from
'
path-to-regexp
'
;
import
{
parse
}
from
'
qs
'
;
/**
* 获取链接的query url部分
*/
export
function
getPageQuery
()
{
return
parse
(
window
.
location
.
href
.
split
(
'
?
'
)[
1
]);
}
export
const
generateUUID
=
()
=>
{
let
d
=
new
Date
().
getTime
();
...
...
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