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 |   83 +++++++++++------------------------------
 1 files changed, 23 insertions(+), 60 deletions(-)

diff --git a/src/views/screen/flow/graphic/index.vue b/src/views/screen/flow/graphic/index.vue
index 621d13b..8fce991 100644
--- a/src/views/screen/flow/graphic/index.vue
+++ b/src/views/screen/flow/graphic/index.vue
@@ -1,11 +1,11 @@
 <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, useRouter} from "vue-router";
-import FullScreenVideo from "./components/FullScreenVideo.vue";
+import VideoPlayer from "@/components/VideoPlayer/VideoPlayer.vue";
+import html2canvas from 'html2canvas';
 
 const route = useRoute();
 const router = useRouter();
@@ -14,26 +14,28 @@
 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);
+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()
 }
 
 // 获取监控点菜单
@@ -45,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>
 
@@ -149,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">
@@ -197,11 +165,6 @@
                 </div>
             </div>
         </div>
-        <FullScreenVideo
-            v-if="hasFullScreen"
-            :data="playerData[fullIndex]"
-            @close="closeFullScreen"
-        />
     </div>
 </template>
 
@@ -301,7 +264,7 @@
                         color: #fff;
                     }
 
-                    .videoBox {
+                    .item-video {
                         width: 100%;
                         height: 60%;
                         background-color: #000;

--
Gitblit v1.9.3