user-behavior-monitor 9.0.6 → 9.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -87,6 +87,17 @@ module.exports =
|
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ({
|
|
89
89
|
|
|
90
|
+
/***/ "06fd":
|
|
91
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
92
|
+
|
|
93
|
+
"use strict";
|
|
94
|
+
/* harmony import */ var _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_b2aa60ae_prod_lang_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("5c3c");
|
|
95
|
+
/* harmony import */ var _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_b2aa60ae_prod_lang_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_b2aa60ae_prod_lang_css__WEBPACK_IMPORTED_MODULE_0__);
|
|
96
|
+
/* unused harmony reexport * */
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
/***/ }),
|
|
100
|
+
|
|
90
101
|
/***/ "2350":
|
|
91
102
|
/***/ (function(module, exports) {
|
|
92
103
|
|
|
@@ -436,45 +447,34 @@ function applyToTag (styleElement, obj) {
|
|
|
436
447
|
|
|
437
448
|
/***/ }),
|
|
438
449
|
|
|
439
|
-
/***/ "
|
|
450
|
+
/***/ "5c3c":
|
|
440
451
|
/***/ (function(module, exports, __webpack_require__) {
|
|
441
452
|
|
|
442
|
-
|
|
443
|
-
// imports
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
// module
|
|
447
|
-
exports.push([module.i, ".behavior-warning-dialog.el-dialog.el-dialog--center{text-align:left}.behavior-warning-dialog .el-dialog__footer{text-align:right!important}.el-alert--warning.is-light{background-color:#382b22!important;color:#e19212!important}", ""]);
|
|
448
|
-
|
|
449
|
-
// exports
|
|
453
|
+
// style-loader: Adds some css to the DOM by adding a <style> tag
|
|
450
454
|
|
|
455
|
+
// load the styles
|
|
456
|
+
var content = __webpack_require__("c340");
|
|
457
|
+
if(content.__esModule) content = content.default;
|
|
458
|
+
if(typeof content === 'string') content = [[module.i, content, '']];
|
|
459
|
+
if(content.locals) module.exports = content.locals;
|
|
460
|
+
// add the styles to the DOM
|
|
461
|
+
var add = __webpack_require__("499e").default
|
|
462
|
+
var update = add("7f9ef077", content, true, {"sourceMap":false,"shadowMode":false});
|
|
451
463
|
|
|
452
464
|
/***/ }),
|
|
453
465
|
|
|
454
|
-
/***/ "
|
|
455
|
-
/***/ (function(module,
|
|
456
|
-
|
|
457
|
-
"use strict";
|
|
458
|
-
/* harmony import */ var _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_62b05bc6_prod_lang_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("f818");
|
|
459
|
-
/* harmony import */ var _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_62b05bc6_prod_lang_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_62b05bc6_prod_lang_css__WEBPACK_IMPORTED_MODULE_0__);
|
|
460
|
-
/* unused harmony reexport * */
|
|
466
|
+
/***/ "c340":
|
|
467
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
461
468
|
|
|
469
|
+
exports = module.exports = __webpack_require__("2350")(false);
|
|
470
|
+
// imports
|
|
462
471
|
|
|
463
|
-
/***/ }),
|
|
464
472
|
|
|
465
|
-
|
|
466
|
-
|
|
473
|
+
// module
|
|
474
|
+
exports.push([module.i, ".behavior-warning-dialog.el-dialog.el-dialog--center{text-align:left}.behavior-warning-dialog .el-dialog__footer{text-align:right!important}.el-alert--warning.is-light{background-color:#382b22!important;color:#e19212!important}", ""]);
|
|
467
475
|
|
|
468
|
-
//
|
|
476
|
+
// exports
|
|
469
477
|
|
|
470
|
-
// load the styles
|
|
471
|
-
var content = __webpack_require__("5beb");
|
|
472
|
-
if(content.__esModule) content = content.default;
|
|
473
|
-
if(typeof content === 'string') content = [[module.i, content, '']];
|
|
474
|
-
if(content.locals) module.exports = content.locals;
|
|
475
|
-
// add the styles to the DOM
|
|
476
|
-
var add = __webpack_require__("499e").default
|
|
477
|
-
var update = add("326698fb", content, true, {"sourceMap":false,"shadowMode":false});
|
|
478
478
|
|
|
479
479
|
/***/ }),
|
|
480
480
|
|
|
@@ -503,12 +503,12 @@ if (typeof window !== 'undefined') {
|
|
|
503
503
|
// Indicate to webpack that this file can be concatenated
|
|
504
504
|
/* harmony default export */ var setPublicPath = (null);
|
|
505
505
|
|
|
506
|
-
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"14550f6a-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UserBehaviorMonitor.vue?vue&type=template&id=
|
|
506
|
+
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"14550f6a-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UserBehaviorMonitor.vue?vue&type=template&id=b2aa60ae
|
|
507
507
|
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:"behaviorMonitor",staticClass:"user-behavior-monitor"},[_c('el-dialog',{attrs:{"title":"提示","visible":_vm.showWarning,"show-close":false,"modal":true,"width":"30%","center":"","custom-class":"behavior-warning-dialog"},on:{"update:visible":function($event){_vm.showWarning=$event}}},[_c('span',[_vm._v(_vm._s(_vm.warningMessage))])]),_c('el-dialog',{attrs:{"title":"提示","visible":_vm.showtips,"close-on-click-modal":false,"close-on-press-escape":false,"show-close":false,"modal":true,"width":"30%","center":"","custom-class":"behavior-warning-dialog"},on:{"update:visible":function($event){_vm.showtips=$event}}},[_c('el-alert',{staticStyle:{"margin":"10px 0"},attrs:{"title":'该账号已在其他设备登录!',"type":"warning","closable":false,"show-icon":""}}),_c('span',{staticClass:"dialog-footer",attrs:{"slot":"footer"},slot:"footer"},[_c('el-button',{attrs:{"type":"primary","size":"mini"},on:{"click":_vm.handleReconnectFailure}},[_vm._v("确 定")])],1)],1)],1)}
|
|
508
508
|
var staticRenderFns = []
|
|
509
509
|
|
|
510
510
|
|
|
511
|
-
// CONCATENATED MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=template&id=
|
|
511
|
+
// CONCATENATED MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=template&id=b2aa60ae
|
|
512
512
|
|
|
513
513
|
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UserBehaviorMonitor.vue?vue&type=script&lang=js
|
|
514
514
|
//
|
|
@@ -748,7 +748,7 @@ var staticRenderFns = []
|
|
|
748
748
|
|
|
749
749
|
// 设置连接成功回调
|
|
750
750
|
this.socket.onopen = () => {
|
|
751
|
-
|
|
751
|
+
console.log('WebSocket连接已建立');
|
|
752
752
|
this.sendUserBehavior();
|
|
753
753
|
this.$emit('websocket-open');
|
|
754
754
|
// 连接成功时重置重连尝试次数
|
|
@@ -759,17 +759,17 @@ var staticRenderFns = []
|
|
|
759
759
|
this.socket.onmessage = (event) => {
|
|
760
760
|
try {
|
|
761
761
|
const data = JSON.parse(event.data);
|
|
762
|
-
|
|
762
|
+
console.log('收到用户活动状态消息:', data);
|
|
763
763
|
this.handleActivityStatus(data);
|
|
764
764
|
this.$emit('websocket-message', data);
|
|
765
765
|
} catch (e) {
|
|
766
|
-
|
|
766
|
+
console.error('解析WebSocket消息失败:', e);
|
|
767
767
|
}
|
|
768
768
|
};
|
|
769
769
|
|
|
770
770
|
// 设置连接关闭回调
|
|
771
771
|
this.socket.onclose = (event) => {
|
|
772
|
-
|
|
772
|
+
console.log('WebSocket连接已断开:', event.reason);
|
|
773
773
|
this.$emit('websocket-close');
|
|
774
774
|
|
|
775
775
|
// 如果不是在登录页面且监控仍在运行,尝试重连
|
|
@@ -843,7 +843,7 @@ var staticRenderFns = []
|
|
|
843
843
|
// 如果是线上环境且重连次数已达到最大值,则跳转到登录页
|
|
844
844
|
if (!this.isLocalDevelopment && this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
845
845
|
// console.log('线上环境,重连失败,跳转到登录页');
|
|
846
|
-
this.handleReconnectFailure();
|
|
846
|
+
// this.handleReconnectFailure();
|
|
847
847
|
return;
|
|
848
848
|
}
|
|
849
849
|
|
|
@@ -855,12 +855,12 @@ var staticRenderFns = []
|
|
|
855
855
|
// 处理重连失败
|
|
856
856
|
handleReconnectFailure() {
|
|
857
857
|
// 清空缓存
|
|
858
|
-
|
|
859
|
-
|
|
858
|
+
localStorage.clear();
|
|
859
|
+
sessionStorage.clear();
|
|
860
860
|
|
|
861
861
|
// 跳转到登录页
|
|
862
862
|
|
|
863
|
-
|
|
863
|
+
location.reload();
|
|
864
864
|
|
|
865
865
|
// 触发登出事件
|
|
866
866
|
this.$emit('logout');
|
|
@@ -902,11 +902,11 @@ var staticRenderFns = []
|
|
|
902
902
|
// 处理非活跃状态
|
|
903
903
|
handleInactiveStatus() {
|
|
904
904
|
// 清空缓存
|
|
905
|
-
|
|
906
|
-
|
|
905
|
+
localStorage.clear();
|
|
906
|
+
sessionStorage.clear();
|
|
907
907
|
|
|
908
908
|
// 跳转到登录页
|
|
909
|
-
|
|
909
|
+
this.$router.push('/login');
|
|
910
910
|
|
|
911
911
|
// 或者使用window.location
|
|
912
912
|
|
|
@@ -924,7 +924,7 @@ var staticRenderFns = []
|
|
|
924
924
|
"type": "HEARTBEAT",
|
|
925
925
|
"message": "心跳",
|
|
926
926
|
};
|
|
927
|
-
|
|
927
|
+
console.log('用户行为监测:', JSON.stringify(message));
|
|
928
928
|
this.socket.send(JSON.stringify(message));
|
|
929
929
|
}
|
|
930
930
|
},
|
|
@@ -1106,9 +1106,9 @@ var staticRenderFns = []
|
|
|
1106
1106
|
|
|
1107
1107
|
// 登出操作
|
|
1108
1108
|
logout() {
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1109
|
+
localStorage.clear();
|
|
1110
|
+
sessionStorage.clear();
|
|
1111
|
+
location.reload();
|
|
1112
1112
|
// 跳转到登录页
|
|
1113
1113
|
//this.$router.push('/login');
|
|
1114
1114
|
|
|
@@ -1204,11 +1204,11 @@ var staticRenderFns = []
|
|
|
1204
1204
|
// 新增:处理token缺失的情况
|
|
1205
1205
|
handleTokenMissing() {
|
|
1206
1206
|
// 清空缓存
|
|
1207
|
-
|
|
1208
|
-
|
|
1207
|
+
localStorage.clear();
|
|
1208
|
+
sessionStorage.clear();
|
|
1209
1209
|
|
|
1210
1210
|
// 刷新页面
|
|
1211
|
-
|
|
1211
|
+
location.reload();
|
|
1212
1212
|
|
|
1213
1213
|
// 触发登出事件
|
|
1214
1214
|
this.$emit('logout');
|
|
@@ -1218,8 +1218,8 @@ var staticRenderFns = []
|
|
|
1218
1218
|
|
|
1219
1219
|
// CONCATENATED MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=script&lang=js
|
|
1220
1220
|
/* harmony default export */ var components_UserBehaviorMonitorvue_type_script_lang_js = (UserBehaviorMonitorvue_type_script_lang_js);
|
|
1221
|
-
// EXTERNAL MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=style&index=0&id=
|
|
1222
|
-
var
|
|
1221
|
+
// EXTERNAL MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=style&index=0&id=b2aa60ae&prod&lang=css
|
|
1222
|
+
var UserBehaviorMonitorvue_type_style_index_0_id_b2aa60ae_prod_lang_css = __webpack_require__("06fd");
|
|
1223
1223
|
|
|
1224
1224
|
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
|
1225
1225
|
/* globals __VUE_SSR_CONTEXT__ */
|
|
@@ -96,6 +96,17 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
96
96
|
/************************************************************************/
|
|
97
97
|
/******/ ({
|
|
98
98
|
|
|
99
|
+
/***/ "06fd":
|
|
100
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
101
|
+
|
|
102
|
+
"use strict";
|
|
103
|
+
/* harmony import */ var _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_b2aa60ae_prod_lang_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("5c3c");
|
|
104
|
+
/* harmony import */ var _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_b2aa60ae_prod_lang_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_b2aa60ae_prod_lang_css__WEBPACK_IMPORTED_MODULE_0__);
|
|
105
|
+
/* unused harmony reexport * */
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
/***/ }),
|
|
109
|
+
|
|
99
110
|
/***/ "2350":
|
|
100
111
|
/***/ (function(module, exports) {
|
|
101
112
|
|
|
@@ -445,45 +456,34 @@ function applyToTag (styleElement, obj) {
|
|
|
445
456
|
|
|
446
457
|
/***/ }),
|
|
447
458
|
|
|
448
|
-
/***/ "
|
|
459
|
+
/***/ "5c3c":
|
|
449
460
|
/***/ (function(module, exports, __webpack_require__) {
|
|
450
461
|
|
|
451
|
-
|
|
452
|
-
// imports
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
// module
|
|
456
|
-
exports.push([module.i, ".behavior-warning-dialog.el-dialog.el-dialog--center{text-align:left}.behavior-warning-dialog .el-dialog__footer{text-align:right!important}.el-alert--warning.is-light{background-color:#382b22!important;color:#e19212!important}", ""]);
|
|
457
|
-
|
|
458
|
-
// exports
|
|
462
|
+
// style-loader: Adds some css to the DOM by adding a <style> tag
|
|
459
463
|
|
|
464
|
+
// load the styles
|
|
465
|
+
var content = __webpack_require__("c340");
|
|
466
|
+
if(content.__esModule) content = content.default;
|
|
467
|
+
if(typeof content === 'string') content = [[module.i, content, '']];
|
|
468
|
+
if(content.locals) module.exports = content.locals;
|
|
469
|
+
// add the styles to the DOM
|
|
470
|
+
var add = __webpack_require__("499e").default
|
|
471
|
+
var update = add("7f9ef077", content, true, {"sourceMap":false,"shadowMode":false});
|
|
460
472
|
|
|
461
473
|
/***/ }),
|
|
462
474
|
|
|
463
|
-
/***/ "
|
|
464
|
-
/***/ (function(module,
|
|
465
|
-
|
|
466
|
-
"use strict";
|
|
467
|
-
/* harmony import */ var _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_62b05bc6_prod_lang_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("f818");
|
|
468
|
-
/* harmony import */ var _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_62b05bc6_prod_lang_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_UserBehaviorMonitor_vue_vue_type_style_index_0_id_62b05bc6_prod_lang_css__WEBPACK_IMPORTED_MODULE_0__);
|
|
469
|
-
/* unused harmony reexport * */
|
|
475
|
+
/***/ "c340":
|
|
476
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
470
477
|
|
|
478
|
+
exports = module.exports = __webpack_require__("2350")(false);
|
|
479
|
+
// imports
|
|
471
480
|
|
|
472
|
-
/***/ }),
|
|
473
481
|
|
|
474
|
-
|
|
475
|
-
|
|
482
|
+
// module
|
|
483
|
+
exports.push([module.i, ".behavior-warning-dialog.el-dialog.el-dialog--center{text-align:left}.behavior-warning-dialog .el-dialog__footer{text-align:right!important}.el-alert--warning.is-light{background-color:#382b22!important;color:#e19212!important}", ""]);
|
|
476
484
|
|
|
477
|
-
//
|
|
485
|
+
// exports
|
|
478
486
|
|
|
479
|
-
// load the styles
|
|
480
|
-
var content = __webpack_require__("5beb");
|
|
481
|
-
if(content.__esModule) content = content.default;
|
|
482
|
-
if(typeof content === 'string') content = [[module.i, content, '']];
|
|
483
|
-
if(content.locals) module.exports = content.locals;
|
|
484
|
-
// add the styles to the DOM
|
|
485
|
-
var add = __webpack_require__("499e").default
|
|
486
|
-
var update = add("326698fb", content, true, {"sourceMap":false,"shadowMode":false});
|
|
487
487
|
|
|
488
488
|
/***/ }),
|
|
489
489
|
|
|
@@ -512,12 +512,12 @@ if (typeof window !== 'undefined') {
|
|
|
512
512
|
// Indicate to webpack that this file can be concatenated
|
|
513
513
|
/* harmony default export */ var setPublicPath = (null);
|
|
514
514
|
|
|
515
|
-
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"14550f6a-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UserBehaviorMonitor.vue?vue&type=template&id=
|
|
515
|
+
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"14550f6a-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UserBehaviorMonitor.vue?vue&type=template&id=b2aa60ae
|
|
516
516
|
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:"behaviorMonitor",staticClass:"user-behavior-monitor"},[_c('el-dialog',{attrs:{"title":"提示","visible":_vm.showWarning,"show-close":false,"modal":true,"width":"30%","center":"","custom-class":"behavior-warning-dialog"},on:{"update:visible":function($event){_vm.showWarning=$event}}},[_c('span',[_vm._v(_vm._s(_vm.warningMessage))])]),_c('el-dialog',{attrs:{"title":"提示","visible":_vm.showtips,"close-on-click-modal":false,"close-on-press-escape":false,"show-close":false,"modal":true,"width":"30%","center":"","custom-class":"behavior-warning-dialog"},on:{"update:visible":function($event){_vm.showtips=$event}}},[_c('el-alert',{staticStyle:{"margin":"10px 0"},attrs:{"title":'该账号已在其他设备登录!',"type":"warning","closable":false,"show-icon":""}}),_c('span',{staticClass:"dialog-footer",attrs:{"slot":"footer"},slot:"footer"},[_c('el-button',{attrs:{"type":"primary","size":"mini"},on:{"click":_vm.handleReconnectFailure}},[_vm._v("确 定")])],1)],1)],1)}
|
|
517
517
|
var staticRenderFns = []
|
|
518
518
|
|
|
519
519
|
|
|
520
|
-
// CONCATENATED MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=template&id=
|
|
520
|
+
// CONCATENATED MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=template&id=b2aa60ae
|
|
521
521
|
|
|
522
522
|
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UserBehaviorMonitor.vue?vue&type=script&lang=js
|
|
523
523
|
//
|
|
@@ -757,7 +757,7 @@ var staticRenderFns = []
|
|
|
757
757
|
|
|
758
758
|
// 设置连接成功回调
|
|
759
759
|
this.socket.onopen = () => {
|
|
760
|
-
|
|
760
|
+
console.log('WebSocket连接已建立');
|
|
761
761
|
this.sendUserBehavior();
|
|
762
762
|
this.$emit('websocket-open');
|
|
763
763
|
// 连接成功时重置重连尝试次数
|
|
@@ -768,17 +768,17 @@ var staticRenderFns = []
|
|
|
768
768
|
this.socket.onmessage = (event) => {
|
|
769
769
|
try {
|
|
770
770
|
const data = JSON.parse(event.data);
|
|
771
|
-
|
|
771
|
+
console.log('收到用户活动状态消息:', data);
|
|
772
772
|
this.handleActivityStatus(data);
|
|
773
773
|
this.$emit('websocket-message', data);
|
|
774
774
|
} catch (e) {
|
|
775
|
-
|
|
775
|
+
console.error('解析WebSocket消息失败:', e);
|
|
776
776
|
}
|
|
777
777
|
};
|
|
778
778
|
|
|
779
779
|
// 设置连接关闭回调
|
|
780
780
|
this.socket.onclose = (event) => {
|
|
781
|
-
|
|
781
|
+
console.log('WebSocket连接已断开:', event.reason);
|
|
782
782
|
this.$emit('websocket-close');
|
|
783
783
|
|
|
784
784
|
// 如果不是在登录页面且监控仍在运行,尝试重连
|
|
@@ -852,7 +852,7 @@ var staticRenderFns = []
|
|
|
852
852
|
// 如果是线上环境且重连次数已达到最大值,则跳转到登录页
|
|
853
853
|
if (!this.isLocalDevelopment && this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
854
854
|
// console.log('线上环境,重连失败,跳转到登录页');
|
|
855
|
-
this.handleReconnectFailure();
|
|
855
|
+
// this.handleReconnectFailure();
|
|
856
856
|
return;
|
|
857
857
|
}
|
|
858
858
|
|
|
@@ -864,12 +864,12 @@ var staticRenderFns = []
|
|
|
864
864
|
// 处理重连失败
|
|
865
865
|
handleReconnectFailure() {
|
|
866
866
|
// 清空缓存
|
|
867
|
-
|
|
868
|
-
|
|
867
|
+
localStorage.clear();
|
|
868
|
+
sessionStorage.clear();
|
|
869
869
|
|
|
870
870
|
// 跳转到登录页
|
|
871
871
|
|
|
872
|
-
|
|
872
|
+
location.reload();
|
|
873
873
|
|
|
874
874
|
// 触发登出事件
|
|
875
875
|
this.$emit('logout');
|
|
@@ -911,11 +911,11 @@ var staticRenderFns = []
|
|
|
911
911
|
// 处理非活跃状态
|
|
912
912
|
handleInactiveStatus() {
|
|
913
913
|
// 清空缓存
|
|
914
|
-
|
|
915
|
-
|
|
914
|
+
localStorage.clear();
|
|
915
|
+
sessionStorage.clear();
|
|
916
916
|
|
|
917
917
|
// 跳转到登录页
|
|
918
|
-
|
|
918
|
+
this.$router.push('/login');
|
|
919
919
|
|
|
920
920
|
// 或者使用window.location
|
|
921
921
|
|
|
@@ -933,7 +933,7 @@ var staticRenderFns = []
|
|
|
933
933
|
"type": "HEARTBEAT",
|
|
934
934
|
"message": "心跳",
|
|
935
935
|
};
|
|
936
|
-
|
|
936
|
+
console.log('用户行为监测:', JSON.stringify(message));
|
|
937
937
|
this.socket.send(JSON.stringify(message));
|
|
938
938
|
}
|
|
939
939
|
},
|
|
@@ -1115,9 +1115,9 @@ var staticRenderFns = []
|
|
|
1115
1115
|
|
|
1116
1116
|
// 登出操作
|
|
1117
1117
|
logout() {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1118
|
+
localStorage.clear();
|
|
1119
|
+
sessionStorage.clear();
|
|
1120
|
+
location.reload();
|
|
1121
1121
|
// 跳转到登录页
|
|
1122
1122
|
//this.$router.push('/login');
|
|
1123
1123
|
|
|
@@ -1213,11 +1213,11 @@ var staticRenderFns = []
|
|
|
1213
1213
|
// 新增:处理token缺失的情况
|
|
1214
1214
|
handleTokenMissing() {
|
|
1215
1215
|
// 清空缓存
|
|
1216
|
-
|
|
1217
|
-
|
|
1216
|
+
localStorage.clear();
|
|
1217
|
+
sessionStorage.clear();
|
|
1218
1218
|
|
|
1219
1219
|
// 刷新页面
|
|
1220
|
-
|
|
1220
|
+
location.reload();
|
|
1221
1221
|
|
|
1222
1222
|
// 触发登出事件
|
|
1223
1223
|
this.$emit('logout');
|
|
@@ -1227,8 +1227,8 @@ var staticRenderFns = []
|
|
|
1227
1227
|
|
|
1228
1228
|
// CONCATENATED MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=script&lang=js
|
|
1229
1229
|
/* harmony default export */ var components_UserBehaviorMonitorvue_type_script_lang_js = (UserBehaviorMonitorvue_type_script_lang_js);
|
|
1230
|
-
// EXTERNAL MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=style&index=0&id=
|
|
1231
|
-
var
|
|
1230
|
+
// EXTERNAL MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=style&index=0&id=b2aa60ae&prod&lang=css
|
|
1231
|
+
var UserBehaviorMonitorvue_type_style_index_0_id_b2aa60ae_prod_lang_css = __webpack_require__("06fd");
|
|
1232
1232
|
|
|
1233
1233
|
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
|
1234
1234
|
/* globals __VUE_SSR_CONTEXT__ */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["user-behavior-monitor"]=t():e["user-behavior-monitor"]=t()})("undefined"!==typeof self?self:this,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="fb15")}({2350:function(e,t){function n(e,t){var n=e[1]||"",o=e[3];if(!o)return n;if(t&&"function"===typeof btoa){var s=i(o),r=o.sources.map((function(e){return"/*# sourceURL="+o.sourceRoot+e+" */"}));return[n].concat(r).concat([s]).join("\n")}return[n].join("\n")}function i(e){var t=btoa(unescape(encodeURIComponent(JSON.stringify(e)))),n="sourceMappingURL=data:application/json;charset=utf-8;base64,"+t;return"/*# "+n+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i=n(t,e);return t[2]?"@media "+t[2]+"{"+i+"}":i})).join("")},t.i=function(e,n){"string"===typeof e&&(e=[[null,e,""]]);for(var i={},o=0;o<this.length;o++){var s=this[o][0];"number"===typeof s&&(i[s]=!0)}for(o=0;o<e.length;o++){var r=e[o];"number"===typeof r[0]&&i[r[0]]||(n&&!r[2]?r[2]=n:n&&(r[2]="("+r[2]+") and ("+n+")"),t.push(r))}},t}},"499e":function(e,t,n){"use strict";function i(e,t){for(var n=[],i={},o=0;o<t.length;o++){var s=t[o],r=s[0],a=s[1],c=s[2],u=s[3],h={id:e+":"+o,css:a,media:c,sourceMap:u};i[r]?i[r].parts.push(h):n.push(i[r]={id:r,parts:[h]})}return n}n.r(t),n.d(t,"default",(function(){return v}));var o="undefined"!==typeof document;if("undefined"!==typeof DEBUG&&DEBUG&&!o)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var s={},r=o&&(document.head||document.getElementsByTagName("head")[0]),a=null,c=0,u=!1,h=function(){},l=null,d="data-vue-ssr-id",m="undefined"!==typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function v(e,t,n,o){u=n,l=o||{};var r=i(e,t);return p(r),function(t){for(var n=[],o=0;o<r.length;o++){var a=r[o],c=s[a.id];c.refs--,n.push(c)}t?(r=i(e,t),p(r)):r=[];for(o=0;o<n.length;o++){c=n[o];if(0===c.refs){for(var u=0;u<c.parts.length;u++)c.parts[u]();delete s[c.id]}}}}function p(e){for(var t=0;t<e.length;t++){var n=e[t],i=s[n.id];if(i){i.refs++;for(var o=0;o<i.parts.length;o++)i.parts[o](n.parts[o]);for(;o<n.parts.length;o++)i.parts.push(g(n.parts[o]));i.parts.length>n.parts.length&&(i.parts.length=n.parts.length)}else{var r=[];for(o=0;o<n.parts.length;o++)r.push(g(n.parts[o]));s[n.id]={id:n.id,refs:1,parts:r}}}}function f(){var e=document.createElement("style");return e.type="text/css",r.appendChild(e),e}function g(e){var t,n,i=document.querySelector("style["+d+'~="'+e.id+'"]');if(i){if(u)return h;i.parentNode.removeChild(i)}if(m){var o=c++;i=a||(a=f()),t=w.bind(null,i,o,!1),n=w.bind(null,i,o,!0)}else i=f(),t=b.bind(null,i),n=function(){i.parentNode.removeChild(i)};return t(e),function(i){if(i){if(i.css===e.css&&i.media===e.media&&i.sourceMap===e.sourceMap)return;t(e=i)}else n()}}var y=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}();function w(e,t,n,i){var o=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=y(t,o);else{var s=document.createTextNode(o),r=e.childNodes;r[t]&&e.removeChild(r[t]),r.length?e.insertBefore(s,r[t]):e.appendChild(s)}}function b(e,t){var n=t.css,i=t.media,o=t.sourceMap;if(i&&e.setAttribute("media",i),l.ssrId&&e.setAttribute(d,t.id),o&&(n+="\n/*# sourceURL="+o.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{while(e.firstChild)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}},"5beb":function(e,t,n){t=e.exports=n("2350")(!1),t.push([e.i,".behavior-warning-dialog.el-dialog.el-dialog--center{text-align:left}.behavior-warning-dialog .el-dialog__footer{text-align:right!important}.el-alert--warning.is-light{background-color:#382b22!important;color:#e19212!important}",""])},9303:function(e,t,n){"use strict";n("f818")},f818:function(e,t,n){var i=n("5beb");i.__esModule&&(i=i.default),"string"===typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);var o=n("499e").default;o("326698fb",i,!0,{sourceMap:!1,shadowMode:!1})},fb15:function(e,t,n){"use strict";var i;(n.r(t),n.d(t,"UserBehaviorMonitor",(function(){return h})),"undefined"!==typeof window)&&((i=window.document.currentScript)&&(i=i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=i[1]));var o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"behaviorMonitor",staticClass:"user-behavior-monitor"},[n("el-dialog",{attrs:{title:"提示",visible:e.showWarning,"show-close":!1,modal:!0,width:"30%",center:"","custom-class":"behavior-warning-dialog"},on:{"update:visible":function(t){e.showWarning=t}}},[n("span",[e._v(e._s(e.warningMessage))])]),n("el-dialog",{attrs:{title:"提示",visible:e.showtips,"close-on-click-modal":!1,"close-on-press-escape":!1,"show-close":!1,modal:!0,width:"30%",center:"","custom-class":"behavior-warning-dialog"},on:{"update:visible":function(t){e.showtips=t}}},[n("el-alert",{staticStyle:{margin:"10px 0"},attrs:{title:"该账号已在其他设备登录!",type:"warning",closable:!1,"show-icon":""}}),n("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[n("el-button",{attrs:{type:"primary",size:"mini"},on:{click:e.handleReconnectFailure}},[e._v("确 定")])],1)],1)],1)},s=[],r={name:"UserBehaviorMonitor",props:{timeoutMinutes:{type:Number,default:10},warningMinutes:{type:Number,default:1}},data(){return{showtips:!1,mouseMoveThrottled:!1,socket:null,countdownTimer:null,warningTimer:null,showWarning:!1,warningMessage:`您已${this.timeoutMinutes}分钟未操作,将在1分钟后自动退出`,lastActivityTime:null,isMonitoring:!1,currentTimeoutMinutes:10,currentWarningMinutes:1,reconnectAttempts:0,maxReconnectAttempts:3,reconnectDelay:3e3,isLocalDevelopment:this.checkIfLocalDevelopment(),tokenCheckTimer:null}},mounted(){this.isLoginRoute()||this.initMonitor()},beforeDestroy(){this.destroyMonitor()},watch:{$route(e,t){const n=t.path.includes("/login")||t.href&&t.href.includes("/login"),i=this.isLoginRoute();!n||i||this.isMonitoring?!n&&i&&this.isMonitoring&&this.destroyMonitor():this.initMonitor()}},methods:{isLoginRoute(){return!!(this.$route&&this.$route.path&&this.$route.path.includes("/login"))||"undefined"!==typeof window&&(window.location.pathname.includes("/login")||window.location.href.includes("/login"))},checkIfLocalDevelopment(){if("undefined"!==typeof window){const e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e||"0.0.0.0"===e||/^192\.168\./.test(e)||/^10\./.test(e)||/^172\.(1[6-9]|2[0-9]|3[01])\./.test(e)}return!1},updateTimeoutSettings(e,t){void 0!==e&&(this.currentTimeoutMinutes=e,localStorage.setItem("userBehavior_timeoutMinutes",e.toString())),void 0!==t&&(this.currentWarningMinutes=t,localStorage.setItem("userBehavior_warningMinutes",t.toString())),this.warningMessage=`您已${this.currentTimeoutMinutes}分钟未操作,将在1分钟后自动退出`,this.resetTimer()},initMonitor(){this.isLoginRoute()?this.destroyMonitor():this.isMonitoring||(this.isMonitoring=!0,this.lastActivityTime=Date.now(),this.reconnectAttempts=0,this.initWebSocket(),this.bindEventListeners(),this.startTokenCheckPolling())},destroyMonitor(){this.isMonitoring=!1,this.countdownTimer&&clearInterval(this.countdownTimer),this.warningTimer&&clearTimeout(this.warningTimer),this.tokenCheckTimer&&clearInterval(this.tokenCheckTimer),this.socket&&(this.socket.close(),this.socket=null),this.unbindEventListeners()},initWebSocket(){try{const t=`wss://${location.host}/xy-api/auth-server/ws/user-activity`;let n="";try{const e=localStorage.getItem("api_header");e&&(n=JSON.parse(e).Authorization||"")}catch(e){n=localStorage.getItem("token")||""}this.socket=new WebSocket(`${t}?token=${encodeURIComponent(n)}`),this.socket.onopen=()=>{this.sendUserBehavior(),this.$emit("websocket-open"),this.reconnectAttempts=0},this.socket.onmessage=t=>{try{const e=JSON.parse(t.data);this.handleActivityStatus(e),this.$emit("websocket-message",e)}catch(e){}},this.socket.onclose=e=>{this.$emit("websocket-close"),this.shouldAttemptReconnect()?this.attemptReconnect():!this.isLoginRoute()&&this.isMonitoring&&(this.isLocalDevelopment||this.handleReconnectFailure())},this.socket.onerror=e=>{this.$emit("websocket-error",e),this.shouldAttemptReconnect()?this.attemptReconnect():!this.isLoginRoute()&&this.isMonitoring&&(this.isLocalDevelopment||this.handleReconnectFailure())}}catch(t){this.$emit("websocket-error",t),this.shouldAttemptReconnect()?this.attemptReconnect():!this.isLoginRoute()&&this.isMonitoring&&(this.isLocalDevelopment||this.handleReconnectFailure())}},shouldAttemptReconnect(){return this.isMonitoring&&!this.isLoginRoute()&&this.reconnectAttempts<this.maxReconnectAttempts},attemptReconnect(){this.isLoginRoute()||(this.reconnectAttempts++,console.log(`尝试第${this.reconnectAttempts}次重连...`),this.isLocalDevelopment&&this.reconnectAttempts>=this.maxReconnectAttempts?this.$emit("websocket-reconnect-failed"):!this.isLocalDevelopment&&this.reconnectAttempts>=this.maxReconnectAttempts?this.handleReconnectFailure():setTimeout(()=>{this.initWebSocket()},this.reconnectDelay))},handleReconnectFailure(){this.$emit("logout")},handleActivityStatus(e){if("OTHER_DEVICE_LOGIN_FORCE_LOGOUT"!==e.type&&"FORCE_LOGOUT"!==e.type){if("ACTIVITY_STATUS"===e.type&&e.data){const t=e.data;this.currentTimeoutMinutes=t.noOperateMinutes||10,this.currentWarningMinutes=t.reminderMinutes||1,this.warningMessage=`您已${this.currentTimeoutMinutes}分钟未操作,将在${this.currentWarningMinutes}分钟后自动退出`,t.needReminder&&this.showWarningWarning(t.remainingMillis)}}else this.showtips=!0},handleInactiveStatus(){location.reload(),this.$emit("logout")},sendUserBehavior(e){if(this.socket&&this.socket.readyState===WebSocket.OPEN){const e={type:"HEARTBEAT",message:"心跳"};this.socket.send(JSON.stringify(e))}},bindEventListeners(){document.addEventListener("click",this.handleUserActivity,!0),document.addEventListener("dblclick",this.handleUserActivity,!0),document.addEventListener("mousedown",this.handleUserActivity,!0),document.addEventListener("mouseup",this.handleUserActivity,!0),document.addEventListener("mousemove",this.handleMouseMove,!0),document.addEventListener("mouseover",this.handleUserActivity,!0),document.addEventListener("mouseout",this.handleUserActivity,!0),document.addEventListener("keydown",this.handleUserActivity,!0),document.addEventListener("keyup",this.handleUserActivity,!0),document.addEventListener("input",this.handleUserActivity,!0),document.addEventListener("change",this.handleUserActivity,!0),document.addEventListener("focus",this.handleUserActivity,!0),document.addEventListener("blur",this.handleUserActivity,!0),document.addEventListener("scroll",this.debounce(this.handleUserActivity,300),!0),window.addEventListener("resize",this.handleUserActivity,!0),window.addEventListener("beforeunload",this.handleBeforeUnload)},unbindEventListeners(){document.removeEventListener("click",this.handleUserActivity,!0),document.removeEventListener("dblclick",this.handleUserActivity,!0),document.removeEventListener("mousedown",this.handleUserActivity,!0),document.removeEventListener("mouseup",this.handleUserActivity,!0),document.removeEventListener("mousemove",this.handleMouseMove,!0),document.removeEventListener("mouseover",this.handleUserActivity,!0),document.removeEventListener("mouseout",this.handleUserActivity,!0),document.removeEventListener("keydown",this.handleUserActivity,!0),document.removeEventListener("keyup",this.handleUserActivity,!0),document.removeEventListener("input",this.handleUserActivity,!0),document.removeEventListener("change",this.handleUserActivity,!0),document.removeEventListener("focus",this.handleUserActivity,!0),document.removeEventListener("blur",this.handleUserActivity,!0),document.removeEventListener("scroll",this.debounce(this.handleUserActivity,300),!0),window.removeEventListener("resize",this.handleUserActivity,!0),window.removeEventListener("beforeunload",this.handleBeforeUnload)},handleUserActivity(e){if(this.isAutomaticEvent(e))return;this.resetTimer();const t={eventType:e.type,target:e.target.tagName,timestamp:Date.now(),url:window.location.href};"click"===e.type?(t.clientX=e.clientX,t.clientY=e.clientY):"keydown"===e.type&&(t.key=e.key,t.ctrlKey=e.ctrlKey,t.altKey=e.altKey,t.shiftKey=e.shiftKey),this.sendUserBehavior(t)},handleMouseMove(e){this.mouseMoveThrottled||(this.handleUserActivity(e),this.mouseMoveThrottled=!0,setTimeout(()=>{this.mouseMoveThrottled=!1},500))},isAutomaticEvent(e){return"scroll"===e.type&&!this.isUserScrolling},debounce(e,t){let n;return function(...i){const o=()=>{clearTimeout(n),e.apply(this,i)};clearTimeout(n),n=setTimeout(o,t)}},resetTimer(){this.lastActivityTime=Date.now(),this.showWarning=!1,this.reconnectAttempts=0,this.warningTimer&&(clearTimeout(this.warningTimer),this.warningTimer=null),this.$emit("user-active")},startCountdown(){this.countdownTimer&&clearInterval(this.countdownTimer),this.countdownTimer=setInterval(()=>{const e=Date.now(),t=(e-this.lastActivityTime)/5e4;t>=this.currentTimeoutMinutes-this.currentWarningMinutes&&!this.warningTimer&&this.showWarningWarning(),t>=this.currentTimeoutMinutes&&this.handleTimeout()},1e3)},showWarningWarning(e){let t=e||5e4;console.log("Setting showWarning to true"),this.showWarning=!0,this.$emit("timeout-warning"),this.warningTimer&&clearTimeout(this.warningTimer),this.warningTimer=setTimeout(()=>{this.handleTimeout()},t)},handleTimeout(){this.showWarning=!1,this.$emit("timeout"),this.logout()},logout(){if(this.socket&&this.socket.readyState===WebSocket.OPEN){const e={type:"logout",timestamp:Date.now()};this.socket.send(JSON.stringify(e))}this.$emit("logout"),this.countdownTimer&&clearInterval(this.countdownTimer),this.warningTimer&&clearTimeout(this.warningTimer)},handleBeforeUnload(e){if(this.socket&&this.socket.readyState===WebSocket.OPEN){const e={type:"page_unload",timestamp:Date.now()};this.socket.send(JSON.stringify(e))}},reset(){this.isLoginRoute()?this.destroyMonitor():this.resetTimer()},reconnect(){this.isLoginRoute()?this.destroyMonitor():(this.reconnectAttempts=0,this.socket&&this.socket.close(),this.initWebSocket())},startTokenCheckPolling(){this.tokenCheckTimer&&clearInterval(this.tokenCheckTimer),this.tokenCheckTimer=setInterval(()=>{this.checkToken()},1e3)},checkToken(){if(this.isLoginRoute())return;const e=localStorage.getItem("api_header");e||(console.log("Token不存在,即将刷新页面"),this.handleTokenMissing())},handleTokenMissing(){this.$emit("logout")}}},a=r;n("9303");function c(e,t,n,i,o,s,r,a){var c,u="function"===typeof e?e.options:e;if(t&&(u.render=t,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),s&&(u._scopeId="data-v-"+s),r?(c=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(r)},u._ssrRegister=c):o&&(c=a?function(){o.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:o),c)if(u.functional){u._injectStyles=c;var h=u.render;u.render=function(e,t){return c.call(t),h(e,t)}}else{var l=u.beforeCreate;u.beforeCreate=l?[].concat(l,c):[c]}return{exports:e,options:u}}var u=c(a,o,s,!1,null,null,null),h=u.exports;h.install=function(e){e.component(h.name,h)};var l=h;"undefined"!==typeof window&&window.Vue&&h.install(window.Vue);t["default"]=l}})}));
|
|
1
|
+
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["user-behavior-monitor"]=t():e["user-behavior-monitor"]=t()})("undefined"!==typeof self?self:this,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="fb15")}({"06fd":function(e,t,n){"use strict";n("5c3c")},2350:function(e,t){function n(e,t){var n=e[1]||"",o=e[3];if(!o)return n;if(t&&"function"===typeof btoa){var s=i(o),r=o.sources.map((function(e){return"/*# sourceURL="+o.sourceRoot+e+" */"}));return[n].concat(r).concat([s]).join("\n")}return[n].join("\n")}function i(e){var t=btoa(unescape(encodeURIComponent(JSON.stringify(e)))),n="sourceMappingURL=data:application/json;charset=utf-8;base64,"+t;return"/*# "+n+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i=n(t,e);return t[2]?"@media "+t[2]+"{"+i+"}":i})).join("")},t.i=function(e,n){"string"===typeof e&&(e=[[null,e,""]]);for(var i={},o=0;o<this.length;o++){var s=this[o][0];"number"===typeof s&&(i[s]=!0)}for(o=0;o<e.length;o++){var r=e[o];"number"===typeof r[0]&&i[r[0]]||(n&&!r[2]?r[2]=n:n&&(r[2]="("+r[2]+") and ("+n+")"),t.push(r))}},t}},"499e":function(e,t,n){"use strict";function i(e,t){for(var n=[],i={},o=0;o<t.length;o++){var s=t[o],r=s[0],a=s[1],c=s[2],l=s[3],u={id:e+":"+o,css:a,media:c,sourceMap:l};i[r]?i[r].parts.push(u):n.push(i[r]={id:r,parts:[u]})}return n}n.r(t),n.d(t,"default",(function(){return v}));var o="undefined"!==typeof document;if("undefined"!==typeof DEBUG&&DEBUG&&!o)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var s={},r=o&&(document.head||document.getElementsByTagName("head")[0]),a=null,c=0,l=!1,u=function(){},h=null,d="data-vue-ssr-id",m="undefined"!==typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function v(e,t,n,o){l=n,h=o||{};var r=i(e,t);return p(r),function(t){for(var n=[],o=0;o<r.length;o++){var a=r[o],c=s[a.id];c.refs--,n.push(c)}t?(r=i(e,t),p(r)):r=[];for(o=0;o<n.length;o++){c=n[o];if(0===c.refs){for(var l=0;l<c.parts.length;l++)c.parts[l]();delete s[c.id]}}}}function p(e){for(var t=0;t<e.length;t++){var n=e[t],i=s[n.id];if(i){i.refs++;for(var o=0;o<i.parts.length;o++)i.parts[o](n.parts[o]);for(;o<n.parts.length;o++)i.parts.push(g(n.parts[o]));i.parts.length>n.parts.length&&(i.parts.length=n.parts.length)}else{var r=[];for(o=0;o<n.parts.length;o++)r.push(g(n.parts[o]));s[n.id]={id:n.id,refs:1,parts:r}}}}function f(){var e=document.createElement("style");return e.type="text/css",r.appendChild(e),e}function g(e){var t,n,i=document.querySelector("style["+d+'~="'+e.id+'"]');if(i){if(l)return u;i.parentNode.removeChild(i)}if(m){var o=c++;i=a||(a=f()),t=w.bind(null,i,o,!1),n=w.bind(null,i,o,!0)}else i=f(),t=T.bind(null,i),n=function(){i.parentNode.removeChild(i)};return t(e),function(i){if(i){if(i.css===e.css&&i.media===e.media&&i.sourceMap===e.sourceMap)return;t(e=i)}else n()}}var y=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}();function w(e,t,n,i){var o=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=y(t,o);else{var s=document.createTextNode(o),r=e.childNodes;r[t]&&e.removeChild(r[t]),r.length?e.insertBefore(s,r[t]):e.appendChild(s)}}function T(e,t){var n=t.css,i=t.media,o=t.sourceMap;if(i&&e.setAttribute("media",i),h.ssrId&&e.setAttribute(d,t.id),o&&(n+="\n/*# sourceURL="+o.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{while(e.firstChild)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}},"5c3c":function(e,t,n){var i=n("c340");i.__esModule&&(i=i.default),"string"===typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);var o=n("499e").default;o("7f9ef077",i,!0,{sourceMap:!1,shadowMode:!1})},c340:function(e,t,n){t=e.exports=n("2350")(!1),t.push([e.i,".behavior-warning-dialog.el-dialog.el-dialog--center{text-align:left}.behavior-warning-dialog .el-dialog__footer{text-align:right!important}.el-alert--warning.is-light{background-color:#382b22!important;color:#e19212!important}",""])},fb15:function(e,t,n){"use strict";var i;(n.r(t),n.d(t,"UserBehaviorMonitor",(function(){return u})),"undefined"!==typeof window)&&((i=window.document.currentScript)&&(i=i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=i[1]));var o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"behaviorMonitor",staticClass:"user-behavior-monitor"},[n("el-dialog",{attrs:{title:"提示",visible:e.showWarning,"show-close":!1,modal:!0,width:"30%",center:"","custom-class":"behavior-warning-dialog"},on:{"update:visible":function(t){e.showWarning=t}}},[n("span",[e._v(e._s(e.warningMessage))])]),n("el-dialog",{attrs:{title:"提示",visible:e.showtips,"close-on-click-modal":!1,"close-on-press-escape":!1,"show-close":!1,modal:!0,width:"30%",center:"","custom-class":"behavior-warning-dialog"},on:{"update:visible":function(t){e.showtips=t}}},[n("el-alert",{staticStyle:{margin:"10px 0"},attrs:{title:"该账号已在其他设备登录!",type:"warning",closable:!1,"show-icon":""}}),n("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[n("el-button",{attrs:{type:"primary",size:"mini"},on:{click:e.handleReconnectFailure}},[e._v("确 定")])],1)],1)],1)},s=[],r={name:"UserBehaviorMonitor",props:{timeoutMinutes:{type:Number,default:10},warningMinutes:{type:Number,default:1}},data(){return{showtips:!1,mouseMoveThrottled:!1,socket:null,countdownTimer:null,warningTimer:null,showWarning:!1,warningMessage:`您已${this.timeoutMinutes}分钟未操作,将在1分钟后自动退出`,lastActivityTime:null,isMonitoring:!1,currentTimeoutMinutes:10,currentWarningMinutes:1,reconnectAttempts:0,maxReconnectAttempts:3,reconnectDelay:3e3,isLocalDevelopment:this.checkIfLocalDevelopment(),tokenCheckTimer:null}},mounted(){this.isLoginRoute()||this.initMonitor()},beforeDestroy(){this.destroyMonitor()},watch:{$route(e,t){const n=t.path.includes("/login")||t.href&&t.href.includes("/login"),i=this.isLoginRoute();!n||i||this.isMonitoring?!n&&i&&this.isMonitoring&&this.destroyMonitor():this.initMonitor()}},methods:{isLoginRoute(){return!!(this.$route&&this.$route.path&&this.$route.path.includes("/login"))||"undefined"!==typeof window&&(window.location.pathname.includes("/login")||window.location.href.includes("/login"))},checkIfLocalDevelopment(){if("undefined"!==typeof window){const e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e||"0.0.0.0"===e||/^192\.168\./.test(e)||/^10\./.test(e)||/^172\.(1[6-9]|2[0-9]|3[01])\./.test(e)}return!1},updateTimeoutSettings(e,t){void 0!==e&&(this.currentTimeoutMinutes=e,localStorage.setItem("userBehavior_timeoutMinutes",e.toString())),void 0!==t&&(this.currentWarningMinutes=t,localStorage.setItem("userBehavior_warningMinutes",t.toString())),this.warningMessage=`您已${this.currentTimeoutMinutes}分钟未操作,将在1分钟后自动退出`,this.resetTimer()},initMonitor(){this.isLoginRoute()?this.destroyMonitor():this.isMonitoring||(this.isMonitoring=!0,this.lastActivityTime=Date.now(),this.reconnectAttempts=0,this.initWebSocket(),this.bindEventListeners(),this.startTokenCheckPolling())},destroyMonitor(){this.isMonitoring=!1,this.countdownTimer&&clearInterval(this.countdownTimer),this.warningTimer&&clearTimeout(this.warningTimer),this.tokenCheckTimer&&clearInterval(this.tokenCheckTimer),this.socket&&(this.socket.close(),this.socket=null),this.unbindEventListeners()},initWebSocket(){try{const t=`wss://${location.host}/xy-api/auth-server/ws/user-activity`;let n="";try{const e=localStorage.getItem("api_header");e&&(n=JSON.parse(e).Authorization||"")}catch(e){n=localStorage.getItem("token")||""}this.socket=new WebSocket(`${t}?token=${encodeURIComponent(n)}`),this.socket.onopen=()=>{console.log("WebSocket连接已建立"),this.sendUserBehavior(),this.$emit("websocket-open"),this.reconnectAttempts=0},this.socket.onmessage=t=>{try{const e=JSON.parse(t.data);console.log("收到用户活动状态消息:",e),this.handleActivityStatus(e),this.$emit("websocket-message",e)}catch(e){console.error("解析WebSocket消息失败:",e)}},this.socket.onclose=e=>{console.log("WebSocket连接已断开:",e.reason),this.$emit("websocket-close"),this.shouldAttemptReconnect()?this.attemptReconnect():!this.isLoginRoute()&&this.isMonitoring&&(this.isLocalDevelopment||this.handleReconnectFailure())},this.socket.onerror=e=>{this.$emit("websocket-error",e),this.shouldAttemptReconnect()?this.attemptReconnect():!this.isLoginRoute()&&this.isMonitoring&&(this.isLocalDevelopment||this.handleReconnectFailure())}}catch(t){this.$emit("websocket-error",t),this.shouldAttemptReconnect()?this.attemptReconnect():!this.isLoginRoute()&&this.isMonitoring&&(this.isLocalDevelopment||this.handleReconnectFailure())}},shouldAttemptReconnect(){return this.isMonitoring&&!this.isLoginRoute()&&this.reconnectAttempts<this.maxReconnectAttempts},attemptReconnect(){this.isLoginRoute()||(this.reconnectAttempts++,console.log(`尝试第${this.reconnectAttempts}次重连...`),this.isLocalDevelopment&&this.reconnectAttempts>=this.maxReconnectAttempts?this.$emit("websocket-reconnect-failed"):!this.isLocalDevelopment&&this.reconnectAttempts>=this.maxReconnectAttempts||setTimeout(()=>{this.initWebSocket()},this.reconnectDelay))},handleReconnectFailure(){localStorage.clear(),sessionStorage.clear(),location.reload(),this.$emit("logout")},handleActivityStatus(e){if("OTHER_DEVICE_LOGIN_FORCE_LOGOUT"!==e.type&&"FORCE_LOGOUT"!==e.type){if("ACTIVITY_STATUS"===e.type&&e.data){const t=e.data;this.currentTimeoutMinutes=t.noOperateMinutes||10,this.currentWarningMinutes=t.reminderMinutes||1,this.warningMessage=`您已${this.currentTimeoutMinutes}分钟未操作,将在${this.currentWarningMinutes}分钟后自动退出`,t.needReminder&&this.showWarningWarning(t.remainingMillis)}}else this.showtips=!0},handleInactiveStatus(){localStorage.clear(),sessionStorage.clear(),this.$router.push("/login"),location.reload(),this.$emit("logout")},sendUserBehavior(e){if(this.socket&&this.socket.readyState===WebSocket.OPEN){const e={type:"HEARTBEAT",message:"心跳"};console.log("用户行为监测:",JSON.stringify(e)),this.socket.send(JSON.stringify(e))}},bindEventListeners(){document.addEventListener("click",this.handleUserActivity,!0),document.addEventListener("dblclick",this.handleUserActivity,!0),document.addEventListener("mousedown",this.handleUserActivity,!0),document.addEventListener("mouseup",this.handleUserActivity,!0),document.addEventListener("mousemove",this.handleMouseMove,!0),document.addEventListener("mouseover",this.handleUserActivity,!0),document.addEventListener("mouseout",this.handleUserActivity,!0),document.addEventListener("keydown",this.handleUserActivity,!0),document.addEventListener("keyup",this.handleUserActivity,!0),document.addEventListener("input",this.handleUserActivity,!0),document.addEventListener("change",this.handleUserActivity,!0),document.addEventListener("focus",this.handleUserActivity,!0),document.addEventListener("blur",this.handleUserActivity,!0),document.addEventListener("scroll",this.debounce(this.handleUserActivity,300),!0),window.addEventListener("resize",this.handleUserActivity,!0),window.addEventListener("beforeunload",this.handleBeforeUnload)},unbindEventListeners(){document.removeEventListener("click",this.handleUserActivity,!0),document.removeEventListener("dblclick",this.handleUserActivity,!0),document.removeEventListener("mousedown",this.handleUserActivity,!0),document.removeEventListener("mouseup",this.handleUserActivity,!0),document.removeEventListener("mousemove",this.handleMouseMove,!0),document.removeEventListener("mouseover",this.handleUserActivity,!0),document.removeEventListener("mouseout",this.handleUserActivity,!0),document.removeEventListener("keydown",this.handleUserActivity,!0),document.removeEventListener("keyup",this.handleUserActivity,!0),document.removeEventListener("input",this.handleUserActivity,!0),document.removeEventListener("change",this.handleUserActivity,!0),document.removeEventListener("focus",this.handleUserActivity,!0),document.removeEventListener("blur",this.handleUserActivity,!0),document.removeEventListener("scroll",this.debounce(this.handleUserActivity,300),!0),window.removeEventListener("resize",this.handleUserActivity,!0),window.removeEventListener("beforeunload",this.handleBeforeUnload)},handleUserActivity(e){if(this.isAutomaticEvent(e))return;this.resetTimer();const t={eventType:e.type,target:e.target.tagName,timestamp:Date.now(),url:window.location.href};"click"===e.type?(t.clientX=e.clientX,t.clientY=e.clientY):"keydown"===e.type&&(t.key=e.key,t.ctrlKey=e.ctrlKey,t.altKey=e.altKey,t.shiftKey=e.shiftKey),this.sendUserBehavior(t)},handleMouseMove(e){this.mouseMoveThrottled||(this.handleUserActivity(e),this.mouseMoveThrottled=!0,setTimeout(()=>{this.mouseMoveThrottled=!1},500))},isAutomaticEvent(e){return"scroll"===e.type&&!this.isUserScrolling},debounce(e,t){let n;return function(...i){const o=()=>{clearTimeout(n),e.apply(this,i)};clearTimeout(n),n=setTimeout(o,t)}},resetTimer(){this.lastActivityTime=Date.now(),this.showWarning=!1,this.reconnectAttempts=0,this.warningTimer&&(clearTimeout(this.warningTimer),this.warningTimer=null),this.$emit("user-active")},startCountdown(){this.countdownTimer&&clearInterval(this.countdownTimer),this.countdownTimer=setInterval(()=>{const e=Date.now(),t=(e-this.lastActivityTime)/5e4;t>=this.currentTimeoutMinutes-this.currentWarningMinutes&&!this.warningTimer&&this.showWarningWarning(),t>=this.currentTimeoutMinutes&&this.handleTimeout()},1e3)},showWarningWarning(e){let t=e||5e4;console.log("Setting showWarning to true"),this.showWarning=!0,this.$emit("timeout-warning"),this.warningTimer&&clearTimeout(this.warningTimer),this.warningTimer=setTimeout(()=>{this.handleTimeout()},t)},handleTimeout(){this.showWarning=!1,this.$emit("timeout"),this.logout()},logout(){if(localStorage.clear(),sessionStorage.clear(),location.reload(),this.socket&&this.socket.readyState===WebSocket.OPEN){const e={type:"logout",timestamp:Date.now()};this.socket.send(JSON.stringify(e))}this.$emit("logout"),this.countdownTimer&&clearInterval(this.countdownTimer),this.warningTimer&&clearTimeout(this.warningTimer)},handleBeforeUnload(e){if(this.socket&&this.socket.readyState===WebSocket.OPEN){const e={type:"page_unload",timestamp:Date.now()};this.socket.send(JSON.stringify(e))}},reset(){this.isLoginRoute()?this.destroyMonitor():this.resetTimer()},reconnect(){this.isLoginRoute()?this.destroyMonitor():(this.reconnectAttempts=0,this.socket&&this.socket.close(),this.initWebSocket())},startTokenCheckPolling(){this.tokenCheckTimer&&clearInterval(this.tokenCheckTimer),this.tokenCheckTimer=setInterval(()=>{this.checkToken()},1e3)},checkToken(){if(this.isLoginRoute())return;const e=localStorage.getItem("api_header");e||(console.log("Token不存在,即将刷新页面"),this.handleTokenMissing())},handleTokenMissing(){localStorage.clear(),sessionStorage.clear(),location.reload(),this.$emit("logout")}}},a=r;n("06fd");function c(e,t,n,i,o,s,r,a){var c,l="function"===typeof e?e.options:e;if(t&&(l.render=t,l.staticRenderFns=n,l._compiled=!0),i&&(l.functional=!0),s&&(l._scopeId="data-v-"+s),r?(c=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(r)},l._ssrRegister=c):o&&(c=a?function(){o.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:o),c)if(l.functional){l._injectStyles=c;var u=l.render;l.render=function(e,t){return c.call(t),u(e,t)}}else{var h=l.beforeCreate;l.beforeCreate=h?[].concat(h,c):[c]}return{exports:e,options:l}}var l=c(a,o,s,!1,null,null,null),u=l.exports;u.install=function(e){e.component(u.name,u)};var h=u;"undefined"!==typeof window&&window.Vue&&u.install(window.Vue);t["default"]=h}})}));
|
package/package.json
CHANGED
|
@@ -235,7 +235,7 @@ export default {
|
|
|
235
235
|
|
|
236
236
|
// 设置连接成功回调
|
|
237
237
|
this.socket.onopen = () => {
|
|
238
|
-
|
|
238
|
+
console.log('WebSocket连接已建立');
|
|
239
239
|
this.sendUserBehavior();
|
|
240
240
|
this.$emit('websocket-open');
|
|
241
241
|
// 连接成功时重置重连尝试次数
|
|
@@ -246,17 +246,17 @@ export default {
|
|
|
246
246
|
this.socket.onmessage = (event) => {
|
|
247
247
|
try {
|
|
248
248
|
const data = JSON.parse(event.data);
|
|
249
|
-
|
|
249
|
+
console.log('收到用户活动状态消息:', data);
|
|
250
250
|
this.handleActivityStatus(data);
|
|
251
251
|
this.$emit('websocket-message', data);
|
|
252
252
|
} catch (e) {
|
|
253
|
-
|
|
253
|
+
console.error('解析WebSocket消息失败:', e);
|
|
254
254
|
}
|
|
255
255
|
};
|
|
256
256
|
|
|
257
257
|
// 设置连接关闭回调
|
|
258
258
|
this.socket.onclose = (event) => {
|
|
259
|
-
|
|
259
|
+
console.log('WebSocket连接已断开:', event.reason);
|
|
260
260
|
this.$emit('websocket-close');
|
|
261
261
|
|
|
262
262
|
// 如果不是在登录页面且监控仍在运行,尝试重连
|
|
@@ -330,7 +330,7 @@ export default {
|
|
|
330
330
|
// 如果是线上环境且重连次数已达到最大值,则跳转到登录页
|
|
331
331
|
if (!this.isLocalDevelopment && this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
332
332
|
// console.log('线上环境,重连失败,跳转到登录页');
|
|
333
|
-
this.handleReconnectFailure();
|
|
333
|
+
// this.handleReconnectFailure();
|
|
334
334
|
return;
|
|
335
335
|
}
|
|
336
336
|
|
|
@@ -342,12 +342,12 @@ export default {
|
|
|
342
342
|
// 处理重连失败
|
|
343
343
|
handleReconnectFailure() {
|
|
344
344
|
// 清空缓存
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
localStorage.clear();
|
|
346
|
+
sessionStorage.clear();
|
|
347
347
|
|
|
348
348
|
// 跳转到登录页
|
|
349
349
|
|
|
350
|
-
|
|
350
|
+
location.reload();
|
|
351
351
|
|
|
352
352
|
// 触发登出事件
|
|
353
353
|
this.$emit('logout');
|
|
@@ -389,11 +389,11 @@ export default {
|
|
|
389
389
|
// 处理非活跃状态
|
|
390
390
|
handleInactiveStatus() {
|
|
391
391
|
// 清空缓存
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
localStorage.clear();
|
|
393
|
+
sessionStorage.clear();
|
|
394
394
|
|
|
395
395
|
// 跳转到登录页
|
|
396
|
-
|
|
396
|
+
this.$router.push('/login');
|
|
397
397
|
|
|
398
398
|
// 或者使用window.location
|
|
399
399
|
|
|
@@ -411,7 +411,7 @@ export default {
|
|
|
411
411
|
"type": "HEARTBEAT",
|
|
412
412
|
"message": "心跳",
|
|
413
413
|
};
|
|
414
|
-
|
|
414
|
+
console.log('用户行为监测:', JSON.stringify(message));
|
|
415
415
|
this.socket.send(JSON.stringify(message));
|
|
416
416
|
}
|
|
417
417
|
},
|
|
@@ -593,9 +593,9 @@ export default {
|
|
|
593
593
|
|
|
594
594
|
// 登出操作
|
|
595
595
|
logout() {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
596
|
+
localStorage.clear();
|
|
597
|
+
sessionStorage.clear();
|
|
598
|
+
location.reload();
|
|
599
599
|
// 跳转到登录页
|
|
600
600
|
//this.$router.push('/login');
|
|
601
601
|
|
|
@@ -691,11 +691,11 @@ export default {
|
|
|
691
691
|
// 新增:处理token缺失的情况
|
|
692
692
|
handleTokenMissing() {
|
|
693
693
|
// 清空缓存
|
|
694
|
-
|
|
695
|
-
|
|
694
|
+
localStorage.clear();
|
|
695
|
+
sessionStorage.clear();
|
|
696
696
|
|
|
697
697
|
// 刷新页面
|
|
698
|
-
|
|
698
|
+
location.reload();
|
|
699
699
|
|
|
700
700
|
// 触发登出事件
|
|
701
701
|
this.$emit('logout');
|