| 123456789101112131415161718192021222324252627282930313233 |
- import { RoleTableType } from "@/types";
- // 初始化状态
- const initState = {
- // 列表数据
- tableInfo: {
- list: [] as RoleTableType[],
- total: 0,
- },
- // 用户的所有 权限信息(扁平化,且过滤掉没有权限的数据)
- A4RoleAll: [] as string[],
- };
- // 定义 action 类型
- type Props =
- | { type: "Role/getList"; payload: { list: RoleTableType[]; total: number } }
- | { type: "A4RoleAll/getInfo"; payload: string[] };
- // 频道 reducer
- export default function RoleReducer(state = initState, action: Props) {
- switch (action.type) {
- // 获取列表数据
- case "Role/getList":
- return { ...state, tableInfo: action.payload };
- // 用户的所有 权限信息
- case "A4RoleAll/getInfo":
- return { ...state, A4RoleAll: action.payload };
- default:
- return state;
- }
- }
|