import moment from 'moment' import { getSceneDetail } from '@/api/scene' import { getToken, setToken } from '@/utils/auth' import { ICON_MODE } from '@/enum' const state = { token: getToken(), reloadKey: '', // 用于刷新路由的 key ,起到重新加载的作用 currentTime: '', // 场景当前时间 speed: null, // 场景速度 sceneInfo: null, // 场景信息 sceneId: 0, // 用户信息 userId: null, // 用户ID sceneMode: true, // 场景模式 实时 false、回放 true iconMode: ICON_MODE.SMALL, duringPlay: false, menuExpand: false, // 侧边工具栏是否展开 theme: 'light', menusChose: '2' } const mutations = { // 设置主图 SET_THEME: (state, val) => { state.theme = val }, // 设置图标模式 SET_ICON_MODE: (state, val) => { state.iconMode = val }, // 设置token SET_TOKEN: (state, val) => { state.token = val }, // 设置用于刷新路由的 key SET_RELOAD_KEY: (state, val) => { state.reloadKey = val }, // 设置场景当前时间 SET_CURRENT_TIME: (state, val) => { state.currentTime = val }, // 设置场景速度 SET_SPEED: (state, val) => { state.speed = val }, // 设置场景信息 SET_SCENE_INFO: (state, val) => { state.sceneInfo = val }, // 设置场景ID SET_SCENE_ID: (state, val) => { state.sceneId = val }, // 设置用户ID SET_USER_ID: (state, val) => { state.userId = val }, // 设置场景模式 SET_SCENE_MODE: (state, val) => { state.sceneMode = val }, SET_DURING_PLAY: (state, val) => { state.duringPlay = val }, SET_MENU_EXPAND: (state, val) => { state.menuExpand = val }, SET_MENUS_CHOSE: (state, val) => { state.menusChose = val } } const actions = { /** * 刷新页面 * @author wangxueshen * @date 2022-05-09 * @param {any} {commit * @param {any} state} * @returns {any} */ reload({ commit }) { commit('SET_RELOAD_KEY', new Date().getTime()) } } export default { namespaced: true, state, mutations, actions }