user.ts 597 B

12345678910111213141516171819202122232425262728293031
  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 UserActionType =
  12. | {
  13. type: "user/getList";
  14. payload: { list: UserTableListType[]; total: number };
  15. }
  16. // 频道 reducer
  17. export default function userReducer(state = initState, action: UserActionType) {
  18. switch (action.type) {
  19. // 获取列表数据
  20. case "user/getList":
  21. return { ...state, tableInfo: action.payload };
  22. default:
  23. return state;
  24. }
  25. }