From 9f4609f4822222632ab2fcf85d58b0b4b8459160 Mon Sep 17 00:00:00 2001 From: web <candymxq888@outlook.com> Date: 星期一, 26 五月 2025 17:30:33 +0800 Subject: [PATCH] fix:修改播放⑦ --- src/views/screen/flow/graphic/index.vue | 123 +++++++++++++++------------------------- 1 files changed, 47 insertions(+), 76 deletions(-) diff --git a/src/views/screen/flow/graphic/index.vue b/src/views/screen/flow/graphic/index.vue index d208ed6..8fce991 100644 --- a/src/views/screen/flow/graphic/index.vue +++ b/src/views/screen/flow/graphic/index.vue @@ -1,38 +1,41 @@ <script setup> -import {onMounted, ref, onUnmounted} from "vue"; +import {onMounted, ref} from "vue"; import {getUserType} from '@/utils/auth.js' import {getFlowPointList} from '@/api/screen/index' import {getFlowVideoData} from '@/api/screen/graphic/index.js' -import EZUIKit from 'ezuikit-js'; -import {useRoute} from "vue-router"; -import FullScreenVideo from "./components/FullScreenVideo.vue"; +import {useRoute, useRouter} from "vue-router"; +import VideoPlayer from "@/components/VideoPlayer/VideoPlayer.vue"; +import html2canvas from 'html2canvas'; const route = useRoute(); +const router = useRouter(); const menuList = ref([]) const userType = ref(getUserType()) const searchVal = ref('') const playerData = ref([]) -const hasFullScreen = ref(false) -const fullIndex = ref() -let ezKitList = []; //视频组件实例数组 -let ezKitId = []; //视频盒子id数组 -let timer = null; // 全屏弹窗 const handleFullScreen = (index) => { - fullIndex.value = index; - hasFullScreen.value = true; -} - -// 关闭全屏弹窗 -const closeFullScreen = () => { - hasFullScreen.value = false; + const dom = document.getElementById(`player${index}`) + dom.requestFullscreen() } // 抓拍 -const handleSnap = (index) => { - ezKitList[index].capturePicture(`capture-${new Date().getTime()}`, 0.8); // 参数:回调函数,图片格式,质量(0-1) +const handleSnap = async (index) => { + const dom = document.getElementById(`player${index}`) + const canvas = await html2canvas(dom, { + backgroundColor: null, // 透明背景 + scale: 2, // 提高分辨率 + logging: false, // 关闭日志 + useCORS: true, // 允许跨域图片 + allowTaint: true, // 允许污染图片 + }); + const imgUrl = canvas.toDataURL('image/png'); + const adom = document.createElement("a"); + adom.download = `截图_${new Date().getTime()}.png` + adom.href = imgUrl; + adom.click() } // 获取监控点菜单 @@ -44,63 +47,27 @@ // 选择菜单 const handleSelect = (id) => { - ezKitList = [] - ezKitId = [] playerData.value = [] - clearInterval(timer) getPlayerList(id) } // 搜索 const handleSearch = () => { - ezKitList = [] - ezKitId = [] playerData.value = [] - clearInterval(timer) getPlayerList() } // 获取监控点 const getPlayerList = async (id) => { getFlowVideoData({pointId: id, pointName: searchVal.value}).then(async res => { - res.data.forEach((item, index) => { - ezKitId[index] = `ezuikitPlayer${index}` - }) playerData.value = res.data - await nextTick() - - // 渲染视频 - res.data.forEach((item, index) => { - ezKitList[index] = new EZUIKit.EZUIKitPlayer({ - id: ezKitId[index], - url: item.url, - accessToken: item.accessToken, - }) - }) }) - - // 挂载定时器, 只获取数据,不重新渲染视频节点 - timer = setInterval(() => { - getFlowVideoData({pointId: id, pointName: searchVal.value}).then(res => { - playerData.value = res.data - }) - }, 10000) } onMounted(() => { getMoitorList() getPlayerList(route.params.id || '') -}) - -onUnmounted(() => { - if (timer) { - clearInterval(timer) - } - // 停止播放 - ezKitList?.forEach(item => { - item.stop(); - }) }) </script> @@ -136,7 +103,7 @@ </el-icon> 搜索 </el-button> - <el-button style="margin-left: 0" v-if="userType === '1'"> + <el-button style="margin-left: 0" v-if="userType === '1'" @click="router.push('/monitorList')"> <el-icon> <Plus/> </el-icon> @@ -148,7 +115,9 @@ <div class="monitor-list"> <div class="item" v-for="(item, index) in playerData" :key="index"> <div class="title">{{ item.pointName }}</div> - <div class="videoBox" :id="ezKitId[index]"></div> + <div class="item-video" :id="`player${index}`"> + <VideoPlayer :item="item" :autoPlay="true" /> + </div> <div class="info"> <div class="info-list"> <div class="info-item"> @@ -156,28 +125,36 @@ <div class="val"><span>{{ item.waterLevel }}</span>m</div> </div> <div class="info-item"> - <div class="name">流速:</div> + <div class="name">表面流速:</div> <div class="val"><span>{{ item.flowVelocity }}</span>m/s</div> - </div> - <div class="info-item"> - <div class="name">瞬时流量:</div> - <div class="val"><span>{{ item.newFlow }}</span>m³/h</div> - </div> - <div class="info-item"> - <div class="name">累计流量:</div> - <div class="val"><span>{{ item.totalFlow }}</span>m³</div> </div> <div class="info-item"> <div class="name">水面宽度:</div> <div class="val"><span>{{ item.waterWidth }}</span>m</div> </div> <div class="info-item"> + <div class="name">平均流速:</div> + <div class="val"><span>{{ item.avgVelocity }}</span>m/s</div> + </div> + <div class="info-item"> <div class="name">过水面积:</div> <div class="val"><span>{{ item.waterArea }}</span>m³</div> </div> + <div class="info-item"> + <div class="name">雷达流速:</div> + <div class="val"><span>{{ item.radarVelocity }}</span>m/s</div> + </div> + <div class="info-item"> + <div class="name">实时流量:</div> + <div class="val"><span>{{ item.newFlow }}</span>m³/h</div> + </div> + <div class="info-item"> + <div class="name">起点距:</div> + <div class="val"><span>{{ item.radarDistance }}</span>m</div> + </div> </div> <div class="info-btn"> - <div class="fullScreen" @click="handleFullScreen(index)"> + <div class="fullScreen" v-if="item.url" @click="handleFullScreen(index)"> <img src="@/assets/images/flow/screenIconWhite.png" alt="" /> 全屏 </div> @@ -188,11 +165,6 @@ </div> </div> </div> - <FullScreenVideo - v-if="hasFullScreen" - :data="playerData[fullIndex]" - @close="closeFullScreen" - /> </div> </template> @@ -292,7 +264,7 @@ color: #fff; } - .videoBox { + .item-video { width: 100%; height: 60%; background-color: #000; @@ -339,15 +311,14 @@ .info-btn { width: 15%; padding: 1rem 0; - display: flex; - align-items: flex-end; - flex-direction: column; - justify-content: space-between; + position: relative; :deep(.el-button) { color: #fff; background: rgba(94, 229, 92, 0.6); border-radius: 4px 4px 4px 4px; border: 1px solid rgba(94, 229, 92, 0.6); + position: absolute; + bottom: 1rem; } .fullScreen{ width: 100%; -- Gitblit v1.9.3