{"remainingRequest":"D:\\jenkins\\workspace\\sfz-lh-fvue\\node_modules\\thread-loader\\dist\\cjs.js!D:\\jenkins\\workspace\\sfz-lh-fvue\\node_modules\\babel-loader\\lib\\index.js!D:\\jenkins\\workspace\\sfz-lh-fvue\\node_modules\\cache-loader\\dist\\cjs.js??ref--0-0!D:\\jenkins\\workspace\\sfz-lh-fvue\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\sfz-lh-fvue\\src\\App.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\sfz-lh-fvue\\src\\App.vue","mtime":1708420520442},{"path":"D:\\jenkins\\workspace\\sfz-lh-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\sfz-lh-fvue\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\sfz-lh-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\sfz-lh-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\sfz-lh-fvue\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/es6.array.find\";\nimport \"core-js/modules/es6.regexp.replace\";\nimport \"core-js/modules/es6.function.name\";\nimport \"core-js/modules/web.dom.iterable\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nimport Vue from '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 componentsArr: [] // 含有iframe的页面\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; // 设置iframe页的数组对象\n\n var componentsArr = this.getComponentsArr();\n componentsArr.forEach(function (item) {\n Vue.component(item.name, item.component);\n });\n this.componentsArr = componentsArr; // 判断当前路由是否iframe页\n // this.isOpenIframePage()\n // this.heartCheckFun()\n // this.initWebSocket()\n },\n watch: {\n $route: function $route() {\n // 判断当前路由是否iframe页\n this.isOpenIframePage();\n }\n },\n computed: {\n // 实现懒加载,只渲染已经打开过(hasOpen:true)的iframe页\n hasOpenComponentsArr: function hasOpenComponentsArr() {\n return this.componentsArr.filter(function (item) {\n return item.hasOpen;\n });\n }\n },\n methods: {\n // 缓存iframe类型页面\n // 遍历路由的所有页面,把含有iframe标识的收集起来\n getComponentsArr: function getComponentsArr() {\n var router = this.$router;\n var routes = router.options.routes;\n var iframeArr = routes.filter(function (item) {\n if (item.meta && item.meta.iframe) {\n return true;\n } else {\n return false;\n }\n });\n var iframeArrs = iframeArr.map(function (item) {\n var name = item.name || item.path.replace('/', '');\n return {\n name: name,\n path: item.path,\n hasOpen: false,\n // 是否打开过,默认false\n component: item.component // 组件文件的引用\n\n };\n });\n return iframeArrs;\n },\n // 根据当前路由设置hasOpen\n isOpenIframePage: function isOpenIframePage() {\n var _this2 = this;\n\n var target = this.componentsArr.find(function (item) {\n return item.path === _this2.$route.path;\n });\n\n if (target && !target.hasOpen) {\n target.hasOpen = true;\n }\n },\n reload: function reload() {\n var _this3 = this;\n\n this.isRouterAlive = false;\n setTimeout(function () {\n _this3.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 _this4 = this;\n\n if (this.lockReconnect) return;\n this.lockReconnect = true; //没连接上会一直重连,设置延迟避免请求过多\n\n setTimeout(function () {\n console.info('尝试重连...');\n\n _this4.initWebSocket();\n\n _this4.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':'heartcheck'}\"); // 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]}