A1Project.ts 538 B

12345678910111213141516171819202122232425262728
  1. import { A1TableType } from "@/types";
  2. // 初始化状态
  3. const initState = {
  4. // 列表数据
  5. tableInfo: {
  6. list: [] as A1TableType[],
  7. total: 2,
  8. },
  9. };
  10. // 定义 action 类型
  11. type Props = {
  12. type: "A1/getList";
  13. payload: { list: A1TableType[]; total: number };
  14. };
  15. // 频道 reducer
  16. export default function A1Reducer(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. }