Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
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
f50867b0
Commit
f50867b0
authored
7 years ago
by
afc163
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better dispatch and saga for login logic
parent
41fffed2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
22 deletions
+11
-22
src/layouts/BasicLayout.js
src/layouts/BasicLayout.js
+1
-7
src/models/login.js
src/models/login.js
+10
-15
No files found.
src/layouts/BasicLayout.js
View file @
f50867b0
...
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
...
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import
{
Layout
,
Menu
,
Icon
,
Avatar
,
Dropdown
,
Tag
,
message
,
Spin
}
from
'
antd
'
;
import
{
Layout
,
Menu
,
Icon
,
Avatar
,
Dropdown
,
Tag
,
message
,
Spin
}
from
'
antd
'
;
import
DocumentTitle
from
'
react-document-title
'
;
import
DocumentTitle
from
'
react-document-title
'
;
import
{
connect
}
from
'
dva
'
;
import
{
connect
}
from
'
dva
'
;
import
{
Link
,
routerRedux
,
Route
,
Redirect
,
Switch
}
from
'
dva/router
'
;
import
{
Link
,
Route
,
Redirect
,
Switch
}
from
'
dva/router
'
;
import
moment
from
'
moment
'
;
import
moment
from
'
moment
'
;
import
groupBy
from
'
lodash/groupBy
'
;
import
groupBy
from
'
lodash/groupBy
'
;
import
{
ContainerQuery
}
from
'
react-container-query
'
;
import
{
ContainerQuery
}
from
'
react-container-query
'
;
...
@@ -80,12 +80,6 @@ class BasicLayout extends React.PureComponent {
...
@@ -80,12 +80,6 @@ class BasicLayout extends React.PureComponent {
if
(
key
===
'
logout
'
)
{
if
(
key
===
'
logout
'
)
{
this
.
props
.
dispatch
({
this
.
props
.
dispatch
({
type
:
'
login/logout
'
,
type
:
'
login/logout
'
,
payload
:
{
status
:
false
,
},
callback
:
()
=>
{
this
.
props
.
dispatch
(
routerRedux
.
push
(
'
/user/login
'
));
},
});
});
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/models/login.js
View file @
f50867b0
import
{
routerRedux
}
from
'
dva/router
'
;
import
{
fakeAccountLogin
,
fakeMobileLogin
}
from
'
../services/api
'
;
import
{
fakeAccountLogin
,
fakeMobileLogin
}
from
'
../services/api
'
;
export
default
{
export
default
{
...
@@ -15,7 +16,7 @@ export default {
...
@@ -15,7 +16,7 @@ export default {
});
});
const
response
=
yield
call
(
fakeAccountLogin
,
payload
);
const
response
=
yield
call
(
fakeAccountLogin
,
payload
);
yield
put
({
yield
put
({
type
:
'
loginHandle
'
,
type
:
'
changeLoginStatus
'
,
payload
:
response
,
payload
:
response
,
});
});
yield
put
({
yield
put
({
...
@@ -30,7 +31,7 @@ export default {
...
@@ -30,7 +31,7 @@ export default {
});
});
const
response
=
yield
call
(
fakeMobileLogin
);
const
response
=
yield
call
(
fakeMobileLogin
);
yield
put
({
yield
put
({
type
:
'
loginHandle
'
,
type
:
'
changeLoginStatus
'
,
payload
:
response
,
payload
:
response
,
});
});
yield
put
({
yield
put
({
...
@@ -38,19 +39,19 @@ export default {
...
@@ -38,19 +39,19 @@ export default {
payload
:
false
,
payload
:
false
,
});
});
},
},
*
logout
(
{
payload
,
callback
}
,
{
put
})
{
*
logout
(
_
,
{
put
})
{
yield
put
({
yield
put
({
type
:
'
logoutHandle
'
,
type
:
'
changeLoginStatus
'
,
payload
,
payload
:
{
status
:
false
,
},
});
});
if
(
callback
)
{
yield
put
(
routerRedux
.
push
(
'
/user/login
'
));
callback
();
}
},
},
},
},
reducers
:
{
reducers
:
{
loginHandle
(
state
,
{
payload
})
{
changeLoginStatus
(
state
,
{
payload
})
{
return
{
return
{
...
state
,
...
state
,
status
:
payload
.
status
,
status
:
payload
.
status
,
...
@@ -63,11 +64,5 @@ export default {
...
@@ -63,11 +64,5 @@ export default {
submitting
:
payload
,
submitting
:
payload
,
};
};
},
},
logoutHandle
(
state
,
{
payload
})
{
return
{
...
state
,
status
:
payload
.
status
,
};
},
},
},
};
};
This diff is collapsed.
Click to expand it.
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