rain
2025-01-16 fa0045dec30afff824b1efdafeb437a7b4f21c7e
src/store/index.ts
@@ -6,8 +6,10 @@
import { LayerType } from '/@/types/mapLayer'
import { WaylineFile } from '/@/types/wayline'
import { DevicesCmdExecuteInfo } from '/@/types/device-cmd'
import createPersistedState from 'vuex-persistedstate' // 导入库
import map from './map'
import common from './common'
import user from './user'
const initStateFunc = () => ({
  Layers: [
@@ -76,7 +78,10 @@
    visible: false,
    gateway_sn: '',
    is_dock: false,
    payloads: null
    payloads: null,
    device_domain: '',
    device_sub_type: '',
    device_type: ''
  } as OSDVisible,
  waylineInfo: {
@@ -92,7 +97,13 @@
  devicesCmdExecuteInfo: {
  } as DevicesCmdExecuteInfo,
  mqttState: null as any, // mqtt 实例
  clientId: '', // mqtt 连接 唯一客户端id
  clientId: '', // mqtt 连接 唯一客户端id,
  waylineTool: {
    isShow: false as boolean,
    selectedPoint: undefined as number | undefined,
    selectedAction: undefined as any | undefined,
    kmzPath: '' as string
  }
})
export type RootStateType = ReturnType<typeof initStateFunc>
@@ -200,6 +211,15 @@
  SET_CLIENT_ID (state, clientId) {
    state.clientId = clientId
  },
  // 设置wayline中的信息
  SET_WAYLINE_INFO (state, { isShow, selectedPoint, selectedAction }) {
    isShow !== undefined && (state.waylineTool.isShow = isShow)
    state.waylineTool.selectedPoint = selectedPoint
    selectedAction !== undefined && (state.waylineTool.selectedAction = selectedAction)
  },
  SET_WAYLINE_KMZPATH (state, kmzPath) {
    state.waylineTool.kmzPath = kmzPath
  }
}
const actions: ActionTree<RootStateType, RootStateType> = {
@@ -235,7 +255,6 @@
      }
    })
    state.layerBaseInfo = obj
    console.log('state.layerBaseInfo', state.layerBaseInfo)
  },
  getLayerInfo ({ state }, id:string) {
    return state.layerBaseInfo[id]
@@ -249,8 +268,14 @@
  actions,
  modules: {
    map,
    common
    common,
    user
  },
  plugins: [createPersistedState({
    storage: window.sessionStorage,
    key: 'drone-client',
    paths: ['map', 'common', 'user'],
  })]
}
const rootStore = createStore(storeOptions)