import { MessageType } from "@/utils/message";

// 初始化状态
const initState = {
  // antd轻提示(兼容360浏览器)
  message: {
    txt: "",
    type: "info",
    duration: 3,
  } as MessageType,
  // 所有图片点击预览查看大图
  lookBigImg: {
    url: "",
    show: false,
  },
  // 地图大图片加载是否完成
  imgLodingArr: [] as number[],
};

// 定义 action 类型
type Props =
  | { type: "layout/message"; payload: MessageType }
  | { type: "layout/lookBigImg"; payload: { url: string; show: boolean } }
  | { type: "layout/imgLoding"; payload: number[] };
// 频道 reducer
export default function loginReducer(state = initState, action: Props) {
  switch (action.type) {
    // antd轻提示(兼容360浏览器)
    case "layout/message":
      return { ...state, message: action.payload };
    // 所有图片点击预览查看大图
    case "layout/lookBigImg":
      return { ...state, lookBigImg: action.payload };
    // 大图片是否加载完成
    case "layout/imgLoding":
      return { ...state, imgLodingArr: action.payload };
    default:
      return state;
  }
}
