{"remainingRequest":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\thread-loader\\dist\\cjs.js!D:\\jenkins\\workspace\\examine-fvue\\node_modules\\babel-loader\\lib\\index.js!D:\\jenkins\\workspace\\examine-fvue\\node_modules\\cache-loader\\dist\\cjs.js??ref--0-0!D:\\jenkins\\workspace\\examine-fvue\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\examine-fvue\\src\\App.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\examine-fvue\\src\\App.vue","mtime":1667280203123},{"path":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/es6.regexp.replace\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n// import Navigator from '@/views/Navigator.vue'\nimport portal from '@/api/portal.js';\nexport default {\n name: 'app',\n provide: function provide() {\n //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。\n return {\n reload: this.reload,\n heartCheck: null,\n lockReconnect: false\n };\n },\n components: {// Navigator,\n },\n data: function data() {\n return {\n isRouterAlive: true //控制视图是否显示的变量\n\n };\n },\n mounted: function mounted() {\n var _this = this;\n\n // 因为resize事件在整个项目中只能监听一次,所以这里通过全局广播发送这个事件\n window.onresize = function () {\n _this.$root.$emit('resize');\n }; // this.$bus.$on('login', () => {\n // this.initWebSocket()\n // })\n\n },\n created: function created() {\n var that = this; // that.$store._vm.$root.$on('login-completed', function () {\n // that.getSysDict()\n // //获取静态资源目录\n // that.$store.dispatch('menu/getStaticMenus')\n // // 获取用户接口权限\n // that.$store.dispatch('menu/getCurrentUserMethodAuth')\n // // 获取动态资源目录\n // // that.$store.dispatch('menu/getSyncMenus')\n // })\n // this.heartCheckFun()\n // this.initWebSocket()\n },\n methods: {\n reload: function reload() {\n var _this2 = this;\n\n this.isRouterAlive = false;\n setTimeout(function () {\n _this2.isRouterAlive = true;\n }, 10);\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(e) {\n console.log(e, 'WebSocket连接发生错误');\n this.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: 10000,\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 that.websocketSend('{\"messageType\":\"ping\",\"message\":\"web\"}'); // console.info('客户端发送心跳')\n //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]}