From 9f16b5c553b479ea12fe368a7ecc748872ea8b98 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期四, 12 六月 2025 11:11:27 +0800
Subject: [PATCH] 修改配置文件

---
 web_src/src/components/CloudRecord.vue |   71 ++++++++++++++++++++++++++---------
 1 files changed, 53 insertions(+), 18 deletions(-)

diff --git a/web_src/src/components/CloudRecord.vue b/web_src/src/components/CloudRecord.vue
index ca963e6..b6f0286 100755
--- a/web_src/src/components/CloudRecord.vue
+++ b/web_src/src/components/CloudRecord.vue
@@ -74,6 +74,8 @@
         <template slot-scope="scope">
           <el-button size="medium" icon="el-icon-video-play" type="text" @click="play(scope.row)">鎾斁
           </el-button>
+          <el-button size="medium" icon="el-icon-download" type="text" @click="downloadFile(scope.row)">涓嬭浇
+          </el-button>
           <!--            <el-button size="medium" icon="el-icon-delete" type="text" style="color: #f56c6c"-->
           <!--                       @click="deleteRecord(scope.row)">鍒犻櫎-->
           <!--            </el-button>-->
@@ -213,20 +215,51 @@
       console.log(row)
       this.chooseRecord = row;
       this.showPlayer = true;
-      let videoPath = row.filePath.substring(row.filePath.length - 25);
-      console.log(videoPath)
-      this.videoUrl = `${this.getFileBasePath(row)}/download/${row.app}/${row.stream}/${videoPath}`
-      console.log(this.videoUrl)
-    },
-      getFileBasePath(item) {
-          let basePath = ""
-          if (axios.defaults.baseURL.startsWith("http")) {
-              basePath = `${axios.defaults.baseURL}/record_proxy/${item.mediaServerId}`
+      this.$axios({
+        method: 'get',
+        url: `/api/cloud/record/play/path`,
+        params: {
+          recordId: row.id,
+        }
+      }).then((res) => {
+        console.log(res)
+        if (res.data.code === 0) {
+          if (location.protocol === "https:") {
+            this.videoUrl = res.data.data.httpsPath;
           }else {
-              basePath = `${window.location.origin}${axios.defaults.baseURL}/record_proxy/${item.mediaServerId}`
+            this.videoUrl = res.data.data.httpPath;
           }
-          return basePath;
-      },
+          console.log(222 )
+          console.log(this.videoUrl )
+        }
+      }).catch((error) => {
+        console.log(error);
+      });
+    },
+    downloadFile(file){
+      console.log(file)
+      this.$axios({
+        method: 'get',
+        url: `/api/cloud/record/play/path`,
+        params: {
+          recordId: file.id,
+        }
+      }).then((res) => {
+        console.log(res)
+        const link = document.createElement('a');
+        link.target = "_blank";
+        if (res.data.code === 0) {
+          if (location.protocol === "https:") {
+            link.href = res.data.data.httpsPath + "&save_name=" + file.fileName;
+          }else {
+            link.href = res.data.data.httpPath + "&save_name=" + file.fileName;
+          }
+          link.click();
+        }
+      }).catch((error) => {
+        console.log(error);
+      });
+    },
     deleteRecord() {
       // TODO
       let that = this;
@@ -248,14 +281,16 @@
       });
     },
     formatTime(time) {
-      const h = parseInt(time / 3600)
-      const minute = parseInt(time / 60 % 60)
-      const second = Math.ceil(time % 60)
-
-      return (h > 0 ? h + `灏忔椂` : '') + (minute > 0 ? minute + '鍒�' : '') + second + '绉�'
+      const h = parseInt(time / 3600 / 1000)
+      const minute = parseInt((time - h * 3600 * 1000) / 60 / 1000)
+      let second = Math.ceil((time - h * 3600 * 1000 - minute * 60 * 1000) / 1000)
+      if (second < 0) {
+        second = 0;
+      }
+      return (h > 0 ? h + `灏忔椂` : '') + (minute > 0 ? minute + '鍒�' : '') + (second > 0 ? second + '绉�' : '')
     },
     formatTimeStamp(time) {
-      return moment.unix(time).format('yyyy-MM-DD HH:mm:ss')
+      return moment.unix(time/1000).format('yyyy-MM-DD HH:mm:ss')
     }
 
   }

--
Gitblit v1.8.0