{"size": 1009, "ext": "js", "max_stars_repo_path": "src/models/blog.js", "max_stars_repo_name": "l-Lemon/blog-admin", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/models/blog.js", "max_issues_repo_name": "l-Lemon/blog-admin", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/models/blog.js", "max_forks_repo_name": "l-Lemon/blog-admin", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.7843137255, "max_line_length": 80, "alphanum_fraction": 0.4955401388}
import { getBlogList } from '../services/blog';
import { message } from 'antd';

export default {
  namespace: 'blog',

  state: {
    blogList: [],
    loading: false,
    pagination: {
        pageSize:1,
        page:1,
    },
  },

  effects: {
    *fetchList({payload},{ call, put}){
        yield put({
            type: 'changeLoading',
            payload: true,
          });
        const response = yield call(getBlogList,payload);
        yield put({
          type: 'getList',
          payload: {...response,pagination:payload},
        });
        yield put({
            type: 'changeLoading',
            payload: false,
        });
    }
  },

  reducers: {
    getList(state,action){
      
      return{
        ...state,
        blogList:action.payload.data,
        pagination:{...action.payload.pagination,total:action.payload.totalPage}
      }
    },
    changeLoading(state, action) {
        return {
          ...state,
          loading: action.payload,
        };
    },
  },
};
