guoshilong
2023-11-13 54849757852f6ab40eb17afbd03d1d839b60a38d
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
import { ref } from 'vue'
import { postFlyToPoint, PostFlyToPointBody, deleteFlyToPoint, postTakeoffToPoint, PostTakeoffToPointBody } from '/@/api/drone-control/drone'
import { message } from 'ant-design-vue'
 
export function useDroneControl () {
  const droneControlPanelVisible = ref(false)
 
  function setDroneControlPanelVisible (visible: boolean) {
    droneControlPanelVisible.value = visible
  }
 
  async function flyToPoint (sn: string, body: PostFlyToPointBody) {
    const { code } = await postFlyToPoint(sn, body)
    if (code === 0) {
      message.success('飞到')
    }
  }
 
  async function stopFlyToPoint (sn: string) {
    const { code } = await deleteFlyToPoint(sn)
    if (code === 0) {
      message.success('停止飞到')
    }
  }
 
  async function takeoffToPoint (sn: string, body: PostTakeoffToPointBody) {
    const { code } = await postTakeoffToPoint(sn, body)
    if (code === 0) {
      message.success('起飞成功')
    }
  }
 
  return {
    droneControlPanelVisible,
    setDroneControlPanelVisible,
    flyToPoint,
    stopFlyToPoint,
    takeoffToPoint
  }
}