Skip to content

Commit 459b1a7

Browse files
author
soliury
committed
some litile refactor
1 parent 2471165 commit 459b1a7

4 files changed

Lines changed: 5 additions & 12 deletions

File tree

src/actions/user.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,4 @@ export const getUserInfo = createAction(types.GET_USER_INFO, async (loginName)=>
5858
});
5959

6060

61-
export const logout = createAction(types.LOGOUT, async ()=> {
62-
return userService.storage.clearUser();
63-
});
61+
export const logout = createAction(types.LOGOUT, userService.storage.clearUser);

src/layouts/Utils.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ import Toast from '../components/base/Toast';
88

99

1010
class Utils extends Component {
11-
constructor(props) {
12-
super(props);
13-
}
14-
15-
1611
componentDidMount() {
1712
const { actions } = this.props;
1813
//actions.getUserFromStorage();

src/store/asyncActionCallbackMiddleware.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
export default function asyncActionCallbackMiddleware() {
22
return next => action => {
3-
const { meta = {}, error } = action;
3+
const { meta = {}, error, payload } = action;
44
const { sequence = {}, resolved, rejected } = meta;
55
if (sequence.type !== 'next') return next(action);
66

77

88
// 执行回调
9-
error ? (rejected && rejected()) : (resolved && resolved());
9+
error ? (rejected && rejected(payload)) : (resolved && resolved(payload));
1010

1111
next(action);
1212
}

src/store/utilsMiddleware.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import * as utilsActions from '../actions/utils';
44

55
export default function utilsMiddleware({ dispatch }) {
66
return next => action => {
7-
const { meta = {}, payload, error, type } = action;
8-
const { toast } = meta;
7+
const { payload, error, type } = action;
8+
const { toast } = action.meta || {};
99

1010
const dispatchToast = (...args)=> {
1111
dispatch(utilsActions.toast(...args));

0 commit comments

Comments
 (0)