
import { useApp } from '@/app'

export default {
  namespaced: true,
  state() {
    return {
      // 菜单列表
      menuList: [],
      //是否自动旋转
      isAutoRotate: false,
      //是否展示热点列表
      isShowHotspotList: false,
      //是否显示分享链接
      showShareUrl: false,
      //是否显示场景列表
      isShowScenesList: true,
      //是否显示简介
      showIntroduce: false,
      //是否显示联系电话
      showTelephone: false,
      //是否显示自定义链接
      showLink: false,
      //是否播放背景音乐
      isBGM: false,
      //是否解说音乐
      isCommentary: false,
      //解说音乐
      commentary:null,
      //当前播放中的音频
      currentPlaying: '',
      //打断音频的来源
      pauseFrom: '',
      //当前vr状态
      vrStatus: false,

    };
  },
  getters: {
    menuList: (state) => state.menuList,
    isAutoRotate: (state) => state.isAutoRotate,
    isShowHotspotList: (state) => state.isShowHotspotList,
    isBGM: (state) => state.isBGM,
    showShareUrl: (state) => state.showShareUrl,
    isShowScenesList: (state) => state.isShowScenesList,
    showIntroduce: (state) => state.showIntroduce,
    showTelephone: (state) => state.showTelephone,
    showLink: (state) => state.showLink,
    commentary: (state) => state.commentary,
    isCommentary: (state) => state.isCommentary,
    currentPlaying: (state) => state.currentPlaying,
    pauseFrom: (state) => state.pauseFrom,
    vrStatus: (state) => state.vrStatus,
  },
  mutations: {
    setMenuList(state, payload) {
      state.list = payload;
    },

    setShareUrl(state, payload) {
      state.showShareUrl = payload;
    },

    setAutoRotate(state, payload) {
      state.isAutoRotate = payload;
      useApp().then(app => {
        if (app.krpanoDom) {
          app.krpanoDom.set("autorotate.enabled", state.isAutoRotate);
        }
      })
    },

    
    setShowHotspotList(state, payload) {
      state.isShowHotspotList = payload;
    },


    setIsBGM(state, payload) {
      state.isBGM = payload;
    },

    setIsCommentary(state, payload) {
      state.isCommentary = payload;
    },

    setShowScenesList(state, payload) {
      state.isShowScenesList = payload;
    },

    setShowIntroduce(state, payload) {
      state.showIntroduce = payload;
    },
    setShowTelephone(state, payload) {
      state.showTelephone = payload;
    },

    setShowLink(state, payload) {
      state.showLink = payload;
    },

    setCurrentPlaying(state, payload) {
      state.currentPlaying = payload;
    },

    setPauseFrom(state, payload) {
      state.pauseFrom = payload;
    },


    setCommentaryUrl(state, payload) {
      state.commentary = payload;
    },

    
    setVrStatus(state, payload) {
      state.vrStatus = payload;
    },


  },
};
