chenyao
2025-02-26 31b7e874bac09e8a82c938c75e36452580dfddd6
src/views/components/controlConsole.vue
@@ -15,25 +15,12 @@
      <div class="bottom" @touchstart="handlePublish({ h: -HEIGHT })"><div class="xx">下降</div></div>
      <div class="right" @touchstart="handlePublish({ w: W_SPEED })" ><div class="xy">右转</div></div>
    </div>
    <el-dialog
      v-model="dialogVisible"
      title="提示"
      width="500">
      <span>确认是否接管?</span>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="dialogVisible = false">取消</el-button>
          <el-button type="primary" @click="sureJg">
            确定
          </el-button>
        </div>
      </template>
    </el-dialog>
    <van-dialog v-model:show="dialogVisible" title="确认是否接管?" show-cancel-button @confirm="sureJg"></van-dialog>
  </div>
</template>
<script lang="ts" setup>
import { ElMessage, ElMessageBox } from 'element-plus'
import { showNotify } from 'vant';
import { ref, onMounted, onBeforeUnmount, nextTick, reactive, computed, watch } from 'vue';
import { useMyStore } from '@/store'
import {exitController,droneController,returnHomeCancel,returnHome} from '@/api/drone/drc'
@@ -86,7 +73,7 @@
// const clientId = computed(() => {
//   return localStorage.getItem('clientId') //store.state.clientId
// });
let clientId = ref(localStorage.getItem('clientId'))
let clientId = ref(localStorage.getItem('client_id'))
// {"0":"待机","1":"起飞准备","2":"起飞准备完毕","3":"手动飞行","4":"自动起飞","5":"航线飞行","6":"全景拍照","7":"智能跟随","8":"ADS-B 躲避","9":"自动返航","10":"自动降落","11":"强制降落","12":"三桨叶降落","13":"升级中","14":"未连接","15":"APAS","16":"虚拟摇杆状态","17":"指令飞行","18":"空中 RTK 收敛模式","19":"机场选址中"}
watch(() => store.state.wsMessage, (newValue, oldValue) => {
@@ -142,7 +129,7 @@
const authenticationPwd = (value:any, str:String) => {
  // 提示是否进行人工控制
  if (!isShowKzBtn.value) {
    if (!hasPermission.value) { return ElMessage.warning('暂无无人机控制权限')}
    if (!hasPermission.value) { return showNotify({ type: 'warning', message: '暂无无人机控制权限' })}
    dialogVisible.value = true
  } else {
    isShowKzBtn.value = false
@@ -176,12 +163,12 @@
const onControlsDroneSpeed = (value:Boolean) => {
  if (value) {
    if (droneSeepd.value >= 15) {
      return ElMessage.warning('无人机速度范围应处于0~15m/s之间')
      return showNotify({ type: 'warning', message: '无人机速度范围应处于0~15m/s之间' })
    }
    droneSeepd.value += 1
  } else {
    if (droneSeepd.value <= 0) {
      return ElMessage.warning('无人机速度范围应处于0~15m/s之间')
      return showNotify({ type: 'warning', message: '无人机速度范围应处于0~15m/s之间' })
    }
    droneSeepd.value -= 1
  }
@@ -190,7 +177,7 @@
const mqttHooks =  useMqtt(deviceTopicInfo)
// 字母按键
const handlePublish = (params:Object) => {
  // if (!hasPermission.value) { return ElMessage.warning('暂无无人机控制权限')}
  if (!hasPermission.value) { return showNotify({ type: 'warning', message: '暂无无人机控制权限' });}
  const body = { method: DRC_METHOD.DRONE_CONTROL, data: params}
  mqttHooks?.publishMqtt(deviceTopicInfo.pubTopic, body, {qos: 0})
}