Selaa lähdekoodia

链接websocket

yuhan 1 vuosi sitten
vanhempi
commit
53c7d61640
1 muutettua tiedostoa jossa 5 lisäystä ja 3 poistoa
  1. 5 3
      src/views/modules_guAn/visualization/index.vue

+ 5 - 3
src/views/modules_guAn/visualization/index.vue

@@ -79,6 +79,7 @@ import TestInformation from './modules/TestInformation.vue'
 import TestStatusInfo from './modules/TestStatusInfo.vue'
 
 import { getAction } from '@/api/manage'
+import store from '@/store'
 
 export default {
   name: '',
@@ -106,9 +107,9 @@ export default {
   },
   created () {
     // 初始化websocket
-    // this.initWebSocket()
+    this.initWebSocket()
     // 数据获取
-    this.getData()
+    // this.getData()
   },
   mounted () {
   },
@@ -129,7 +130,8 @@ export default {
     // websocket
     initWebSocket () { // 初始化weosocket(必须)
       // 请根据实际项目需要进行修改
-      const wsuri = 'ws://192.168.2.247:8866/websocket'
+      var userId = store.getters.userInfo.id
+      const wsuri = `ws://192.168.2.247:8866/websocket/${userId}`
       // 新建一个webstock对象
       this.websock = new WebSocket(wsuri)
       this.websock.onmessage = this.websocketonmessage