From 2800fa4f32f3900509cb4d6eefaf2bfaf54efdd7 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 21 Apr 2025 18:29:09 +0800
Subject: [PATCH] fix: 天气显示
---
src/views/SignMachineNest/MachineRight/MachineMonitor.vue | 32 +++++++++++++++++++++++---------
1 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/src/views/SignMachineNest/MachineRight/MachineMonitor.vue b/src/views/SignMachineNest/MachineRight/MachineMonitor.vue
index 993dfd4..835382e 100644
--- a/src/views/SignMachineNest/MachineRight/MachineMonitor.vue
+++ b/src/views/SignMachineNest/MachineRight/MachineMonitor.vue
@@ -15,16 +15,20 @@
import CommonTitle from '@/components/CommonTitle.vue'
import LiveVideo from '@/components/LiveVideo.vue'
import { liveStart } from '@/api/home/machineNest'
-// import { CURRENT_CONFIG as config } from '@/utils/http/config'
import { useStore } from 'vuex'
const store = useStore()
// 单个机巢信息
const singleUavHome = computed(() => store.state.home.singleUavHome);
-const osdVisible = computed(() => store.state.home.osdVisible);
+const wsInfo = inject('wsInfo')
+let device_osd_info = computed(() => wsInfo.value?.device_osd || {});
+let device_osd_host = computed(() => device_osd_info?.value?.data?.host || {});
+
+const dockSn = inject('dockSn')
+const droneSn = inject('droneSn')
// 直播地址
let airPortUrl = ref('')
-// 获取直播地址
+// 获取机巢直播地址
const getVideoUrl = (sn, quality) => {
if (singleUavHome.value.status === 'OFFLINE') return;
liveStart(sn, quality).then(res => {
@@ -33,16 +37,23 @@
})
}
+// 获取无人机直播url
+async function getDroneLiveUrl(sn, quality) {
+ airPortUrl.value = ''
+ await nextTick()
+ const res = await liveStart(sn, quality)
+ airPortUrl.value = res.data.data.rtcs_url
+}
+
const isTakeOff = ref(false)
// 监听ws消息
-watch(() => store.state.home.deviceState, async (newValue) => {
- const deviceInfo = newValue?.deviceInfo[osdVisible.value.sn]
- if (!deviceInfo) return
- const currentIsTakeOff = ![14, 0].includes(deviceInfo?.mode_code)
+watch(device_osd_host, async () => {
+ if (device_osd_host?.value?.mode_code === undefined) return
+ const currentIsTakeOff = ![14, 0].includes(device_osd_host.value?.mode_code)
// 如果还是之前的状态,不切换
if (isTakeOff.value === currentIsTakeOff) return
isTakeOff.value = currentIsTakeOff
- isTakeOff.value ? await getVideoUrl(osdVisible.value.sn, 2) : await getVideoUrl(singleUavHome.value.device_sn, 1)
+ isTakeOff.value ? await getDroneLiveUrl(droneSn.value, 2) : await getVideoUrl(dockSn.value, 1)
},
{
immediate: true,
@@ -51,7 +62,10 @@
)
onMounted(() => {
- getVideoUrl(singleUavHome.value.device_sn, 1)
+ getVideoUrl(dockSn.value, 2)
+})
+onUnmounted(() => {
+ airPortUrl.value = ''
})
</script>
--
Gitblit v1.9.3