From bdbef0fbde20317d19bfc6d3473dabb10fb3fb3b Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Sat, 19 Apr 2025 15:41:21 +0800
Subject: [PATCH] feat: 修改任务事件概况的饼状图颜色
---
src/components/CurrentTaskDetails/CurrentTaskDetails.vue | 153 +++++++++++++++++++++++++-------------------------
1 files changed, 76 insertions(+), 77 deletions(-)
diff --git a/src/components/CurrentTaskDetails/CurrentTaskDetails.vue b/src/components/CurrentTaskDetails/CurrentTaskDetails.vue
index 5d11eee..a9d4cdb 100644
--- a/src/components/CurrentTaskDetails/CurrentTaskDetails.vue
+++ b/src/components/CurrentTaskDetails/CurrentTaskDetails.vue
@@ -1,3 +1,13 @@
+<!--
+ * @Author: shuishen 1109946754@qq.com
+ * @Date: 2025-04-19 13:13:15
+ * @LastEditors: shuishen 1109946754@qq.com
+ * @LastEditTime: 2025-04-19 15:07:04
+ * @FilePath: \command-center-dashboard\src\components\CurrentTaskDetails\CurrentTaskDetails.vue
+ * @Description:
+ *
+ * Copyright (c) 2025 by shuishen, All Rights Reserved.
+-->
<!--当前任务详情-->
<template>
<el-dialog
@@ -20,7 +30,6 @@
<TaskDetailsHead />
<TaskDetailsLeft />
</template>
-
<!-- 控制面板,里面有方法需要立即执行,不可用v-if -->
<ControlPanel v-show="!isAutoControl" />
<img alt="" :src="amplifyImg" class="amplify" @click="isMaxMap = !isMaxMap" />
@@ -35,9 +44,6 @@
import { getJobDetails } from '@/api/home/task'
import RealTimeMap from '@/components/CurrentTaskDetails/RealTimeMap.vue'
-import { getWebsocketUrl } from '@/websocket/util/config'
-import { useConnectWebSocket } from '@/utils/websocket/connect-websocket'
-import { EBizCode } from '@/utils/staticData/enums'
import ControlPanel from '@/components/CurrentTaskDetails/ControlPanel/ControlPanel.vue'
import TaskDetailsHead from '@/components/CurrentTaskDetails/TaskDetailsHead.vue'
import TaskDetailsLeft from '@/components/CurrentTaskDetails/TaskDetailsLeft.vue'
@@ -46,45 +52,78 @@
import { ElMessage } from 'element-plus'
import EventBus from '@/event-bus'
import { updateDroneQualityApi } from '@/api/drc'
+import { getLiveAiLinkApi } from '@/api/payload'
+import { CURRENT_CONFIG } from '@/utils/http/config'
+import { useDroneWS } from '@/hooks/useDroneWS'
+import { useTaskDetails } from '@/hooks/useTaskDetails/useTaskDetails'
-const isAutoControl = ref(true)
+const isAutoControl = ref(true) //是否自动控制
const lineQuality = ref(1) //1流畅,2标清
-provide('isAutoControl', isAutoControl)
-provide('lineQuality', lineQuality)
-
-const taskDetailsViewer = ref(null)
-provide('taskDetailsViewer', taskDetailsViewer)
-
-let taskDetails = ref({})
-const deviceOsdInfo = ref({})
-provide('taskDetails', taskDetails)
-provide('deviceOsdInfo', deviceOsdInfo)
-
+const taskDetailsViewer = ref(null) //地图实例
+const deviceOsdInfo = computed(() => wsInfo.value?.device_osd)
const dockSn = computed(() => taskDetails?.value?.device_sns?.[0])
const droneSn = computed(() => deviceOsdInfo?.value?.data?.sn)
-provide('dockSn', dockSn)
-provide('droneSn', droneSn)
-
-const isShow = defineModel('show')
+const trueAltitude = ref('') // 真实高度
+const isAiLive = ref(false) // 是ai直播
+const video_id = ref('') // 直播视频id
+const isShow = defineModel('show') // 是否显示当前任务详情
const props = defineProps(['id'])
-const currentLiveUrl = ref('')
-const isTakeOff = ref(false)
-const isMaxMap = ref(false)
-let droneWebSocket //WS实例
+const currentLiveUrl = ref('') // 当前直播地址
+const isTakeOff = ref(false) // 是在飞行中
+const isMaxMap = ref(false) //是大地图
+const client_id = ref('') //是大地图
-// 机巢直播
+// 获取机巢直播
const getDeviceLiveUrl = async () => {
const res = await liveStart(dockSn.value, 2)
currentLiveUrl.value = res.data.data.rtcs_url
}
-const video_id = ref('')
+let { taskDetails, workspace_id, getTaskDetails } = useTaskDetails(getDeviceLiveUrl)
+let { wsInfo, removeWS } = useDroneWS(workspace_id) //ws信息,是一个ref对象
+
+provide('wsInfo', wsInfo)
+provide('deviceOsdInfo', deviceOsdInfo)
+provide('dockOsdInfo', wsInfo?.value?.dock_osd)
+provide('dockSn', dockSn)
+provide('droneSn', droneSn)
+provide('isAutoControl', isAutoControl)
+provide('lineQuality', lineQuality)
+provide('taskDetailsViewer', taskDetailsViewer)
+provide('taskDetails', taskDetails)
+provide('trueAltitude', trueAltitude)
+provide('isAiLive', isAiLive)
+provide('video_id', video_id)
+provide('client_id', client_id)
+
+watch(
+ wsInfo,
+ () => {
+ // wsInfo 变化触发
+ setCurrentLiveUrl()
+ },
+ { deep: true }
+)
+
+const getAiLiveUrl = async () => {
+ const res = await getLiveAiLinkApi({
+ original_stream_url: `${CURRENT_CONFIG.rtmpURL}${video_id.value.replace(/\//g, '-')}`,
+ video_id: video_id.value,
+ })
+ currentLiveUrl.value = res.data.data.rtcs_url
+ ElMessage.success('开启成功')
+ isAiLive.value = true
+}
// 获取无人机直播url
-async function getDroneLiveUrl() {
+async function getDroneLiveUrl(reset = false) {
+ currentLiveUrl.value = ''
+ await nextTick()
const res = await liveStart(droneSn.value, lineQuality.value)
currentLiveUrl.value = res.data.data.rtcs_url
video_id.value = res.data.data.video_id
+ isAiLive.value = false
+ reset && ElMessage.success('刷新成功')
}
// 无人机直播画质切换
@@ -95,68 +134,26 @@
// 设置当前直播地址
const setCurrentLiveUrl = async () => {
- const data = deviceOsdInfo.value?.data
- const deviceInfo = data?.host
- const currentIsTakeOff = ![14, 0].includes(deviceInfo.mode_code)
+ const deviceInfo = deviceOsdInfo.value?.data?.host
+ if (!deviceInfo) return
+ const currentIsTakeOff = ![14, 0].includes(deviceInfo?.mode_code)
// 如果还是之前的状态,不切换
if (isTakeOff.value === currentIsTakeOff) return
isTakeOff.value = currentIsTakeOff
isTakeOff.value ? await getDroneLiveUrl() : await getDeviceLiveUrl()
}
-// 获取任务详情获取航线文件
-const getTaskDetails = () => {
- if (!props.id) ElMessage.warning('请检查是否传入id')
- getJobDetails({ wayLineJobInfoId: props.id }).then(async res => {
- taskDetails.value = res.data.data
- await getDeviceLiveUrl()
- taskDetails.value.workspace_id = taskDetails.value.way_lines[0]?.workspace_id
- createWsConnect()
- })
-}
-
-// websocket 的消息回调
-const messageHandler = result => {
- let payload = JSON.parse(result)
- switch (payload.biz_code) {
- case EBizCode.DeviceOsd: {
- deviceOsdInfo.value = payload
- setCurrentLiveUrl()
- console.log(payload, 'DeviceOsd--信息')
- break
- }
- case EBizCode.GatewayOsd: {
- console.log(payload, 'GatewayOsd--信息')
- break
- }
- case EBizCode.DockOsd: {
- console.log(payload, 'GatewayOsd--信息')
- break
- }
- default:
- break
- }
-}
-
-// 创建ws连接
-const createWsConnect = () => {
- const workspaceId = taskDetails.value.workspace_id
- if (!workspaceId) return
- let webSocketUrl = getWebsocketUrl() + '&workspace-id=' + workspaceId
- // 监听ws 消息
- droneWebSocket = useConnectWebSocket(messageHandler, webSocketUrl)
-}
-
onMounted(() => {
- getTaskDetails()
+ getTaskDetails(props?.id)
EventBus.on('CurrentTaskDetails-timeStop', changeLineQuality)
+ EventBus.on('CurrentTaskDetails-getAiLiveUrl', getAiLiveUrl)
+ EventBus.on('CurrentTaskDetails-getDroneLiveUrl', getDroneLiveUrl)
})
onBeforeUnmount(() => {
- droneWebSocket?.close()
- deviceOsdInfo.value = {}
- droneWebSocket = null
EventBus.off('CurrentTaskDetails-timeStop', changeLineQuality)
+ EventBus.off('CurrentTaskDetails-getAiLiveUrl', getAiLiveUrl)
+ EventBus.off('CurrentTaskDetails-getDroneLiveUrl', getDroneLiveUrl)
})
</script>
@@ -225,6 +222,8 @@
position: absolute;
left: 340px;
bottom: 183px;
+ width: 22px;
+ height: 22px;
}
}
</style>
--
Gitblit v1.9.3