You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
2 years ago
|
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('Fly to')
|
||
|
}
|
||
|
}
|
||
|
|
||
|
async function stopFlyToPoint (sn: string) {
|
||
|
const { code } = await deleteFlyToPoint(sn)
|
||
|
if (code === 0) {
|
||
|
message.success('Stop fly to')
|
||
|
}
|
||
|
}
|
||
|
|
||
|
async function takeoffToPoint (sn: string, body: PostTakeoffToPointBody) {
|
||
|
const { code } = await postTakeoffToPoint(sn, body)
|
||
|
if (code === 0) {
|
||
|
message.success('Take off successfully')
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
droneControlPanelVisible,
|
||
|
setDroneControlPanelVisible,
|
||
|
flyToPoint,
|
||
|
stopFlyToPoint,
|
||
|
takeoffToPoint
|
||
|
}
|
||
|
}
|