Browse Source

websocket截流

didi 4 years ago
parent
commit
46c7cff1de
2 changed files with 12 additions and 3 deletions
  1. 8 1
      src/App.vue
  2. 4 2
      src/views/workbench/mixins/websocket.js

+ 8 - 1
src/App.vue

@@ -37,7 +37,14 @@ export default {
   methods: {
     initOmegaTracker() {
       try {
-        OmegaTracker.getTracker(config)
+        // console.log('OmegaTracker.getTracker', config)
+        window.Omega = OmegaTracker.getTracker(config)
+        // window.Omega.trackEvent('注册的埋点id', {
+        //   'bizId': 99,
+        //   'user': 'amyliaozijun',
+        //   'master_func': '项目',
+        //   'detail_func': '行为'
+        // })
       } catch (error) {
         console.error(error)
       }

+ 4 - 2
src/views/workbench/mixins/websocket.js

@@ -1,3 +1,4 @@
+const _ = require('lodash')
 import { ws } from '@/apiConfig/requestIP'
 export default {
   name: 'test',
@@ -24,9 +25,10 @@ export default {
     websocketonopen() { // 连接建立之后执行send方法发送数据
 
     },
-    websocketonerror() { // 连接建立失败重连
+    websocketonerror: _.throttle(function() { // 连接建立失败重连
+      console.log(222)
       this.initWebSocket()
-    },
+    }, 5000),
     websocketsend(Data) { // 数据发送
       this.websock.send(Data)
     },