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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { queryRule, removeRule, addRule } from '../services/api';
  2. export default {
  3. namespace: 'rule',
  4. state: {
  5. data: {
  6. list: [],
  7. pagination: {},
  8. },
  9. },
  10. effects: {
  11. *fetch({ payload }, { call, put }) {
  12. const response = yield call(queryRule, payload);
  13. yield put({
  14. type: 'save',
  15. payload: response,
  16. });
  17. },
  18. *add({ payload, callback }, { call, put }) {
  19. const response = yield call(addRule, payload);
  20. yield put({
  21. type: 'save',
  22. payload: response,
  23. });
  24. if (callback) callback();
  25. },
  26. *remove({ payload, callback }, { call, put }) {
  27. const response = yield call(removeRule, payload);
  28. yield put({
  29. type: 'save',
  30. payload: response,
  31. });
  32. if (callback) callback();
  33. },
  34. },
  35. reducers: {
  36. save(state, action) {
  37. return {
  38. ...state,
  39. data: action.payload,
  40. };
  41. },
  42. },
  43. };