Z1user.ts 551 B

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