From 32fe6e21781de5ff3218ffe71454a023c56ef50e Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Fri, 28 Feb 2025 12:44:19 +0800
Subject: [PATCH] 航线和视频 飞完立即清除

---
 src/views/hooks/test.json       |  293 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/views/DronePilotDetails.vue |   25 +++-
 src/views/hooks/droneFly.ts     |   12 +
 3 files changed, 320 insertions(+), 10 deletions(-)

diff --git a/src/views/DronePilotDetails.vue b/src/views/DronePilotDetails.vue
index bd1e781..a0701a2 100644
--- a/src/views/DronePilotDetails.vue
+++ b/src/views/DronePilotDetails.vue
@@ -7,11 +7,11 @@
     />
     <div id="landscapeBox" class="landscape-box" :style="{ width: boxWidth + 'px', height: boxHeight + 'px'}">
       <div id="videoModule" class="l-video" :style="{ width: screenWidthVideo + 'px', height: (screenHeightVideo) + 'px'}">
-        <video v-show="videoUrl && droneInfo.mode_code != 14" ref="videoPlayerBig" :style="{ width: screenWidthVideo + 'px', height: screenHeightVideo + 'px'}" controls autoplay muted playsinline style="text-align: left; object-fit: fill">
+        <video v-show="videoUrl" ref="videoPlayerBig" :style="{ width: screenWidthVideo + 'px', height: screenHeightVideo + 'px'}" controls autoplay muted playsinline style="text-align: left; object-fit: fill">
           Your browser is too old which doesn't support HTML5 video.
         </video>
-        <el-empty v-show="videoUrl == ''&& droneInfo.mode_code == 14" description="当前设备已关机,无法进行直播" :image="imageUrl"></el-empty>
-        <div v-if="videoUrl && droneInfo.mode_code != 14" class="center-point"></div>
+        <el-empty v-show="videoUrl == ''" description="当前设备已关机,无法进行直播" :image="imageUrl"></el-empty>
+        <div v-if="videoUrl" class="center-point"></div>
         <div class="right-box">
           <ptzControl :sn="sn" :osdVisible="sbInfo"/>
           <controlConsole :sn="sn" :osdVisible="sbInfo" :cesiumViewe="globalViewer" />
@@ -287,7 +287,7 @@
 }
 
 // 无人机相关信息
-const droneInfo = ref({})
+// const droneInfo = ref({})
 
 // 监听ws
 const messageHandler = async (payload: any) => {
@@ -299,16 +299,26 @@
       store.commit('SET_GATEWAY_INFO', payload.data)
       break
     }
