{"remainingRequest":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\thread-loader\\dist\\cjs.js!D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\babel-loader\\lib\\index.js!D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\cache-loader\\dist\\cjs.js??ref--0-0!D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\xq-web-bpm\\src\\App.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\src\\App.vue","mtime":1675071990741},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/es6.regexp.replace\";\nimport \"core-js/modules/es6.regexp.split\";\nimport \"core-js/modules/es6.regexp.search\";\n\nvar _this2 = this;\n\n//\n//\n//\n//\n//\nimport portal from '@/api/portal.js';\nexport default {\n  name: 'app',\n  data: function data() {\n    return {\n      hasToken: false,\n      heartCheck: null,\n      lockReconnect: false\n    };\n  },\n  created: function created() {\n    this.hasToken = this.hasParams();\n    this.$store.dispatch('login/hasToken', this.hasToken);\n    this.heartCheckFun();\n    this.initWebSocket();\n  },\n  mounted: function mounted() {\n    var _this = this;\n\n    // 因为resize事件在整个项目中只能监听一次，所以这里通过全局广播发送这个事件\n    window.onresize = function () {\n      _this.$root.$emit('resize');\n    };\n\n    this.$bus.$on('login', function () {\n      _this.initWebSocket();\n    });\n  },\n  methods: {\n    hasParams: function hasParams() {\n      var query = window.location.search.substring(1);\n\n      if (!query) {\n        return false;\n      }\n\n      var vars = query.split('&');\n      var newVars = [];\n\n      for (var i = 0; i < vars.length; i++) {\n        var pair = vars[i].split('=');\n\n        if (pair[0] == 'token') {\n          return true;\n        }\n      }\n    },\n    initWebSocket: function initWebSocket() {\n      // WebSocket与普通的请求所用协议有所不同，ws等同于http，wss等同于https\n      var url = window.context.WebSocket.replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket';\n      this.websock = new WebSocket(url);\n      this.websock.onopen = this.websocketOnopen;\n      this.websock.onerror = this.websocketOnerror;\n      this.websock.onmessage = this.websocketOnmessage;\n      this.websock.onclose = this.websocketOnclose;\n    },\n    websocketOnopen: function websocketOnopen() {\n      console.log('WebSocket连接成功');\n      this.heartCheck.start();\n    },\n    websocketOnerror: function websocketOnerror() {\n      console.log(e, 'WebSocket连接发生错误');\n\n      _this2.reconnect();\n    },\n    websocketOnmessage: function websocketOnmessage(e) {\n      console.log('-----接收消息-------', e.data);\n      var data = eval('(' + e.data + ')'); //解析对象\n\n      if (data.cmd == 'dict') {\n        // 重载字典\n        this.getSysDict();\n      }\n\n      this.heartCheck.reset();\n    },\n    websocketOnclose: function websocketOnclose(e) {\n      console.log('connection closed (' + e.code + ')');\n      this.reconnect();\n    },\n    websocketSend: function websocketSend(text) {\n      // 数据发送\n      try {\n        this.websock.send(text);\n      } catch (err) {\n        console.log('send failed (' + err.code + ')');\n      }\n    },\n    reconnect: function reconnect() {\n      var _this3 = this;\n\n      if (this.lockReconnect) return;\n      this.lockReconnect = true; //没连接上会一直重连，设置延迟避免请求过多\n\n      setTimeout(function () {\n        console.info('尝试重连...');\n\n        _this3.initWebSocket();\n\n        _this3.lockReconnect = false;\n      }, 5000);\n    },\n    heartCheckFun: function heartCheckFun() {\n      var that = this; //心跳检测,每10s心跳一次\n\n      this.heartCheck = {\n        timeout: 1000 * 60 * 10,\n        timeoutObj: null,\n        serverTimeoutObj: null,\n        reset: function reset() {\n          clearTimeout(this.timeoutObj);\n          this.start();\n          return this;\n        },\n        start: function start() {\n          var self = this;\n          this.timeoutObj = setTimeout(function () {\n            //这里发送一个心跳，后端收到后，返回一个心跳消息，\n            //onmessage拿到返回的心跳就说明连接正常\n            // const account = JSON.parse(\n            //     sessionStorage.getItem('currentUser')\n            // ).account\n            that.websocketSend('{\"messageType\":\"ping\",\"message\":\"web\"}');\n            console.info('客户端发送心跳'); //self.serverTimeoutObj = setTimeout(function(){//如果超过一定时间还没重置，说明后端主动断开了\n            //  that.websock.close();//如果onclose会执行reconnect，我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次\n            //}, self.timeout)\n          }, this.timeout);\n        }\n      };\n    },\n    //---------websocket 接收字典被修改的信息，请求新字典数据。-------------\n    getSysDict: function getSysDict() {\n      portal.getSysDict().then(function (data) {\n        if (data) {\n          sessionStorage.setItem('dict_data', JSON.stringify(data));\n        }\n      });\n    }\n  }\n};",null]}