1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import request from '../utils/request';
- import apis from '../services/apis';
-
- const UserModel = {
- namespace: 'user',
- state: {
- currentUser: {},
- },
- effects: {
- *fetchCurrent(_, { call, put }) {
- const response = yield call(request, apis.user.current);
-
- yield put({
- type: 'saveCurrentUser',
- payload: response,
- });
- },
- },
- reducers: {
- saveCurrentUser(state, action) {
- return { ...state, currentUser: action.payload || {} };
- },
-
- changeNotifyCount(
- state = {
- currentUser: {},
- },
- action,
- ) {
- return {
- ...state,
- currentUser: {
- ...state.currentUser,
- notifyCount: action.payload.totalCount,
- unreadCount: action.payload.unreadCount,
- },
- };
- },
- },
- };
- export default UserModel;
|