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
P
pro-blocks
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
pro-blocks
Commits
26dc3af8
Commit
26dc3af8
authored
May 23, 2019
by
陈帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix login status error
parent
825425c5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
3 deletions
+33
-3
UserLogin/package.json
UserLogin/package.json
+2
-1
UserLogin/src/model.ts
UserLogin/src/model.ts
+26
-2
UserLogin/src/utils/utils.ts
UserLogin/src/utils/utils.ts
+5
-0
No files found.
UserLogin/package.json
View file @
26dc3af8
...
@@ -11,10 +11,11 @@
...
@@ -11,10 +11,11 @@
"url"
:
"https://github.com/umijs/umi-blocks/ant-design-pro/userlogin"
"url"
:
"https://github.com/umijs/umi-blocks/ant-design-pro/userlogin"
},
},
"dependencies"
:
{
"dependencies"
:
{
"@types/qs"
:
"^6.5.3"
,
"antd"
:
"^3.16.3"
,
"antd"
:
"^3.16.3"
,
"dva"
:
"^2.4.0"
,
"dva"
:
"^2.4.0"
,
"moment"
:
"^2.22.2"
,
"moment"
:
"^2.22.2"
,
"q
uery-string"
:
"^6.0
.0"
,
"q
s"
:
"^6.7
.0"
,
"react"
:
"^16.6.3"
,
"react"
:
"^16.6.3"
,
"umi-request"
:
"^1.0.0"
"umi-request"
:
"^1.0.0"
},
},
...
...
UserLogin/src/model.ts
View file @
26dc3af8
import
{
routerRedux
}
from
'
dva/router
'
;
import
{
routerRedux
}
from
'
dva/router
'
;
import
{
getPageQuery
}
from
'
./utils/utils
'
;
import
{
getPageQuery
,
setAuthority
}
from
'
./utils/utils
'
;
import
{
fakeAccountLogin
,
getFakeCaptcha
}
from
'
./service
'
;
import
{
fakeAccountLogin
,
getFakeCaptcha
}
from
'
./service
'
;
import
{
stringify
}
from
'
qs
'
;
import
{
Reducer
}
from
'
redux
'
;
import
{
Reducer
}
from
'
redux
'
;
import
{
EffectsCommandMap
}
from
'
dva
'
;
import
{
EffectsCommandMap
}
from
'
dva
'
;
import
{
AnyAction
}
from
'
redux
'
;
import
{
AnyAction
}
from
'
redux
'
;
...
@@ -23,6 +23,7 @@ export interface ModelType {
...
@@ -23,6 +23,7 @@ export interface ModelType {
effects
:
{
effects
:
{
login
:
Effect
;
login
:
Effect
;
getCaptcha
:
Effect
;
getCaptcha
:
Effect
;
logout
:
Effect
;
};
};
reducers
:
{
reducers
:
{
changeLoginStatus
:
Reducer
<
IStateType
>
;
changeLoginStatus
:
Reducer
<
IStateType
>
;
...
@@ -67,10 +68,33 @@ const Model: ModelType = {
...
@@ -67,10 +68,33 @@ const Model: ModelType = {
*
getCaptcha
({
payload
},
{
call
})
{
*
getCaptcha
({
payload
},
{
call
})
{
yield
call
(
getFakeCaptcha
,
payload
);
yield
call
(
getFakeCaptcha
,
payload
);
},
},
*
logout
(
_
,
{
put
})
{
yield
put
({
type
:
'
changeLoginStatus
'
,
payload
:
{
status
:
false
,
currentAuthority
:
'
guest
'
,
},
});
const
{
redirect
}
=
getPageQuery
();
// redirect
if
(
window
.
location
.
pathname
!==
'
/user/login
'
&&
!
redirect
)
{
yield
put
(
routerRedux
.
replace
({
pathname
:
'
/user/login
'
,
search
:
stringify
({
redirect
:
window
.
location
.
href
,
}),
}),
);
}
},
},
},
reducers
:
{
reducers
:
{
changeLoginStatus
(
state
,
{
payload
})
{
changeLoginStatus
(
state
,
{
payload
})
{
setAuthority
(
payload
.
currentAuthority
);
return
{
return
{
...
state
,
...
state
,
status
:
payload
.
status
,
status
:
payload
.
status
,
...
...
UserLogin/src/utils/utils.ts
View file @
26dc3af8
...
@@ -3,3 +3,8 @@ import { parse } from 'query-string';
...
@@ -3,3 +3,8 @@ import { parse } from 'query-string';
export
function
getPageQuery
()
{
export
function
getPageQuery
()
{
return
parse
(
window
.
location
.
href
.
split
(
'
?
'
)[
1
]);
return
parse
(
window
.
location
.
href
.
split
(
'
?
'
)[
1
]);
}
}
export
function
setAuthority
(
authority
:
string
|
string
[])
{
const
proAuthority
=
typeof
authority
===
'
string
'
?
[
authority
]
:
authority
;
return
localStorage
.
setItem
(
'
antd-pro-authority
'
,
JSON
.
stringify
(
proAuthority
));
}
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