diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 9d82c49f56536ada159835e1f5cba5964aa5eb49..ed274857dc4bcfaa18452fa989fa7d60b805294b 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 854d8b0fbcc1b61b63c56c42ff668e20f57acd3f..81d60252d66caf56d2b57d6a60cb5598a3549d1b 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, + }; + }, }, };