Browse Source

增强数据校验

李富豪 1 year ago
parent
commit
cc9cf3e9d3

+ 16 - 16
Web/src/components/airport/components/InfoModal.vue

@@ -466,7 +466,7 @@ const hangarLogInfo = computed(() => {
 // 遥控器信号
 const controllerSignal = computed(() => {
   const info = props.deviceInfo?.gateway;
-  if (info && info.wireless_link) {
+  if (info?.wireless_link) {
     return info.wireless_link['4g_gnd_quality'];
   } else {
     return 0;
@@ -476,7 +476,7 @@ const controllerSignal = computed(() => {
 // 飞机信号
 const aircraftSignal = computed(() => {
   const info = props.deviceInfo?.gateway;
-  if (info && info.wireless_link) {
+  if (info?.wireless_link) {
     return info.wireless_link['4g_uav_quality'];
   } else {
     return 0;
@@ -485,7 +485,7 @@ const aircraftSignal = computed(() => {
 
 const RTK = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.position_state) {
     return info.position_state.rtk_number;
   } else {
     return 0;
@@ -494,7 +494,7 @@ const RTK = computed(() => {
 
 const GPS = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.position_state) {
     return info.position_state.gps_number;
   } else {
     return 0;
@@ -504,7 +504,7 @@ const GPS = computed(() => {
 // 电池容量
 const capacity = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.battery) {
     return info.battery.capacity_percent;
   } else {
     return 0;
@@ -513,7 +513,7 @@ const capacity = computed(() => {
 
 const windDirection = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.wind_direction) {
     return getWindDirection(info.wind_direction);
   } else {
     return '';
@@ -522,66 +522,66 @@ const windDirection = computed(() => {
 
 const windSpeed = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.wind_speed) {
     if (info.wind_speed === '--') {
       return info.wind_speed;
     } else {
       return (info.wind_speed / 10).toFixed(2) + ' m/s';
     }
   } else {
-    return '--';
+    return 0 + ' m/s';
   }
 });
 
 const ASL = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.height) {
     if (info.height === '--') {
       return info.height;
     } else {
       return info.height.toFixed(2) + ' m';
     }
   } else {
-    return '--';
+    return 0 + ' m';
   }
 });
 
 const AGL = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.elevation) {
     if (info.elevation === '--') {
       return info.elevation;
     } else {
       return info.elevation.toFixed(2) + ' m';
     }
   } else {
-    return '--';
+    return 0 + ' m';
   }
 });
 
 const HS = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.horizontal_speed) {
     if (info.horizontal_speed === '--') {
       return info.horizontal_speed;
     } else {
       return info.horizontal_speed.toFixed(2) + ' m/s';
     }
   } else {
-    return '--';
+    return 0 + ' m/s';
   }
 });
 
 const homeDistance = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.home_distance) {
     if (info.home_distance === '--') {
       return info.home_distance;
     } else {
       return info.home_distance.toFixed(2) + ' m';
     }
   } else {
-    return '--';
+    return 0 + ' m';
   }
 });
 

+ 16 - 16
Web/src/components/onLineDevice/components/InfoModal.vue

@@ -245,7 +245,7 @@ const props = withDefaults(defineProps<Props>(), {
 // 遥控器信号
 const controllerSignal = computed(() => {
   const info = props.deviceInfo?.gateway;
-  if (info && info.wireless_link) {
+  if (info?.wireless_link) {
     return info.wireless_link['4g_gnd_quality'];
   } else {
     return 0;
@@ -255,7 +255,7 @@ const controllerSignal = computed(() => {
 // 飞机信号
 const aircraftSignal = computed(() => {
   const info = props.deviceInfo?.gateway;
-  if (info && info.wireless_link) {
+  if (info?.wireless_link) {
     return info.wireless_link['4g_uav_quality'];
   } else {
     return 0;
@@ -264,7 +264,7 @@ const aircraftSignal = computed(() => {
 
 const RTK = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.position_state) {
     return info.position_state.rtk_number;
   } else {
     return 0;
@@ -273,7 +273,7 @@ const RTK = computed(() => {
 
 const GPS = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.position_state) {
     return info.position_state.gps_number;
   } else {
     return 0;
@@ -283,7 +283,7 @@ const GPS = computed(() => {
 // 电池容量
 const capacity = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.battery) {
     return info.battery.capacity_percent;
   } else {
     return 0;
@@ -292,7 +292,7 @@ const capacity = computed(() => {
 
 const windDirection = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.wind_direction) {
     return getWindDirection(info.wind_direction);
   } else {
     return '';
@@ -301,66 +301,66 @@ const windDirection = computed(() => {
 
 const windSpeed = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.wind_speed) {
     if (info.wind_speed === '--') {
       return info.wind_speed;
     } else {
       return (info.wind_speed / 10).toFixed(2) + ' m/s';
     }
   } else {
-    return '--';
+    return 0 + ' m/s';
   }
 });
 
 const ASL = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.height) {
     if (info.height === '--') {
       return info.height;
     } else {
       return info.height.toFixed(2) + ' m';
     }
   } else {
-    return '--';
+    return 0 + ' m';
   }
 });
 
 const AGL = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.elevation) {
     if (info.elevation === '--') {
       return info.elevation;
     } else {
       return info.elevation.toFixed(2) + ' m';
     }
   } else {
-    return '--';
+    return 0 + ' m';
   }
 });
 
 const HS = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.horizontal_speed) {
     if (info.horizontal_speed === '--') {
       return info.horizontal_speed;
     } else {
       return info.horizontal_speed.toFixed(2) + ' m/s';
     }
   } else {
-    return '--';
+    return 0 + ' m/s';
   }
 });
 
 const homeDistance = computed(() => {
   const info = props.deviceInfo?.device;
-  if (info) {
+  if (info?.home_distance) {
     if (info.home_distance === '--') {
       return info.home_distance;
     } else {
       return info.home_distance.toFixed(2) + ' m';
     }
   } else {
-    return '--';
+    return 0 + ' m';
   }
 });
 

+ 1 - 1
Web/src/hooks/use-g-map-tsa.ts

@@ -55,8 +55,8 @@ export function deviceTsaUpdate() {
         anchor: 'top-center',
         offset: [0, -20],
       })
+      root.$map.add(markers[sn])
     }
-    root.$map.add(markers[sn])
   }
 
   const removeDeviceMarker = (sn: string) => {