From 703703929e97b94ca1c1c5e35a578e5fe9d4cfea Mon Sep 17 00:00:00 2001 From: suerprisePlus <15810472099@163.com> Date: 星期一, 30 九月 2024 09:58:04 +0800 Subject: [PATCH] 代码修改 --- src/views/visualization/index.vue | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/views/visualization/index.vue b/src/views/visualization/index.vue index d54d49d..6a77f43 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> @@ -50,12 +50,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