management/front/dkha-web-sz-main/node_modules/.cache/babel-loader/9261ebfdb2cde8b2949b04f011f...

1 line
8.9 KiB
JSON
Raw Normal View History

2023-12-18 13:12:25 +08:00
{"remainingRequest":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\babel-loader\\lib\\index.js!C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\src\\websocket\\visitor.js","dependencies":[{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\src\\websocket\\visitor.js","mtime":1614735254000},{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\babel-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/es6.function.name\";\nimport { hasPermission } from '@/utils';\nexport default {\n data: function data() {\n return {\n visitorWebsocketCount: 0\n };\n },\n created: function created() {\n this.visitorWebsocketCount = 0; // 访客信息录入权限 \n\n if (this.$store.state.user.name != 'admin' && hasPermission('sys:visitor:webscoket')) {\n this.iinitVisitorWebsocket();\n }\n },\n methods: {\n iinitVisitorWebsocket: function iinitVisitorWebsocket() {\n var _this = this; // let currentId = '';\n // let currentTime = new Date().getTime() - 1000 * 30;\n // 尝试建立websocket连接\n\n\n try {\n var visitor_websockt = new WebSocket(window.GLOBAL_CONFIG['VISITOR_SOCKET_URL']); // 监听socket连接\n\n visitor_websockt.onopen = function () {\n console.log(\"websocket连接成功\");\n };\n\n visitor_websockt.onclose = function () {\n console.log(\"websocket连接已关闭\");\n };\n\n visitor_websockt.onerror = function () {\n console.log(\"websocket连接失败\");\n };\n\n visitor_websockt.onmessage = function (res) {\n var data = JSON.parse(res.data); // let timeEnd = new Date().getTime();\n\n _this.$store.commit('visitor/UPDATE_VISITOR', data.msg); // if (data.msg != currentId) {\n // currentId = data.msg;\n // currentTime = new Date().getTime();\n // _this.$store.commit('visitor/UPDATE_VISITOR', data.msg)\n // } else if (timeEnd - currentTime > 1000 * 30) {\n // currentId = data.msg;\n // currentTime = new Date().getTime();\n // _this.$store.commit('visitor/UPDATE_VISITOR', data.msg)\n // }\n\n }; // 关闭webscoket连接\n\n\n _this.$once(\"hook:beforeDestroy\", function () {\n visitor_websockt.close();\n }); // 关闭或刷新浏览器 结束websocket连接\n\n\n window.addEventListener(\"beforeunload\", function () {\n visitor_websockt.close();\n });\n } catch (error) {\n console.error('链接websocket失败', error);\n _this.visitorWebsocketCount++; // 失败建立连接 五次内失败 尝试重新连接\n\n if (_this.visitorWebsocketCount < 5) {\n _this.iinitVisitorWebsocket();\n } else {\n _this.$confirm('建立websocket连接失败访客信息无法直接录入是否重试?', '提示', {\n confirmButtonText: '确定',\n cancelButtonText: '取消',\n type: 'warning'\n }).then(function () {\n _this.visitorWebsocketCount = 0;\n\n _this.iinitVisitorWebsocket();\n }).catch(function () {});\n }\n }\n }\n }\n};",{"version":3,"sources":["C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\src\\websocket\\visitor.js"],"names":["hasPermission","data","visitorWebsocketCount","created","$store","state","user","name","iinitVisitorWebsocket","methods","_this","visitor_websockt","WebSocket","window","GLOBAL_CONFIG","onopen","console","log","onclose","onerror","onmessage","res","JSON","parse","commit","msg","$once","close","addEventListener","error","$confirm","confirmButtonText","cancelButtonText","type","then","catch"],"mappings":";AAAA,SAASA,aAAT,QAA8B,SAA9B;AACA,eAAe;AACXC,EAAAA,IADW,kBACJ;AACH,WAAO;AACHC,MAAAA,qBAAqB,EAAE;AADp