123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import request from '../utils/request';
- import apis from '../services/apis';
-
- const UserModel = {
- namespace: 'user',
- state: {
- currentUser: {},
- },
- effects: {
- // *fetch(_, { call, put }) {
- // const response = yield call(queryUsers);
- // yield put({
- // type: 'save',
- // payload: response,
- // });
- // },
-
- *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;
|