forked from drone/command-center-dashboard

chenyao
2025-04-14 b0ccd2d131b2e3df5d901385e38ed0077b8d0fbc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { EDeviceTypeName } from '@/utils/staticData/enums'
import { getStore, setStore } from '@/utils/store'
 
const home = {
  state: {
    machineNestDetail: false, // 机巢长列表
        isEventOverviewDetail: false,//是事件概述详情
        // 用户行政区划中心点
        userAreaPosition: getStore({ name: 'userAreaPosition' }) || {},
        // 用户切换后行政区划中心点
        currentAreaPosition:getStore({ name: 'currentAreaPosition' }) || {},
    singleUavHome: {},
        footActiveIndex: 0,
    singleTotal: {}, // 统计单个机巢数据
    // 项目id
    selectedWorkSpaceId: window.localStorage.getItem('bs_workspace_id'),
    wsMessage: {},
    deviceState: {
      gatewayInfo: {},
      deviceInfo: {},
      timestamp: '',
      dockInfo: {},
      currentSn: '',
      currentType: -1,
      drone_charge_state_new: {},
      psdk_widget_values: {},
      speakerAudioPlayStartProgress: {},
    },
    osdVisible: {
      // osd 显示设备相关信息
      sn: '',
      callsign: '',
      model: '',
      visible: false,
      gateway_sn: '',
      is_dock: false,
      payloads: null,
      device_domain: '',
      device_sub_type: '',
      device_type: '',
    },
  },
  actions: {},
  mutations: {
        setUserAreaPosition: (state, data) => {
            setStore({ name: 'userAreaPosition', content: data })
            state.userAreaPosition = data;
        },
        setCurrentAreaPosition: (state, data) => {
            setStore({ name: 'currentAreaPosition', content: data })
            state.currentAreaPosition = data;
        },
        setFootActiveIndex: (state, index) => {
            state.footActiveIndex = index;
            state.isEventOverviewDetail = false
            state.singleUavHome = {}
            state.machineNestDetail = false
        },
        setIsEventOverviewDetail: (state, data) => {
            state.isEventOverviewDetail = data;
        },
    setMachineNestDetail: (state, data) => {
      state.machineNestDetail = data;
    },
    setSingleUavHome: (state, data) => {
      state.singleUavHome = data;
    },
    setSingleTotal: (state, data) => {
      state.singleTotal = data;
    },
    setSelectedWorkSpaceId: (state, id) => {
      state.selectedWorkSpaceId = id
      window.localStorage.setItem('bs_workspace_id', id)
    },
    setOsdVisibleInfo: (state, info) => {
      state.osdVisible = Object.assign({}, info)
      window.localStorage.setItem('bs_osd', JSON.stringify(info))
    },
    setWsMessage: (state, data) => {
      state.wsMessage = data.data.host;
    },
    setDeviceInfo: (state, data) => {
      const info = data.data
      state.deviceState.timestamp = data.timestamp
      state.deviceState.deviceInfo[info.sn] = info.host
      state.deviceState.currentSn = info.sn
      state.deviceState.currentType = EDeviceTypeName.Aircraft
    },
    setGatewayInfo: (state, info) => {
      state.deviceState.gatewayInfo[info.sn] = info.host
      state.deviceState.currentSn = info.sn
      state.deviceState.currentType = EDeviceTypeName.Gateway
    },
    setDockOnfo: (state, info) => {
      if (Object.keys(info.host).length === 0) return
 
            if (!state.deviceState.dockInfo[info.sn]) {
                state.deviceState.dockInfo[info.sn] = {}
            }
            state.deviceState.currentSn = info.sn
            state.deviceState.currentType = EDeviceTypeName.Dock
            const dock = state.deviceState.dockInfo[info.sn]
            if (info.host.mode_code !== undefined) {
                dock.basic_osd = info.host
                state.deviceState.drone_charge_state_new = dock.basic_osd.drone_charge_state
                return
            }
            if (info.host.sdr) {
                dock.link_osd = info.host
                return
            }
            if (info.host.job_number !== undefined) {
                dock.work_osd = info.host
            }
        },
    },
    getters: {
        test(state) {
            return state.singleUavHome.id.toString() + '65'
        },
    },
}
 
export default home