{"remainingRequest":"D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\thread-loader\\dist\\cjs.js!D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\babel-loader\\lib\\index.js!D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\cache-loader\\dist\\cjs.js??ref--0-0!D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\cssc-fvue\\src\\components\\layout\\Layout.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\cssc-fvue\\src\\components\\layout\\Layout.vue","mtime":1698745303706},{"path":"D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/es6.typed.uint8-array\";\nimport \"core-js/modules/es6.regexp.replace\";\nimport \"core-js/modules/es6.function.name\";\nimport \"core-js/modules/es6.regexp.split\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nimport Navigator from \"./Navigator.vue\";\nimport SideMenu from \"./SideMenu.vue\";\nimport menu from '@/api/menu.js';\nimport portal from '@/api/portal.js';\nimport pako from 'pako';\nexport default {\n components: {\n Navigator: Navigator,\n SideMenu: SideMenu\n },\n data: function data() {\n return {\n menuShow: true,\n currentMenuLabel: '',\n showHeader: true,\n menuStyle: 'sideMenu',\n // sideMenu topMenu topSide\n transitionName: 'fold-left',\n showPage: true,\n isCurrentWindow: true\n };\n },\n watch: {\n $route: function $route(to, from) {\n if (!to.hash) {\n this.showPage = !this.showPage;\n var toDepth = to.path.split('/').length;\n var fromDepth = from.path.split('/').length;\n this.transitionName = toDepth < fromDepth ? 'fold-right' : 'fold-left';\n }\n }\n },\n created: function created() {\n this.heartCheckFun();\n this.initWebSocket();\n },\n mounted: function mounted() {\n var _this = this;\n\n document.addEventListener('visibilitychange', this.windowVisiable);\n\n window.onresize = function () {\n _this.$root.$emit('resize');\n };\n\n menu.getMenuByAlias(this.$route.name, function (m) {\n if (m) {\n _this.$emit('menuChange', m);\n }\n });\n this.$bus.$on('login', function () {\n _this.heartCheckFun();\n }); // 发送消息\n // this.$bus.$on('sendWebsock',()=>{\n // this.websocketSend(\"{'messageType':'topic','message': '发送'}\")\n // })\n },\n beforeDestroy: function beforeDestroy() {\n this.isCurrentWindow = false;\n document.removeEventListener('visibilitychange', this.windowVisiable);\n },\n methods: {\n windowVisiable: function windowVisiable(e) {\n if (e.target.visibilityState == 'visible') {\n // console.log('回到当前tab标签')\n this.isCurrentWindow = true;\n } else {\n // console.log('离开当前tab标签')\n this.isCurrentWindow = false;\n }\n },\n handleMenuChange: function handleMenuChange(menu) {\n this.currentMenuLabel = menu.name;\n this.showHeader = !(menu.children && menu.children.length > 0);\n },\n initWebSocket: function initWebSocket() {\n // WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https\n var token = this.$store.state.login.currentUser.token;\n var url = window.context.WebSocket.replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket'; // ?token=' +\n // token\n\n console.log(url, 'url');\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 ungzip: function ungzip(zipData, callback) {\n var unZipData = ''; //解压缩后数据\n //在浏览器中,必须使用atob,并且您需要使用例如Uint8Array.from将解码的数据转换为Uint8Array\n\n var strData = atob(zipData);\n var gzipedDataArray = Uint8Array.from(strData, function (c) {\n return c.charCodeAt(0);\n });\n var ungzipedData = pako.ungzip(gzipedDataArray); // console.log('ungziped data', new TextDecoder().decode(ungzipedData))\n // 在ungzip上的结果是一个Unit8Array。如果你想把它转换回一个字符串,你需要再次解码:\n\n unZipData = new TextDecoder().decode(ungzipedData); // 还原成对象\n\n if (unZipData) {\n unZipData = JSON.parse(unZipData);\n } //利用回调进行处理后续操作\n\n\n if (callback) {\n callback(unZipData);\n }\n },\n websocketOnmessage: function websocketOnmessage(e) {\n var _this2 = this;\n\n // console.log('-----接收消息-------', e.data)\n var data = JSON.parse(e.data); //解析对象 eval('(' + e.data + ')');\n // console.log('-----接收消息-------', data.cmd, data.data)\n\n if (data.cmd == 'SCADA') {\n if (this.isCurrentWindow) {\n // 解压数据\n this.ungzip(data.data, function (changeData) {\n // console.log('-----接收消息-------', changeData)\n // 处理业务逻辑\n _this2.$bus.$emit('SCADAMsg', changeData);\n });\n }\n } // 场群协同\n\n\n if (data.cmd == 'CQKZ') {\n if (this.isCurrentWindow) {\n // console.log('-----接收消息-------', data.data)\n this.$bus.$emit('CQKZMsg', data.data);\n }\n } // 无功功率\n\n\n if (data.cmd == 'DWWGKZ') {\n if (this.isCurrentWindow) {\n this.ungzip(data.data, function (changeData) {\n // 处理业务逻辑\n _this2.$bus.$emit('DWWGKZMsg', changeData);\n });\n }\n }\n\n if (data.cmd == 'dict') {\n // 重载字典\n this.getSysDict();\n }\n\n if (data.cmd == 'alarm') {\n // 告警刷新\n this.$bus.$emit('SCADAAlram');\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; //心跳检测,每10分钟心跳一次\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 var account = JSON.parse(sessionStorage.getItem('currentUser')).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 // websocket sendMessage()\n // websocketSend\n // messageType: 类型 ping //心跳,topic //群发送,user //向目标用户发消息\n // account :登录用户account的账号\n // chatId :目标用户account的账号\n // message :消息内容\n getSysDict: function getSysDict() {\n portal.getSysDict().then(function (data) {\n console.log(data, '字典');\n\n if (data) {\n sessionStorage.setItem('dict_data', JSON.stringify(data));\n }\n });\n }\n }\n};",null]}