From 9d43e7051075f1fc1b2fee680a79f90becddd63f Mon Sep 17 00:00:00 2001
From: ZZJ <zzjdsg2300@163.com>
Date: 星期三, 12 一月 2022 17:53:52 +0800
Subject: [PATCH] tab禁用

---
 src/components/player/index.vue |   90 +++++++++++++++++++++++++++++----------------
 1 files changed, 58 insertions(+), 32 deletions(-)

diff --git a/src/components/player/index.vue b/src/components/player/index.vue
index c64cf57..ede8d0b 100644
--- a/src/components/player/index.vue
+++ b/src/components/player/index.vue
@@ -45,18 +45,22 @@
     showArea: {
       type: Boolean,
       default: false
+    },
+    hasPoster:{
+      type: Boolean,
+      default: true
     }
   },
- 
-  computed: {
 
-    poster() {
-      return "/images/player/player_poster.gif?t=" + Math.random()
-    }
+  computed: {
+    // poster() {
+    //   return "/images/player/player_poster.gif?t=" + Math.random()
+    // }
   },
   data() {
     return {
       wfs: {},
+      poster: "/images/player/player_poster.gif?t=" + Math.random(),
       wfsId: 0,
       Camera: new VideoRuleData(),
       showCanvas: true,
@@ -76,19 +80,39 @@
       ctx: null,
       canvasWidth: 0,
       canvasHeight: 0,
+      algoDataSocket: null
     };
   },
   watch: {
     rtspUrl: function (newVal, oldVal) {
+      console.log("new rstp: ", newVal);
       if (newVal !== oldVal) {
         if (this.wfs.config) {
           this.wfs.destroy();
+          !!this.algoDataSocket && this.algoDataSocket.close()
         }
         this.$nextTick(() => {
           this.clickStart();
+          this.poster = "/images/player/player_poster.gif?t=" + Math.random()
         });
       }
     }
+  },
+  mounted() {
+    this.clickStart();
+    this.$nextTick(() => {
+      this.canvas = this.$refs.areaCanvas;
+      this.ctx = this.canvas.getContext("2d");
+      this.ctx.lineWidth = 1;
+      this.initArea();
+
+    })
+  },
+  beforeDestroy() {
+    this.wfs.destroy();
+    this.wfsId = "";
+
+    !!this.algoDataSocket && this.algoDataSocket.close()
   },
   methods: {
     checkConnect(id) {
@@ -96,7 +120,7 @@
       if (id !== this.wfsId) {
         return
       }
-      
+
       if (this.wfs.websocketLoader && this.wfs.websocketLoader.client) {
         if (this.wfs.websocketLoader.client.disconnected) {
           this.clickStart();
@@ -176,7 +200,7 @@
         _this.ctx.lineTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion);
         _this.ctx.stroke();
         _this.canvas.style.cursor = "default";
-        
+
       });
       _this.canvasData.arrow.forEach(function (v, i) {
         _this.ctx.strokeStyle = "yellow";
@@ -189,9 +213,9 @@
           20,
           30,
           "yellow"
-        ); 
+        );
         _this.canvas.style.cursor = "default";
-        
+
       });
       _this.canvasData.polygon.forEach(function (v, i) {
         if (v.location.length === 0) {
@@ -206,12 +230,12 @@
         _this.ctx.closePath();
         _this.ctx.stroke();
         _this.canvas.style.cursor = "default";
-        
+
       });
     },
-    
+
     // 绠ご缁樺埗鍑芥暟
-    drawArrow(ctx, fromX, fromY, toX, toY, theta=30, headlen=10, width=1, color="yellow") {
+    drawArrow(ctx, fromX, fromY, toX, toY, theta = 30, headlen = 10, width = 1, color = "yellow") {
       // ctx锛欳anvas缁樺浘鐜
       // fromX, fromY锛氳捣鐐瑰潗鏍囷紙涔熷彲浠ユ崲鎴恜1锛屽彧涓嶈繃瀹冩槸涓�涓暟缁勶級
       // toX, toY锛氱粓鐐瑰潗鏍� (涔熷彲浠ユ崲鎴恜2锛屽彧涓嶈繃瀹冩槸涓�涓暟缁�)
@@ -251,7 +275,7 @@
       ctx.stroke();
       ctx.restore();
     },
-    
+
     // 鍥炴樉鍥惧舰澶囨敞
     showRemarks(x, y, remarks) {
       this.ctx.moveTo(x, y - 10); // 鍥犱负鏀惧ぇ涔嬪悗鏄痽-20锛屾墍浠ョ缉灏忕増鐨勪负y-10
@@ -269,41 +293,43 @@
         this.Camera.getCameraTask();
       });
     },
-    setWidthHeight(){
+    setWidthHeight() {
       this.canvasWidth = this.$refs.videoPlayer.offsetWidth;
       this.canvasHeight = this.$refs.videoPlayer.offsetHeight;
-      console.log(this.canvasWidth,this.canvasHeight)
+      console.log(this.canvasWidth, this.canvasHeight)
     },
-    async initArea(){
+    async initArea() {
       console.log('init')
-      const res = await getAllPolygon({cameraId: this.TreeDataPool.selectedNode.id});
+      const res = await getAllPolygon({ cameraId: this.TreeDataPool.selectedNode.id });
       this.canvasData.line = res.data.line;
       this.canvasData.rect = res.data.rect;
       this.canvasData.arrow = res.data.arrow;
       this.canvasData.polygon = res.data.polygon;
       console.log(this.canvasData)
       this.clickSelect(this.canvasData);
+    },
+    initAlgoDataWebScoket() {
+      if (typeof (WebSocket) === "undefined") {
+        console.log("error,鎮ㄧ殑娴忚鍣ㄤ笉鏀寔socket")
+      } else {
+        this.algoDataSocket = new WebSocket()
+        this.algoDataSocket.onopen = () => {
+          console.log("socket杩炴帴鎴愬姛")
+        }
+        this.algoDataSocket.onerror = () => {
+          console.log("杩炴帴閿欒")
+        }
+        this.algoDataSocket.onmessage = msg => {
+          console.log(msg)
+        }
+      }
     }
-  },
-  mounted() {
-    this.clickStart();
-    this.$nextTick(()=>{
-      this.canvas = this.$refs.areaCanvas;
-      this.ctx = this.canvas.getContext("2d");
-      this.ctx.lineWidth = 1;
-      this.initArea();
-
-    })
-  },
-  beforeDestroy() {
-    this.wfs.destroy();
-    this.wfsId = "";
   }
 };
 </script>
 
 <style lang="scss">
-#area-canvas{
+#area-canvas {
   background: transparent;
   position: absolute;
   top: 0;

--
Gitblit v1.8.0