import { A0listType, A0Ttype } from '@/pages/A0home/data'

// 初始化状态
const initState = {
  // 通知数据
  Tinfo: {} as A0Ttype,
  // 列表数据
  imgList: [] as A0listType[]
}

// 定义 action 类型
type Props =
  | {
      type: 'A0/getTinfo'
      payload: A0Ttype
    }
  | {
      type: 'A0/getList'
      payload: A0listType[]
    }

// reducer
export default function Reducer(state = initState, action: Props) {
  switch (action.type) {
    // 获取通知数据
    case 'A0/getTinfo':
      return { ...state, Tinfo: action.payload }

    // 获取列表数据
    case 'A0/getList':
      return { ...state, imgList: action.payload }

    default:
      return state
  }
}
