From 9816d2c27a8b986ffbf640c8737e902849ff45e7 Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Mon, 14 Apr 2025 17:01:33 +0800
Subject: [PATCH] feat:修复视频监控

---
 src/views/SignMachineNest/MachineRight/MachineMonitor.vue |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/src/views/SignMachineNest/MachineRight/MachineMonitor.vue b/src/views/SignMachineNest/MachineRight/MachineMonitor.vue
index 5c8d29e..d8ca2db 100644
--- a/src/views/SignMachineNest/MachineRight/MachineMonitor.vue
+++ b/src/views/SignMachineNest/MachineRight/MachineMonitor.vue
@@ -1,6 +1,6 @@
 <!-- 机巢监控 -->
 <template>
-  <CommonTitle title="机巢监控" />
+  <CommonTitle title="视频监控" />
   <div :style="{ marginLeft: pxToRem(14) }">
     <div class="machine-monitor">
       <LiveVideo :videoUrl="airPortUrl" />
@@ -22,14 +22,43 @@
 // 直播地址
 let airPortUrl = ref('');
 // 获取直播地址
-const getVideoUrl = () => {
-  liveStart(singleUavHome.value.device_sn).then(res => {
+const getVideoUrl = (sn,quality) => {
+  liveStart(sn, quality).then(res => {
     if (res.data.code !== 0) return;
     airPortUrl.value = res.data.data.rtcs_url;
   });
 };
+let isCurrentSn = ref(false);
+let CurrentSn = ref('');
+// 监听ws消息
+watch(
+  () => store.state.home.deviceState.deviceInfo,
+  (newValue) => {
+    CurrentSn.value = Object.keys(newValue)[0];
+    const currentDevice = newValue[CurrentSn.value];
+    if (currentDevice.mode_code > 0) {
+      isCurrentSn.value = true;
+    } else if (currentDevice.mode_code === 14) {
+      isCurrentSn.value = false;
+    } else {
+      isCurrentSn.value = false;
+    }
+  },
+  {
+    immediate: true,
+    deep: true,
+  }
+);
+// 监听 isCurrentSn
+watch(isCurrentSn, (newVal) => {
+  if (newVal) {
+    getVideoUrl(CurrentSn.value, 2);
+  } else {
+    getVideoUrl(singleUavHome.value.device_sn,1);
+  }
+}, { immediate: true,deep: true });
 onMounted(() => {
-  getVideoUrl();
+  getVideoUrl(singleUavHome.value.device_sn,1);
 });
 </script>
 

--
Gitblit v1.9.3