-    case EBizCode.DeviceOsd: {
+    case EBizCode.DeviceOsd: { // 无人机的
       store.commit('SET_DEVICE_INFO', payload.data)
       store.commit('SET_WS_MESSAGE', payload)
       // console.log('对对对', payload.data.host.mode_code)
-      droneInfo.value = payload.data.host
+      // droneInfo.value = payload.data.host
+      // if (!payload.data.host || payload.data.host.mode_code == 14) {
+      //   videoUrl.value = ''
+      // }
       getviewDrone(payload)
       break
     }
     case EBizCode.DockOsd: { // 机场
       store.commit('SET_DOCK_INFO', payload.data)
+      break
+    }
+    case EBizCode.DeviceOffline: {
+      store.commit('SET_DEVICE_OFFLINE', payload.data)
+      if (!payload.data.online_status) {
+        videoUrl.value = ''
+      }
       break
     }
     case EBizCode.FlightTaskProgress: { // 获取进度
@@ -578,6 +588,9 @@
 onBeforeUnmount(() => {
   window.removeEventListener('orientationchange', checkOrientation);
   window.removeEventListener('resize', checkOrientation);
+
+  // removeAllPoint()
+  // removeAllDataSource()
   // 销毁地图实例
   if (window.cesiumViewer && !window.cesiumViewer.isDestroyed()) {
     window.cesiumViewer.destroy();
diff --git a/src/views/hooks/droneFly.ts b/src/views/hooks/droneFly.ts
index f75d3b7..fd03248 100644
--- a/src/views/hooks/droneFly.ts
+++ b/src/views/hooks/droneFly.ts
@@ -7,7 +7,7 @@
 import { useMyStore } from '@/store'
 import { getTwoPointInfo } from '@/api/manage'
 
-const { getEntityById, removeById, globalCesium, addLeftClickEvent, removeLeftClickEvent, flyTo } = cesiumOperation()
+const { getEntityById, removeById, globalCesium, removeAllPoint, addLeftClickEvent, removeLeftClickEvent, flyTo } = cesiumOperation()
 // 无人机实体
 let droneEntity = null
 
@@ -63,7 +63,7 @@
       // 当飞机模型存在
       if (droneEntity) {
         //  且在空中飞行时,实时更新飞机模型的位置
-        if (deviceInfo.mode_code && [3, 4, 5, 9, 10, 16].includes(deviceInfo.mode_code)) {
+        if (deviceInfo.mode_code && [3, 4, 5, 9, 10, 16, 17].includes(deviceInfo.mode_code)) {
           if (store.currentAngle == 3) {
             viewInfoFrustum?.clear()
           } else {
@@ -96,6 +96,9 @@
         } else {
           removeById('drone_fly')
           droneEntity = null
+
+          removeById('me_dw')
+          myAppEntity = null
   
           lastTime = null
           viewInfoFrustum?.clear()
@@ -103,9 +106,10 @@
   
           window.cesiumViewer.camera.lookAtTransform(globalCesium.Matrix4.IDENTITY)
           store.commit('SET_CURRENTANGLE', 1)
+          removeAllPoint()
         }
       } else {
-        if (deviceInfo.mode_code && [3, 4, 5, 9, 10].includes(deviceInfo.mode_code)) {
+        if (deviceInfo.mode_code && [3, 4, 5, 9, 10, 17].includes(deviceInfo.mode_code)) {
           // 暂时把视锥代码注释掉
           initCreateFrustum(deviceInfo, viewDroneInfo)
           addFlyGltf(
@@ -146,7 +150,7 @@
         })
       }
       
-      if (data.deviceInfo[data.currentSn].mode_code && [3, 4, 5, 9, 10].includes(deviceInfo.mode_code)) {
+      if (data.deviceInfo[data.currentSn].mode_code && [3, 4, 5, 9, 10, 17].includes(deviceInfo.mode_code)) {
         if (switchSaving) return (switchSaving = false)
         const newPositions = globalCesium.Cartesian3.fromDegrees(
           data.deviceInfo[data.currentSn].longitude,
diff --git a/src/views/hooks/test.json b/src/views/hooks/test.json
new file mode 100644
index 0000000..a89ab3b
--- /dev/null
+++ b/src/views/hooks/test.json
@@ -0,0 +1,293 @@
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.10000228881836,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624647955787974,
+      "measure_target_longitude": 115.85635808986208,
+      "measure_target_error_state": 0
+  }
+]
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.10000228881836,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624647955787974,
+      "measure_target_longitude": 115.85635808986208,
+      "measure_target_error_state": 0
+  }
+]
+{
+  "host": {
+      "attitude_head": 124.7,
+      "attitude_pitch": 0,
+      "attitude_roll": 0.3,
+      "elevation": 0,
+      "battery": {
+          "batteries": [
+              {
+                  "firmware_version": "29.02.01.41",
+                  "index": 0,
+                  "loop_times": 1,
+                  "capacity_percent": 50,
+                  "sn": "7PAPMCSCA001JU",
+                  "sub_type": 0,
+                  "temperature": 24.9,
+                  "type": 0,
+                  "voltage": 15050
+              }
+          ],
+          "capacity_percent": 50,
+          "landing_power": 0,
+          "remain_flight_time": 0,
+          "return_home_power": 0
+      },
+      "firmware_version": "12.00.0106",
+      "gear": 1,
+      "height": 63.10512161254883,
+      "home_distance": 0.653381109237671,
+      "horizontal_speed": 0,
+      "latitude": 28.624682953335515,
+      "longitude": 115.85630050035225,
+      "mode_code": 0,
+      "total_flight_distance": 6016.419651580858,
+      "total_flight_time": 0,
+      "vertical_speed": 0,
+      "wind_direction": 0,
+      "wind_speed": 0,
+      "position_state": {
+          "gps_number": 32,
+          "is_fixed": 0,
+          "quality": 5,
+          "rtk_number": 46
+      },
+      "payloads": [
+          {
+              "payload_index": "88-0-0",
+              "gimbal_pitch": 0,
+              "gimbal_roll": 0,
+              "gimbal_yaw": 129.3,
+              "measure_target_altitude": 63.10000228881836,
+              "measure_target_distance": 6.800000190734863,
+              "measure_target_latitude": 28.624647955787974,
+              "measure_target_longitude": 115.85635808986208,
+              "measure_target_error_state": 0
+          }
+      ],
+      "storage": {
+          "total": 60382000,
+          "used": 27000
+      },
+      "night_lights_state": 0,
+      "height_limit": 120,
+      "distance_limit_status": {
+          "state": 0,
+          "distance_limit": 5000
+      },
+      "obstacle_avoidance": {
+          "horizon": 1,
+          "upside": 0,
+          "downside": 1
+      },
+      "activation_time": 1738959793,
+      "cameras": [
+          {
+              "camera_mode": 0,
+              "liveview_world_region": {
+                  "bottom": 0.556653380393982,
+                  "left": 0.43964454531669617,
+                  "right": 0.565058410167694,
+                  "top": 0.431435763835907
+              },
+              "payload_index": "88-0-0",
+              "photo_state": 0,
+              "record_time": 0,
+              "recording_state": 0,
+              "remain_photo_num": 9503,
+              "remain_record_duration": 0,
+              "zoom_factor": 7
+          }
+      ],
+      "rc_lost_action": 2,
+      "rth_altitude": 120,
+      "total_flight_sorties": 0,
+      "exit_wayline_when_rc_lost": 0,
+      "track_id": ""
+  },
+  "sn": "1581F7FVC251800C5W24"
+}
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.10000228881836,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.62464794726932,
+      "measure_target_longitude": 115.85635819107856,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.10000228881836,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.62464794726932,
+      "measure_target_longitude": 115.85635819107856,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.10000228881836,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624647947124036,
+      "measure_target_longitude": 115.85635819620202,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.10000228881836,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624647947124036,
+      "measure_target_longitude": 115.85635819620202,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.10000228881836,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624648145304633,
+      "measure_target_longitude": 115.85635829380271,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.10000228881836,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624648145304633,
+      "measure_target_longitude": 115.85635829380271,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.10000228881836,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624648234306836,
+      "measure_target_longitude": 115.85635818486095,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.20000076293945,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624648344714267,
+      "measure_target_longitude": 115.85635829084707,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.20000076293945,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624648344714267,
+      "measure_target_longitude": 115.85635829084707,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.4000015258789,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624647746962893,
+      "measure_target_longitude": 115.8563580886594,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.3,
+      "measure_target_altitude": 63.4000015258789,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624647746962893,
+      "measure_target_longitude": 115.8563580886594,
+      "measure_target_error_state": 0
+  }
+]
+
+[
+  {
+      "payload_index": "88-0-0",
+      "gimbal_pitch": 0,
+      "gimbal_roll": 0,
+      "gimbal_yaw": 129.2,
+      "measure_target_altitude": 63.5,
+      "measure_target_distance": 6.800000190734863,
+      "measure_target_latitude": 28.624648387113627,
+      "measure_target_longitude": 115.85635872364763,
+      "measure_target_error_state": 0
+  }
+]
\ No newline at end of file

--
Gitblit v1.9.3