From 7d57b0fef0f220dfe7c868ce1113a7ce6eb6c468 Mon Sep 17 00:00:00 2001
From: suerprisePlus <15810472099@163.com>
Date: 星期三, 21 八月 2024 11:23:06 +0800
Subject: [PATCH] 添加本地矢量地图服务,初始化视角切换

---
 src/views/visualization/index.vue |   45 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/src/views/visualization/index.vue b/src/views/visualization/index.vue
index d54d49d..2fe2f99 100644
--- a/src/views/visualization/index.vue
+++ b/src/views/visualization/index.vue
@@ -3,10 +3,10 @@
         <div class="title"></div>
         <mapView></mapView>
         <div class="leftMenu">
-            <left-menu></left-menu>
+            <left-menu :leftChartData="leftChartData"></left-menu>
         </div>
         <div class="rightMenu">
-            <right-menu></right-menu>
+            <right-menu :rightChartData="rightChartData"></right-menu>
         </div>
         <div class="bottomMenu">
             <bottomMenu @childData="childData"></bottomMenu>
@@ -42,6 +42,7 @@
 import analysis from '@/views/visual/analysis/index.vue'
 import lineLoss from './lineLoss.vue';
 import statistics from '@/views/visual/statistics/index.vue'
+import { type } from 'jquery';
 export default {
     components: {
         mapView, leftMenu,
@@ -50,12 +51,50 @@
     data() {
         return {
             isShow: null,
-            showInfo: false
+            showInfo: false,
+            wsSocket: null,
+            rightChartData: {},
+            leftChartData:{},
         }
     },
+    beforeDestroy() {
+        if (this.wsSocket) {
+            this.wsSocket.onclose = () => {
+                console.log('WebSocket杩炴帴鍏抽棴');
+                this.wsSocket = null
+            };
+        }
+
+    },
     mounted() {
+        if (!this.wsSocket) {
+            this.createSocket();
+        }
     },
     methods: {
+        createSocket() {
+            this.wsSocket = new WebSocket(config.pySocket);
+            this.wsSocket.onopen = (event) => {
+                console.log('WebSocket杩炴帴鎴愬姛');
+            };
+            this.wsSocket.onmessage = (event) => {
+                // console.log('Received message:', event.data);
+
+                if (event.data != "杩炴帴鎴愬姛") {
+                    const obj = JSON.parse(event.data)
+           
+                    
+                    this.leftChartData = {
+                        type: 'left1',
+                        val: obj
+                    }
+                }
+
+
+
+                // 澶勭悊鎺ユ敹鍒扮殑娑堟伅
+            };
+        },
         childData(res) {
             if (!res) return
             this.showInfo = true;

--
Gitblit v1.9.3