From 51b785f8e18e7aab75f2dab03c1b234fae9e9358 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Tue, 10 Jun 2025 13:46:44 +0800
Subject: [PATCH] feat:视频预览

---
 src/utils/util.js                              |   10 ++
 src/views/dataCenter/dataCenter.vue            |   92 ++++++++++++++++++++++
 src/api/panorama/index.js                      |   26 ++++++
 src/components/PanoramaPopup/PanoramaPopup.vue |   59 ++++++++++++++
 src/styles/element-ui.scss                     |   39 +++++++++
 src/utils/eventBus.js                          |    5 +
 src/assets/images/dataCenter/1.jpeg            |    0 
 7 files changed, 228 insertions(+), 3 deletions(-)

diff --git a/src/api/panorama/index.js b/src/api/panorama/index.js
new file mode 100644
index 0000000..928ec9b
--- /dev/null
+++ b/src/api/panorama/index.js
@@ -0,0 +1,26 @@
+/*
+ * @Author       : yuan
+ * @Date         : 2025-06-05 09:49:42
+ * @LastEditors  : yuan
+ * @LastEditTime : 2025-06-07 18:16:57
+ * @FilePath     : \src\api\panorama\index.js
+ * @Description  : 
+ * Copyright 2025 OBKoro1, All Rights Reserved. 
+ * 2025-06-05 09:49:42
+ */
+import request from '@/axios'
+
+export const getPanoramaList = (data) => {
+	return request({
+		url: `/blade-resource/attach/mapAttachs`,
+		method: 'post',
+		data
+	})
+}
+
+export const getPanoramaDetails = (id) => {
+	return request({
+		url: `/blade-resource/attach/detail?id=${id}`,
+		method: 'get'
+	})
+}
diff --git a/src/assets/images/dataCenter/1.jpeg b/src/assets/images/dataCenter/1.jpeg
new file mode 100644
index 0000000..37d5a51
--- /dev/null
+++ b/src/assets/images/dataCenter/1.jpeg
Binary files differ
diff --git a/src/components/PanoramaPopup/PanoramaPopup.vue b/src/components/PanoramaPopup/PanoramaPopup.vue
new file mode 100644
index 0000000..bf485ff
--- /dev/null
+++ b/src/components/PanoramaPopup/PanoramaPopup.vue
@@ -0,0 +1,59 @@
+<!--
+ * @Author       : yuan
+ * @Date         : 2025-06-05 15:57:45
+ * @LastEditors  : yuan
+ * @LastEditTime : 2025-06-06 14:02:54
+ * @FilePath     : \src\components\PanoramaPopup\PanoramaPopup.vue
+ * @Description  : 
+ * Copyright 2025 OBKoro1, All Rights Reserved. 
+ * 2025-06-05 15:57:45
+-->
+<template>
+	<el-dialog
+		modal-class="showFullScreenDlg"
+		v-model="panoramaParamsShow"
+		:close-on-click-modal="false"
+		:destroy-on-close="true"
+		fullscreen
+	>
+		<iframe :src="iframeSrc" frameborder="0"></iframe>
+	</el-dialog>
+</template>
+
+<script setup>
+import { getPanoramaDetails } from '@/api/panorama/index'
+import { getShowImg } from '@/utils/util'
+
+import EventBus from '@/utils/eventBus'
+
+const panoramaParamsShow = defineModel('panoramaParamsShow', {
+	default: false,
+})
+const panoramaParamsUrl = defineModel('panoramaParamsUrl', {
+	default: '',
+})
+const iframeSrc = computed(() => {
+console.log('panoramaParamsShow',panoramaParamsShow.value ,panoramaParamsUrl.value);
+
+	if (!panoramaParamsUrl.value) return ''
+
+	return `https://wrj.shuixiongit.com/dronePanorama/html/simple-index.html?path=${getShowImg(panoramaParamsUrl.value)}`
+})
+
+const initPanorama = id => {
+	getPanoramaDetails(id).then(res => {
+		panoramaParamsUrl.value = res.data.data.link
+		panoramaParamsShow.value = true
+	})
+}
+
+onMounted(() => {
+	EventBus.on('initPanorama', initPanorama)
+})
+
+onBeforeUnmount(() => {
+	EventBus.off('initPanorama', initPanorama)
+})
+</script>
+
+<style lang="scss" scoped></style>
diff --git a/src/styles/element-ui.scss b/src/styles/element-ui.scss
index 337cc36..a9a7ece 100644
--- a/src/styles/element-ui.scss
+++ b/src/styles/element-ui.scss
@@ -60,3 +60,42 @@
 .avue--detail .el-form-item {
   background-color: #fafafa;
 }
+
+.showFullScreenDlg {
+  display: flex;
+  justify-content: space-between;
+
+  .el-dialog {
+      position: relative;
+      padding: 0;
+      overflow: hidden;
+
+      .el-dialog__body {
+          width: 100%;
+          height: 100%;
+
+          iframe {
+              width: 100%;
+              height: 100%;
+          }
+      }
+
+      .el-dialog__header {
+          height: 0;
+          overflow: hidden;
+          padding: 0;
+
+          .el-dialog__headerbtn {
+              position: absolute;
+              left: 0;
+              top: 14px;
+
+              .el-dialog__close {
+                  color: #fff;
+                  font-size: 35px;
+                  z-index: 99;
+              }
+          }
+      }
+  }
+}
\ No newline at end of file
diff --git a/src/utils/eventBus.js b/src/utils/eventBus.js
new file mode 100644
index 0000000..674e1dc
--- /dev/null
+++ b/src/utils/eventBus.js
@@ -0,0 +1,5 @@
+import mitt from 'mitt'
+
+const emitter = mitt()
+
+export default emitter
diff --git a/src/utils/util.js b/src/utils/util.js
index 94137a6..8fe922e 100644
--- a/src/utils/util.js
+++ b/src/utils/util.js
@@ -438,3 +438,13 @@
   // 设置默认范围 [上个月, 当前月]
   return [new Date(lastMonthYear, lastMonth, 1), new Date(currentYear, currentMonth, 1)]
 }
