动态菜单和动态路由的 antd pro

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { queryFakeList } from '../services/api';
  2. export default {
  3. namespace: 'list',
  4. state: {
  5. list: [],
  6. },
  7. effects: {
  8. *fetch({ payload }, { call, put }) {
  9. const response = yield call(queryFakeList, payload);
  10. yield put({
  11. type: 'queryList',
  12. payload: Array.isArray(response) ? response : [],
  13. });
  14. },
  15. *appendFetch({ payload }, { call, put }) {
  16. const response = yield call(queryFakeList, payload);
  17. yield put({
  18. type: 'appendList',
  19. payload: Array.isArray(response) ? response : [],
  20. });
  21. },
  22. },
  23. reducers: {
  24. queryList(state, action) {
  25. return {
  26. ...state,
  27. list: action.payload,
  28. };
  29. },
  30. appendList(state, action) {
  31. return {
  32. ...state,
  33. list: state.list.concat(action.payload),
  34. };
  35. },
  36. },
  37. };