A1list.ts 465 B

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