From aef1e4a213b52d934229a9369e7cc269b018b402 Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Tue, 31 Oct 2017 11:43:01 +0800 Subject: [PATCH] fix #52 --- src/layouts/BasicLayout.js | 10 +++++++++- src/models/login.js | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 9d82c49f..ed274857 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -78,7 +78,15 @@ class BasicLayout extends React.PureComponent { } onMenuClick = ({ key }) => { if (key === 'logout') { - this.props.dispatch(routerRedux.push('/user/login')); + this.props.dispatch({ + type: 'login/logout', + payload: { + status: false, + }, + callback: () => { + this.props.dispatch(routerRedux.push('/user/login')); + }, + }); } } getDefaultCollapsedSubMenus(props) { diff --git a/src/models/login.js b/src/models/login.js index 854d8b0f..81d60252 100644 --- a/src/models/login.js +++ b/src/models/login.js @@ -38,6 +38,15 @@ export default { payload: false, }); }, + *logout({ payload, callback }, { put }) { + yield put({ + type: 'logoutHandle', + payload, + }); + if (callback) { + callback(); + } + }, }, reducers: { @@ -54,5 +63,11 @@ export default { submitting: payload, }; }, + logoutHandle(state, { payload }) { + return { + ...state, + status: payload.status, + }; + }, }, }; -- GitLab