A1List.ts 537 B

123456789101112131415161718192021222324252627
  1. import { A1tableType } from "@/types";
  2. // 初始化状态
  3. const initState = {
  4. // 列表数据
  5. tableInfo: {
  6. list: [] as A1tableType[],
  7. total: 0,
  8. },
  9. };
  10. // 定义 action 类型
  11. type Props = {
  12. type: "A1/getList";
  13. payload: { list: A1tableType[]; total: number };
  14. };
  15. // 频道 reducer
  16. export default function reducerFu(state = initState, action: Props) {
  17. switch (action.type) {
  18. // 获取列表数据
  19. case "A1/getList":
  20. return { ...state, tableInfo: action.payload };
  21. default:
  22. return state;
  23. }
  24. }