husq
2023-10-16 4c7c5b721be0c61b7de5d19f0b0007b5aeb825c5
src/components/g-map/use-drone-control-ws-event.ts
@@ -1,8 +1,8 @@
import {message, notification} from 'ant-design-vue'
import {onBeforeUnmount, onMounted, ref} from 'vue'
import { message, notification } from 'ant-design-vue'
import { onBeforeUnmount, onMounted, ref } from 'vue'
import EventBus from '/@/event-bus/'
import {EBizCode, EBizCodeMessage} from '/@/types'
import {ControlSource} from '/@/types/device'
import { EBizCode, EBizCodeMessage } from '/@/types'
import { ControlSource } from '/@/types/device'
import {
  ControlSourceChangeInfo,
  ControlSourceChangeType,
@@ -11,9 +11,10 @@
  FlyToPointMessage,
  TakeoffToPointMessage
} from '/@/types/drone-control'
import { useMyStore } from '/@/store'
export interface UseDroneControlWsEventParams {
}
const store = useMyStore()
export function useDroneControlWsEvent (sn: string, payloadSn: string, funcs?: UseDroneControlWsEventParams) {
  const droneControlSource = ref(ControlSource.A)
@@ -21,7 +22,8 @@
  function onControlSourceChange (data: ControlSourceChangeInfo) {
    if (data.type === ControlSourceChangeType.Flight && data.sn === sn) {
      droneControlSource.value = data.control_source
      message.info(`飞行控制改为 ${droneControlSource.value}`)
      store.commit('SET_DRONE_CONTROL_SOURCE', droneControlSource.value)
      // message.info(`飞行控制改为 ${droneControlSource.value}`)
      return
    }
    if (data.type === ControlSourceChangeType.Payload && data.sn === payloadSn) {
@@ -88,6 +90,7 @@
  }
  onMounted(() => {
    console.log('弹窗初始化触发?')
    EventBus.on('droneControlWs', handleDroneControlWsEvent)
  })