| | |
| | | <!-- 机巢监控 --> |
| | | <template> |
| | | <CommonTitle title="机巢监控" /> |
| | | <CommonTitle title="视频监控" /> |
| | | <div :style="{ marginLeft: pxToRem(14) }"> |
| | | <div class="machine-monitor"> |
| | | <LiveVideo :videoUrl="airPortUrl" /> |
| | |
| | | // 直播地址 |
| | | 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> |
| | | |