+/**
+ * 获取中等缩略图路径
+ * @param url
+ * @returns {string}
+ */
+export const getShowImg = url => {
+	if (!url) return ''
+	const lastDotIndex = url.lastIndexOf('.')
+	return `${url.substring(0, lastDotIndex)}_show${url.substring(lastDotIndex)}`
+}
\ No newline at end of file
diff --git a/src/views/dataCenter/dataCenter.vue b/src/views/dataCenter/dataCenter.vue
index 2d97ffb..185cc2f 100644
--- a/src/views/dataCenter/dataCenter.vue
+++ b/src/views/dataCenter/dataCenter.vue
@@ -17,7 +17,22 @@
         <el-table-column prop="filename" label="文件名称" />
         <el-table-column property="img" label="缩图" width="120">
           <template #default="scope">
+            <img
+              class="quanjing"
+              @click="clickpanorama(scope.row)"
+              v-if="scope.row.fileformat === '全景'"
+              :src="scope.row.img"
+              alt=""
+            />
+            <img
+              v-else-if="scope.row.fileformat === '视频'"
+              :src="convertVideoUrlToThumbnail(scope.row.img)"
+              alt=""
+              class="imageBox"
+              @click="enterFullScreen(scope.row)"
+            />
             <el-image
+              v-else
               :src="scope.row.img"
               :preview-src-list="[scope.row.img]"
               fit="cover"
@@ -98,13 +113,44 @@
         </div>
       </div>
     </el-dialog>
+    <!-- 全景预览 -->
+    <PanoramaPopup
+      v-model:panoramaParamsShow="panoramaParamsShow"
+      v-model:panoramaParamsUrl="panoramaParamsUrl"
+    ></PanoramaPopup>
+    <!-- 视频预览 -->
+    <el-dialog
+      :title="currentVideoTitle"
+      modal-class="videoDialog"
+      append-to-body
+      width="54%"
+      v-model="VideoShow"
+      :close-on-click-modal="false"
+      :destroy-on-close="true"
+      @close="currentVideoIndex = -1"
+    >
+      <div class="video-container">
+        <video style="width:100%" class="videoBox" ref="videoRefs" controls autoplay :src="currentVideoUrl"></video>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script setup>
+import PanoramaPopup from '@/components/PanoramaPopup/PanoramaPopup.vue'; //全景
 import { ElMessage, ElMessageBox } from 'element-plus';
 import searchData from '@/views/dataCenter/components/searchData.vue';
-import fy1 from '@/assets/images/workbench/fy1.png';
+import fy1 from '@/assets/images/dataCenter/1.jpeg';
+
+function convertVideoUrlToThumbnail(videoUrl) {
+  // 检查是否是有效的视频URL
+  if (!videoUrl || typeof videoUrl !== 'string') {
+    return videoUrl;
+  }
+  // 替换文件扩展名
+  const thumbnailUrl = videoUrl.replace(/\.mp4$/, '_small.jpg');
+  return thumbnailUrl;
+}
 const jobListParams = reactive({
   current: 1,
   size: 10,
@@ -128,7 +174,7 @@
     date: '2016-05-04',
     taskname: '测试任务',
     filename: '1111',
-    img: fy1,
+    img: 'https://wrj.shuixiongit.com/minio/cloud-bucket/9748effb-f27b-49c8-b57d-3e2c2ac7c03a/DJI_202506100845_010_9748effb-f27b-49c8-b57d-3e2c2ac7c03a/DJI_20250610084758_0002_V.mp4',
     timer: '2025-05-26 10:25',
     fileclass: '可见光',
     fileformat: '视频',
@@ -193,8 +239,26 @@
 };
 // 编辑文件名
 const editTitle = val => {
-  console.log('val', val);
+  // console.log('val', val);
   val.checkedinput = !val.checkedinput;
+};
+// 全景预览
+const panoramaParamsShow = ref(false);
+const panoramaParamsUrl = ref(null);
+const clickpanorama = val => {
+  panoramaParamsShow.value = true;
+  panoramaParamsUrl.value = val.img;
+  // console.log('全景', val);
+};
+// 视频
+const currentVideoTitle = ref('');
+const VideoShow = ref(false);
+const currentVideoUrl = ref(null);
+const enterFullScreen = val => {
+  currentVideoTitle.value = val.filename;
+  VideoShow.value = true;
+  currentVideoUrl.value = val.img;
+  console.log('视频', val);
 };
 </script>
 
@@ -226,6 +290,28 @@
     justify-content: end;
     margin-top: 20px;
   }
+  .quanjing,
+  .el-image,
+  .imageBox {
+    cursor: pointer;
+    width: 96px;
+    height: 72px;
+  }
+  .videoDialog :deep(.el-dialog){
+  height: 600px;
+  width: 54%;
+  }
+  .video-container {
+  width: 100%;
+  aspect-ratio: 16/9; /* 按视频比例设置(如16:9) */
+  overflow: hidden; /* 隐藏溢出部分 */
+}
+  .videoBox {
+    width: 100%;
+  height: 100%;
+  object-fit: contain; /* 保持比例完整显示 */
+  display: block;
+  }
 }
 :deep(.custom-header th.el-table__cell) {
   color: rgba(0, 0, 0, 0.85);

--
Gitblit v1.9.3