{"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;AADpB,KAAP;AAGH,GALU;AAMXC,EAAAA,OANW,qBAMD;AACN,SAAKD,qBAAL,GAA6B,CAA7B,CADM,CAEN;;AACA,QAAI,KAAKE,MAAL,CAAYC,KAAZ,CAAkBC,IAAlB,CAAuBC,IAAvB,IAA+B,OAA/B,IAA0CP,aAAa,CAAC,uBAAD,CAA3D,EAAsF;AAClF,WAAKQ,qBAAL;AACH;AACJ,GAZU;AAaXC,EAAAA,OAAO,EAAE;AACLD,IAAAA,qBADK,mCACmB;AACpB,UAAIE,KAAK,GAAG,IAAZ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C;AACjCQ,UAAAA,KAAK,CAACF,qBAAN;AACH,SAFD,MAEO;AACHE,UAAAA,KAAK,CAACoB,QAAN,CAAe,kCAAf,EAAmD,IAAnD,EAAyD;AACrDC,YAAAA,iBAAiB,EAAE,IADkC;AAErDC,YAAAA,gBAAgB,EAAE,IAFmC;AAGrDC,YAAAA,IAAI,EAAE;AAH+C,WAAzD,EAIGC,IAJH,CAIQ,YAAM;AACVxB,YAAAA,KAAK,CAACR,qBAAN,GAA8B,CAA9B;;AACAQ,YAAAA,KAAK,CAACF,qBAAN;AACH,WAPD,EAOG2B,KAPH,CAOS,YAAM,CAEd,CATD;AAUH;AACJ;AACJ;AA5DI;AAbE,CAAf","sourcesContent":["import { hasPermission } from '@/utils'\nexport default {\n data() {\n return {\n visitorWebsocketCount: 0\n }\n },\n 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() {\n let _this = this;\n // let currentId = '';\n // let currentTime = new Date().getTime() - 1000 * 30;\n // 尝试建立websocket连接\n try {\n let visitor_websockt = new WebSocket(window.GLOBAL_CONFIG['VISITOR_SOCKET_URL']);\n // 监听socket连接\n visitor_websockt.onopen = () => {\n console.log(\"websocket连接成功\");\n };\n visitor_websockt.onclose = () => {\n console.log(\"websocket连接已关闭\");\n };\n visitor_websockt.onerror = () => {\n console.log(\"websocket连接失败\");\n };\n visitor_websockt.onmessage = res => {\n let data = JSON.parse(res.data);\n // let timeEnd = new Date().getTime();\n _this.$store.commit('visitor/UPDATE_VISITOR', data.msg)\n // 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\n // 关闭webscoket连接\n _this.$once(\"hook:beforeDestroy\", () => {\n visitor_websockt.close();\n });\n // 关闭或刷新浏览器 结束websocket连接\n window.addEventListener(\"beforeunload\", () => {\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(() => {\n _this.visitorWebsocketCount = 0;\n _this.iinitVisitorWebsocket();\n }).catch(() => {\n\n })\n }\n }\n }\n },\n}"]}]}