import { A3listType } from '@/pages/A3hotList/type'

export type ThreeState3dType = 'panorama' | 'dollhouse' | 'floorplan' | 'transitioning'

declare global {
  //设置全局属性
  interface Window {
    //window对象属性
    threeReact: {
      state3d: (str: ThreeState3dType) => void
    }
    player: {
      director: {
        stopTour: () => void
      }
    }
    manage: {
      switchBgmState: (val: boolean) => void
    }
    myHotList: A3listType[]
  }
}

// 初始化状态
const initState = {
  // 1.panorama 全景漫游 2.dollhouse 3D模型 3.floorplan 顶部俯视 4.transitioning 切换中
  state3d: 'transitioning' as ThreeState3dType
}

// 定义 action 类型
type ActionType = { type: 'three/state3d'; payload: ThreeState3dType }

// 频道 reducer
export default function layoutReducer(state = initState, action: ActionType) {
  switch (action.type) {
    // 当前漫游状态
    case 'three/state3d':
      return { ...state, state3d: action.payload }
    default:
      return state
  }
}
