user-behavior-monitor 1.0.0

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.
@@ -0,0 +1,1001 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define([], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["user-behavior-monitor"] = factory();
8
+ else
9
+ root["user-behavior-monitor"] = factory();
10
+ })((typeof self !== 'undefined' ? self : this), function() {
11
+ return /******/ (function(modules) { // webpackBootstrap
12
+ /******/ // The module cache
13
+ /******/ var installedModules = {};
14
+ /******/
15
+ /******/ // The require function
16
+ /******/ function __webpack_require__(moduleId) {
17
+ /******/
18
+ /******/ // Check if module is in cache
19
+ /******/ if(installedModules[moduleId]) {
20
+ /******/ return installedModules[moduleId].exports;
21
+ /******/ }
22
+ /******/ // Create a new module (and put it into the cache)
23
+ /******/ var module = installedModules[moduleId] = {
24
+ /******/ i: moduleId,
25
+ /******/ l: false,
26
+ /******/ exports: {}
27
+ /******/ };
28
+ /******/
29
+ /******/ // Execute the module function
30
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
+ /******/
32
+ /******/ // Flag the module as loaded
33
+ /******/ module.l = true;
34
+ /******/
35
+ /******/ // Return the exports of the module
36
+ /******/ return module.exports;
37
+ /******/ }
38
+ /******/
39
+ /******/
40
+ /******/ // expose the modules object (__webpack_modules__)
41
+ /******/ __webpack_require__.m = modules;
42
+ /******/
43
+ /******/ // expose the module cache
44
+ /******/ __webpack_require__.c = installedModules;
45
+ /******/
46
+ /******/ // define getter function for harmony exports
47
+ /******/ __webpack_require__.d = function(exports, name, getter) {
48
+ /******/ if(!__webpack_require__.o(exports, name)) {
49
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50
+ /******/ }
51
+ /******/ };
52
+ /******/
53
+ /******/ // define __esModule on exports
54
+ /******/ __webpack_require__.r = function(exports) {
55
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57
+ /******/ }
58
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
59
+ /******/ };
60
+ /******/
61
+ /******/ // create a fake namespace object
62
+ /******/ // mode & 1: value is a module id, require it
63
+ /******/ // mode & 2: merge all properties of value into the ns
64
+ /******/ // mode & 4: return value when already ns object
65
+ /******/ // mode & 8|1: behave like require
66
+ /******/ __webpack_require__.t = function(value, mode) {
67
+ /******/ if(mode & 1) value = __webpack_require__(value);
68
+ /******/ if(mode & 8) return value;
69
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70
+ /******/ var ns = Object.create(null);
71
+ /******/ __webpack_require__.r(ns);
72
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74
+ /******/ return ns;
75
+ /******/ };
76
+ /******/
77
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
78
+ /******/ __webpack_require__.n = function(module) {
79
+ /******/ var getter = module && module.__esModule ?
80
+ /******/ function getDefault() { return module['default']; } :
81
+ /******/ function getModuleExports() { return module; };
82
+ /******/ __webpack_require__.d(getter, 'a', getter);
83
+ /******/ return getter;
84
+ /******/ };
85
+ /******/
86
+ /******/ // Object.prototype.hasOwnProperty.call
87
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88
+ /******/
89
+ /******/ // __webpack_public_path__
90
+ /******/ __webpack_require__.p = "";
91
+ /******/
92
+ /******/
93
+ /******/ // Load entry module and return exports
94
+ /******/ return __webpack_require__(__webpack_require__.s = "fb15");
95
+ /******/ })
96
+ /************************************************************************/
97
+ /******/ ({
98
+
99
+ /***/ "2350":
100
+ /***/ (function(module, exports) {
101
+
102
+ /*
103
+ MIT License http://www.opensource.org/licenses/mit-license.php
104
+ Author Tobias Koppers @sokra
105
+ */
106
+ // css base code, injected by the css-loader
107
+ module.exports = function(useSourceMap) {
108
+ var list = [];
109
+
110
+ // return the list of modules as css string
111
+ list.toString = function toString() {
112
+ return this.map(function (item) {
113
+ var content = cssWithMappingToString(item, useSourceMap);
114
+ if(item[2]) {
115
+ return "@media " + item[2] + "{" + content + "}";
116
+ } else {
117
+ return content;
118
+ }
119
+ }).join("");
120
+ };
121
+
122
+ // import a list of modules into the list
123
+ list.i = function(modules, mediaQuery) {
124
+ if(typeof modules === "string")
125
+ modules = [[null, modules, ""]];
126
+ var alreadyImportedModules = {};
127
+ for(var i = 0; i < this.length; i++) {
128
+ var id = this[i][0];
129
+ if(typeof id === "number")
130
+ alreadyImportedModules[id] = true;
131
+ }
132
+ for(i = 0; i < modules.length; i++) {
133
+ var item = modules[i];
134
+ // skip already imported module
135
+ // this implementation is not 100% perfect for weird media query combinations
136
+ // when a module is imported multiple times with different media queries.
137
+ // I hope this will never occur (Hey this way we have smaller bundles)
138
+ if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
139
+ if(mediaQuery && !item[2]) {
140
+ item[2] = mediaQuery;
141
+ } else if(mediaQuery) {
142
+ item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
143
+ }
144
+ list.push(item);
145
+ }
146
+ }
147
+ };
148
+ return list;
149
+ };
150
+
151
+ function cssWithMappingToString(item, useSourceMap) {
152
+ var content = item[1] || '';
153
+ var cssMapping = item[3];
154
+ if (!cssMapping) {
155
+ return content;
156
+ }
157
+
158
+ if (useSourceMap && typeof btoa === 'function') {
159
+ var sourceMapping = toComment(cssMapping);
160
+ var sourceURLs = cssMapping.sources.map(function (source) {
161
+ return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
162
+ });
163
+
164
+ return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
165
+ }
166
+
167
+ return [content].join('\n');
168
+ }
169
+
170
+ // Adapted from convert-source-map (MIT)
171
+ function toComment(sourceMap) {
172
+ // eslint-disable-next-line no-undef
173
+ var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
174
+ var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
175
+
176
+ return '/*# ' + data + ' */';
177
+ }
178
+
179
+
180
+ /***/ }),
181
+
182
+ /***/ "499e":
183
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
184
+
185
+ "use strict";
186
+ // ESM COMPAT FLAG
187
+ __webpack_require__.r(__webpack_exports__);
188
+
189
+ // EXPORTS
190
+ __webpack_require__.d(__webpack_exports__, "default", function() { return /* binding */ addStylesClient; });
191
+
192
+ // CONCATENATED MODULE: ./node_modules/vue-style-loader/lib/listToStyles.js
193
+ /**
194
+ * Translates the list format produced by css-loader into something
195
+ * easier to manipulate.
196
+ */
197
+ function listToStyles (parentId, list) {
198
+ var styles = []
199
+ var newStyles = {}
200
+ for (var i = 0; i < list.length; i++) {
201
+ var item = list[i]
202
+ var id = item[0]
203
+ var css = item[1]
204
+ var media = item[2]
205
+ var sourceMap = item[3]
206
+ var part = {
207
+ id: parentId + ':' + i,
208
+ css: css,
209
+ media: media,
210
+ sourceMap: sourceMap
211
+ }
212
+ if (!newStyles[id]) {
213
+ styles.push(newStyles[id] = { id: id, parts: [part] })
214
+ } else {
215
+ newStyles[id].parts.push(part)
216
+ }
217
+ }
218
+ return styles
219
+ }
220
+
221
+ // CONCATENATED MODULE: ./node_modules/vue-style-loader/lib/addStylesClient.js
222
+ /*
223
+ MIT License http://www.opensource.org/licenses/mit-license.php
224
+ Author Tobias Koppers @sokra
225
+ Modified by Evan You @yyx990803
226
+ */
227
+
228
+
229
+
230
+ var hasDocument = typeof document !== 'undefined'
231
+
232
+ if (typeof DEBUG !== 'undefined' && DEBUG) {
233
+ if (!hasDocument) {
234
+ throw new Error(
235
+ 'vue-style-loader cannot be used in a non-browser environment. ' +
236
+ "Use { target: 'node' } in your Webpack config to indicate a server-rendering environment."
237
+ ) }
238
+ }
239
+
240
+ /*
241
+ type StyleObject = {
242
+ id: number;
243
+ parts: Array<StyleObjectPart>
244
+ }
245
+
246
+ type StyleObjectPart = {
247
+ css: string;
248
+ media: string;
249
+ sourceMap: ?string
250
+ }
251
+ */
252
+
253
+ var stylesInDom = {/*
254
+ [id: number]: {
255
+ id: number,
256
+ refs: number,
257
+ parts: Array<(obj?: StyleObjectPart) => void>
258
+ }
259
+ */}
260
+
261
+ var head = hasDocument && (document.head || document.getElementsByTagName('head')[0])
262
+ var singletonElement = null
263
+ var singletonCounter = 0
264
+ var isProduction = false
265
+ var noop = function () {}
266
+ var options = null
267
+ var ssrIdKey = 'data-vue-ssr-id'
268
+
269
+ // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
270
+ // tags it will allow on a page
271
+ var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\b/.test(navigator.userAgent.toLowerCase())
272
+
273
+ function addStylesClient (parentId, list, _isProduction, _options) {
274
+ isProduction = _isProduction
275
+
276
+ options = _options || {}
277
+
278
+ var styles = listToStyles(parentId, list)
279
+ addStylesToDom(styles)
280
+
281
+ return function update (newList) {
282
+ var mayRemove = []
283
+ for (var i = 0; i < styles.length; i++) {
284
+ var item = styles[i]
285
+ var domStyle = stylesInDom[item.id]
286
+ domStyle.refs--
287
+ mayRemove.push(domStyle)
288
+ }
289
+ if (newList) {
290
+ styles = listToStyles(parentId, newList)
291
+ addStylesToDom(styles)
292
+ } else {
293
+ styles = []
294
+ }
295
+ for (var i = 0; i < mayRemove.length; i++) {
296
+ var domStyle = mayRemove[i]
297
+ if (domStyle.refs === 0) {
298
+ for (var j = 0; j < domStyle.parts.length; j++) {
299
+ domStyle.parts[j]()
300
+ }
301
+ delete stylesInDom[domStyle.id]
302
+ }
303
+ }
304
+ }
305
+ }
306
+
307
+ function addStylesToDom (styles /* Array<StyleObject> */) {
308
+ for (var i = 0; i < styles.length; i++) {
309
+ var item = styles[i]
310
+ var domStyle = stylesInDom[item.id]
311
+ if (domStyle) {
312
+ domStyle.refs++
313
+ for (var j = 0; j < domStyle.parts.length; j++) {
314
+ domStyle.parts[j](item.parts[j])
315
+ }
316
+ for (; j < item.parts.length; j++) {
317
+ domStyle.parts.push(addStyle(item.parts[j]))
318
+ }
319
+ if (domStyle.parts.length > item.parts.length) {
320
+ domStyle.parts.length = item.parts.length
321
+ }
322
+ } else {
323
+ var parts = []
324
+ for (var j = 0; j < item.parts.length; j++) {
325
+ parts.push(addStyle(item.parts[j]))
326
+ }
327
+ stylesInDom[item.id] = { id: item.id, refs: 1, parts: parts }
328
+ }
329
+ }
330
+ }
331
+
332
+ function createStyleElement () {
333
+ var styleElement = document.createElement('style')
334
+ styleElement.type = 'text/css'
335
+ head.appendChild(styleElement)
336
+ return styleElement
337
+ }
338
+
339
+ function addStyle (obj /* StyleObjectPart */) {
340
+ var update, remove
341
+ var styleElement = document.querySelector('style[' + ssrIdKey + '~="' + obj.id + '"]')
342
+
343
+ if (styleElement) {
344
+ if (isProduction) {
345
+ // has SSR styles and in production mode.
346
+ // simply do nothing.
347
+ return noop
348
+ } else {
349
+ // has SSR styles but in dev mode.
350
+ // for some reason Chrome can't handle source map in server-rendered
351
+ // style tags - source maps in <style> only works if the style tag is
352
+ // created and inserted dynamically. So we remove the server rendered
353
+ // styles and inject new ones.
354
+ styleElement.parentNode.removeChild(styleElement)
355
+ }
356
+ }
357
+
358
+ if (isOldIE) {
359
+ // use singleton mode for IE9.
360
+ var styleIndex = singletonCounter++
361
+ styleElement = singletonElement || (singletonElement = createStyleElement())
362
+ update = applyToSingletonTag.bind(null, styleElement, styleIndex, false)
363
+ remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true)
364
+ } else {
365
+ // use multi-style-tag mode in all other cases
366
+ styleElement = createStyleElement()
367
+ update = applyToTag.bind(null, styleElement)
368
+ remove = function () {
369
+ styleElement.parentNode.removeChild(styleElement)
370
+ }
371
+ }
372
+
373
+ update(obj)
374
+
375
+ return function updateStyle (newObj /* StyleObjectPart */) {
376
+ if (newObj) {
377
+ if (newObj.css === obj.css &&
378
+ newObj.media === obj.media &&
379
+ newObj.sourceMap === obj.sourceMap) {
380
+ return
381
+ }
382
+ update(obj = newObj)
383
+ } else {
384
+ remove()
385
+ }
386
+ }
387
+ }
388
+
389
+ var replaceText = (function () {
390
+ var textStore = []
391
+
392
+ return function (index, replacement) {
393
+ textStore[index] = replacement
394
+ return textStore.filter(Boolean).join('\n')
395
+ }
396
+ })()
397
+
398
+ function applyToSingletonTag (styleElement, index, remove, obj) {
399
+ var css = remove ? '' : obj.css
400
+
401
+ if (styleElement.styleSheet) {
402
+ styleElement.styleSheet.cssText = replaceText(index, css)
403
+ } else {
404
+ var cssNode = document.createTextNode(css)
405
+ var childNodes = styleElement.childNodes
406
+ if (childNodes[index]) styleElement.removeChild(childNodes[index])
407
+ if (childNodes.length) {
408
+ styleElement.insertBefore(cssNode, childNodes[index])
409
+ } else {
410
+ styleElement.appendChild(cssNode)
411
+ }
412
+ }
413
+ }
414
+
415
+ function applyToTag (styleElement, obj) {
416
+ var css = obj.css
417
+ var media = obj.media
418
+ var sourceMap = obj.sourceMap
419
+
420
+ if (media) {
421
+ styleElement.setAttribute('media', media)
422
+ }
423
+ if (options.ssrId) {
424
+ styleElement.setAttribute(ssrIdKey, obj.id)
425
+ }
426
+
427
+ if (sourceMap) {
428
+ // https://developer.chrome.com/devtools/docs/javascript-debugging
429
+ // this makes source maps inside style tags work properly in Chrome
430
+ css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
431
+ // http://stackoverflow.com/a/26603875
432
+ css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
433
+ }
434
+
435
+ if (styleElement.styleSheet) {
436
+ styleElement.styleSheet.cssText = css
437
+ } else {
438
+ while (styleElement.firstChild) {
439
+ styleElement.removeChild(styleElement.firstChild)
440
+ }
441
+ styleElement.appendChild(document.createTextNode(css))
442
+ }
443
+ }
444
+
445
+
446
+ /***/ }),
447
+
448
+ /***/ "533e":
449
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
450
+
451
+ "use strict";
452
+ /* 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_06a138e4_prod_scoped_true_lang_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("d1b1");
453
+ /* 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_06a138e4_prod_scoped_true_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_06a138e4_prod_scoped_true_lang_css__WEBPACK_IMPORTED_MODULE_0__);
454
+ /* unused harmony reexport * */
455
+
456
+
457
+ /***/ }),
458
+
459
+ /***/ "9cfc":
460
+ /***/ (function(module, exports, __webpack_require__) {
461
+
462
+ exports = module.exports = __webpack_require__("2350")(false);
463
+ // imports
464
+
465
+
466
+ // module
467
+ exports.push([module.i, ".user-behavior-monitor[data-v-06a138e4]{display:none}.behavior-warning-dialog[data-v-06a138e4] .el-dialog__body{text-align:center;font-size:16px;padding:30px 20px}.behavior-warning-dialog[data-v-06a138e4]{z-index:9999!important}", ""]);
468
+
469
+ // exports
470
+
471
+
472
+ /***/ }),
473
+
474
+ /***/ "d1b1":
475
+ /***/ (function(module, exports, __webpack_require__) {
476
+
477
+ // style-loader: Adds some css to the DOM by adding a <style> tag
478
+
479
+ // load the styles
480
+ var content = __webpack_require__("9cfc");
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("2c53b590", content, true, {"sourceMap":false,"shadowMode":false});
487
+
488
+ /***/ }),
489
+
490
+ /***/ "fb15":
491
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
492
+
493
+ "use strict";
494
+ // ESM COMPAT FLAG
495
+ __webpack_require__.r(__webpack_exports__);
496
+
497
+ // EXPORTS
498
+ __webpack_require__.d(__webpack_exports__, "UserBehaviorMonitor", function() { return /* reexport */ UserBehaviorMonitor; });
499
+
500
+ // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
501
+ // This file is imported into lib/wc client bundles.
502
+
503
+ if (typeof window !== 'undefined') {
504
+ if (false) {}
505
+
506
+ var i
507
+ if ((i = window.document.currentScript) && (i = i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))) {
508
+ __webpack_require__.p = i[1] // eslint-disable-line
509
+ }
510
+ }
511
+
512
+ // Indicate to webpack that this file can be concatenated
513
+ /* harmony default export */ var setPublicPath = (null);
514
+
515
+ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"7caff2c6-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=06a138e4&scoped=true
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:{"visible":_vm.showWarning,"show-close":false,"modal":true,"width":"30%","center":"","custom-class":"behavior-warning-dialog","append-to-body":true,"modal-append-to-body":true,"close-on-click-modal":false,"close-on-press-escape":false},on:{"update:visible":function($event){_vm.showWarning=$event}}},[_c('span',[_vm._v(_vm._s(_vm.warningMessage))])]),_c('button',{staticStyle:{"position":"fixed","top":"10px","right":"10px","z-index":"10000"},on:{"click":_vm.testWarning}},[_vm._v("\n 测试警告\n ")])],1)}
517
+ var staticRenderFns = []
518
+
519
+
520
+ // CONCATENATED MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=template&id=06a138e4&scoped=true
521
+
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
+ //
524
+ //
525
+ //
526
+ //
527
+ //
528
+ //
529
+ //
530
+ //
531
+ //
532
+ //
533
+ //
534
+ //
535
+ //
536
+ //
537
+ //
538
+ //
539
+ //
540
+ //
541
+ //
542
+ //
543
+ //
544
+ //
545
+ //
546
+ //
547
+ //
548
+
549
+ /* harmony default export */ var UserBehaviorMonitorvue_type_script_lang_js = ({
550
+ name: 'UserBehaviorMonitor',
551
+ props: {
552
+ // WebSocket服务器地址
553
+ websocketUrl: {
554
+ type: String,
555
+ required: true
556
+ },
557
+ // 倒计时时长(分钟)
558
+ timeoutMinutes: {
559
+ type: Number,
560
+ default: 10
561
+ },
562
+ // 警告提前时间(分钟)
563
+ warningMinutes: {
564
+ type: Number,
565
+ default: 1
566
+ }
567
+ },
568
+ data() {
569
+ return {
570
+ mouseMoveThrottled:false,
571
+ websocket: null,
572
+ countdownTimer: null,
573
+ warningTimer: null,
574
+ showWarning: false,
575
+ warningMessage: `您已${this.timeoutMinutes}分钟未操作,将在${this.warningMinutes}分钟后自动退出`,
576
+ lastActivityTime: null,
577
+ isMonitoring: false
578
+ };
579
+ },
580
+ mounted() {
581
+ console.log('开始开始! mounted');
582
+ this.initMonitor();
583
+ },
584
+ beforeDestroy() {
585
+ console.log('开始开始! beforeDestroy');
586
+ this.destroyMonitor();
587
+ },
588
+ methods: {
589
+ testWarning() {
590
+ console.log('Testing warning display');
591
+ this.showWarning = true;
592
+ },
593
+ // 初始化监控
594
+ initMonitor() {
595
+ console.log('Initializing monitor');
596
+ if (this.isMonitoring) return;
597
+
598
+ this.isMonitoring = true;
599
+ this.lastActivityTime = Date.now();
600
+
601
+ // 启动倒计时
602
+ this.startCountdown();
603
+
604
+ // 绑定事件监听器
605
+ this.bindEventListeners();
606
+ },
607
+
608
+ // 销毁监控
609
+ destroyMonitor() {
610
+ this.isMonitoring = false;
611
+
612
+ // 清除定时器
613
+ if (this.countdownTimer) clearInterval(this.countdownTimer);
614
+ if (this.warningTimer) clearTimeout(this.warningTimer);
615
+
616
+ // 解绑事件监听器
617
+ this.unbindEventListeners();
618
+ },
619
+
620
+ // 发送用户行为数据到后端
621
+ sendUserBehavior(data) {
622
+ // 用于测试:在控制台输出用户行为信息
623
+ console.log('用户行为监测:', data);
624
+ },
625
+
626
+ // 绑定事件监听器
627
+ bindEventListeners() {
628
+ console.log('Binding event listeners');
629
+ // 使用箭头函数或bind来保持this上下文
630
+ // 鼠标事件
631
+ document.addEventListener('click', this.handleUserActivity.bind(this), true);
632
+ document.addEventListener('dblclick', this.handleUserActivity.bind(this), true);
633
+ document.addEventListener('mousedown', this.handleUserActivity.bind(this), true);
634
+ document.addEventListener('mouseup', this.handleUserActivity.bind(this), true);
635
+ document.addEventListener('mousemove', this.handleMouseMove.bind(this), true);
636
+ document.addEventListener('mouseover', this.handleUserActivity.bind(this), true);
637
+ document.addEventListener('mouseout', this.handleUserActivity.bind(this), true);
638
+
639
+ // 键盘事件
640
+ document.addEventListener('keydown', this.handleUserActivity.bind(this), true);
641
+ document.addEventListener('keyup', this.handleUserActivity.bind(this), true);
642
+
643
+ // 表单事件
644
+ document.addEventListener('input', this.handleUserActivity.bind(this), true);
645
+ document.addEventListener('change', this.handleUserActivity.bind(this), true);
646
+ document.addEventListener('focus', this.handleUserActivity.bind(this), true);
647
+ document.addEventListener('blur', this.handleUserActivity.bind(this), true);
648
+
649
+ // 滚动事件(防抖处理)
650
+ document.addEventListener('scroll', this.debounce(this.handleUserActivity, 300).bind(this), true);
651
+
652
+ // 窗口事件
653
+ window.addEventListener('resize', this.handleUserActivity.bind(this), true);
654
+ window.addEventListener('beforeunload', this.handleBeforeUnload.bind(this));
655
+ },
656
+
657
+ // 解绑事件监听器
658
+ unbindEventListeners() {
659
+ console.log('Unbinding event listeners');
660
+ // 解绑时也要使用相同的方式
661
+ document.removeEventListener('click', this.handleUserActivity.bind(this), true);
662
+ document.removeEventListener('dblclick', this.handleUserActivity.bind(this), true);
663
+ document.removeEventListener('mousedown', this.handleUserActivity.bind(this), true);
664
+ document.removeEventListener('mouseup', this.handleUserActivity.bind(this), true);
665
+ document.removeEventListener('mousemove', this.handleMouseMove.bind(this), true);
666
+ document.removeEventListener('mouseover', this.handleUserActivity.bind(this), true);
667
+ document.removeEventListener('mouseout', this.handleUserActivity.bind(this), true);
668
+
669
+ document.removeEventListener('keydown', this.handleUserActivity.bind(this), true);
670
+ document.removeEventListener('keyup', this.handleUserActivity.bind(this), true);
671
+
672
+ document.removeEventListener('input', this.handleUserActivity.bind(this), true);
673
+ document.removeEventListener('change', this.handleUserActivity.bind(this), true);
674
+ document.removeEventListener('focus', this.handleUserActivity.bind(this), true);
675
+ document.removeEventListener('blur', this.handleUserActivity.bind(this), true);
676
+
677
+ document.removeEventListener('scroll', this.debounce(this.handleUserActivity, 300).bind(this), true);
678
+
679
+ window.removeEventListener('resize', this.handleUserActivity.bind(this), true);
680
+ window.removeEventListener('beforeunload', this.handleBeforeUnload.bind(this));
681
+ },
682
+
683
+ // 处理用户活动
684
+ handleUserActivity(event) {
685
+ // 过滤掉自动触发的事件
686
+ if (this.isAutomaticEvent(event)) return;
687
+
688
+ this.resetTimer();
689
+
690
+ // 发送用户行为数据
691
+ const behaviorData = {
692
+ eventType: event.type,
693
+ target: event.target.tagName,
694
+ timestamp: Date.now(),
695
+ url: window.location.href
696
+ };
697
+
698
+ // 添加特定事件的额外信息
699
+ if (event.type === 'click') {
700
+ behaviorData.clientX = event.clientX;
701
+ behaviorData.clientY = event.clientY;
702
+ } else if (event.type === 'keydown') {
703
+ behaviorData.key = event.key;
704
+ behaviorData.ctrlKey = event.ctrlKey;
705
+ behaviorData.altKey = event.altKey;
706
+ behaviorData.shiftKey = event.shiftKey;
707
+ }
708
+
709
+ this.sendUserBehavior(behaviorData);
710
+ },
711
+ handleMouseMove(event) {
712
+ if (!this.mouseMoveThrottled) {
713
+ this.handleUserActivity(event);
714
+ this.mouseMoveThrottled = true;
715
+ setTimeout(() => {
716
+ this.mouseMoveThrottled = false;
717
+ }, 500);
718
+ }
719
+ },
720
+
721
+ // 处理鼠标移动(降低频率)
722
+ // handleMouseMove: function() {
723
+ // let isThrottled = false;
724
+ // return (event) => {
725
+ // if (!isThrottled) {
726
+ // this.handleUserActivity(event);
727
+ // isThrottled = true;
728
+ // setTimeout(() => {
729
+ // isThrottled = false;
730
+ // }, 500);
731
+ // }
732
+ // };
733
+ // }(),
734
+
735
+ // 判断是否为自动触发事件
736
+ isAutomaticEvent(event) {
737
+ // 自动刷新等非用户主动触发的事件
738
+ if (event.type === 'scroll' && !this.isUserScrolling) {
739
+ return true;
740
+ }
741
+ return false;
742
+ },
743
+
744
+ // 防抖函数
745
+ debounce(func, wait) {
746
+ let timeout;
747
+ return function executedFunction(...args) {
748
+ const later = () => {
749
+ clearTimeout(timeout);
750
+ func.apply(this, args);
751
+ };
752
+ clearTimeout(timeout);
753
+ timeout = setTimeout(later, wait);
754
+ };
755
+ },
756
+
757
+ // 重置计时器
758
+ resetTimer() {
759
+ console.log('Resetting timer');
760
+ this.lastActivityTime = Date.now();
761
+ this.showWarning = false;
762
+
763
+ // 清除警告定时器
764
+ if (this.warningTimer) {
765
+ clearTimeout(this.warningTimer);
766
+ this.warningTimer = null;
767
+ }
768
+
769
+ // 重新启动倒计时
770
+ this.startCountdown();
771
+
772
+ this.$emit('user-active');
773
+ },
774
+
775
+ // 启动倒计时
776
+ startCountdown() {
777
+ console.log('Starting countdown');
778
+ // 清除现有定时器
779
+ if (this.countdownTimer) clearInterval(this.countdownTimer);
780
+
781
+ // 设置新的倒计时
782
+ this.countdownTimer = setInterval(() => {
783
+ const now = Date.now();
784
+ const elapsedMinutes = (now - this.lastActivityTime) / (1000 * 60);
785
+ console.log('Elapsed minutes:', elapsedMinutes);
786
+
787
+ // 检查是否需要显示警告
788
+ if (elapsedMinutes >= (this.timeoutMinutes - this.warningMinutes) && !this.warningTimer) {
789
+ console.log('Showing warning');
790
+ this.showWarningWarning();
791
+ }
792
+
793
+ // 检查是否超时
794
+ if (elapsedMinutes >= this.timeoutMinutes) {
795
+ console.log('Handling timeout');
796
+ this.handleTimeout();
797
+ }
798
+ }, 1000);
799
+ },
800
+
801
+ // 显示超时警告
802
+ showWarningWarning() {
803
+ console.log('Setting showWarning to true');
804
+ this.showWarning = true;
805
+ this.$emit('timeout-warning');
806
+
807
+ // 设置超时处理
808
+ this.warningTimer = setTimeout(() => {
809
+ this.handleTimeout();
810
+ }, this.warningMinutes * 60 * 1000);
811
+ },
812
+
813
+ // 处理超时
814
+ handleTimeout() {
815
+ console.log('Handling timeout');
816
+ this.showWarning = false;
817
+ this.$emit('timeout');
818
+
819
+ // 执行登出逻辑
820
+ this.logout();
821
+ },
822
+
823
+ // 登出操作
824
+ logout() {
825
+ // 用于测试:在控制台输出登出信息
826
+ console.log('用户超时登出');
827
+
828
+ this.$emit('logout');
829
+
830
+ // 清除定时器
831
+ if (this.countdownTimer) clearInterval(this.countdownTimer);
832
+ if (this.warningTimer) clearTimeout(this.warningTimer);
833
+ },
834
+
835
+ // 处理页面卸载前的操作
836
+ handleBeforeUnload(event) {
837
+ // 用于测试:在控制台输出页面卸载信息
838
+ console.log('页面即将卸载');
839
+ },
840
+
841
+ // 手动重置监控
842
+ reset() {
843
+ this.resetTimer();
844
+ }
845
+ }
846
+ });
847
+
848
+ // CONCATENATED MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=script&lang=js
849
+ /* harmony default export */ var components_UserBehaviorMonitorvue_type_script_lang_js = (UserBehaviorMonitorvue_type_script_lang_js);
850
+ // EXTERNAL MODULE: ./src/components/UserBehaviorMonitor.vue?vue&type=style&index=0&id=06a138e4&prod&scoped=true&lang=css
851
+ var UserBehaviorMonitorvue_type_style_index_0_id_06a138e4_prod_scoped_true_lang_css = __webpack_require__("533e");
852
+
853
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
854
+ /* globals __VUE_SSR_CONTEXT__ */
855
+
856
+ // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
857
+ // This module is a runtime utility for cleaner component module output and will
858
+ // be included in the final webpack user bundle.
859
+
860
+ function normalizeComponent(
861
+ scriptExports,
862
+ render,
863
+ staticRenderFns,
864
+ functionalTemplate,
865
+ injectStyles,
866
+ scopeId,
867
+ moduleIdentifier /* server only */,
868
+ shadowMode /* vue-cli only */
869
+ ) {
870
+ // Vue.extend constructor export interop
871
+ var options =
872
+ typeof scriptExports === 'function' ? scriptExports.options : scriptExports
873
+
874
+ // render functions
875
+ if (render) {
876
+ options.render = render
877
+ options.staticRenderFns = staticRenderFns
878
+ options._compiled = true
879
+ }
880
+
881
+ // functional template
882
+ if (functionalTemplate) {
883
+ options.functional = true
884
+ }
885
+
886
+ // scopedId
887
+ if (scopeId) {
888
+ options._scopeId = 'data-v-' + scopeId
889
+ }
890
+
891
+ var hook
892
+ if (moduleIdentifier) {
893
+ // server build
894
+ hook = function (context) {
895
+ // 2.3 injection
896
+ context =
897
+ context || // cached call
898
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
899
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
900
+ // 2.2 with runInNewContext: true
901
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
902
+ context = __VUE_SSR_CONTEXT__
903
+ }
904
+ // inject component styles
905
+ if (injectStyles) {
906
+ injectStyles.call(this, context)
907
+ }
908
+ // register component module identifier for async chunk inferrence
909
+ if (context && context._registeredComponents) {
910
+ context._registeredComponents.add(moduleIdentifier)
911
+ }
912
+ }
913
+ // used by ssr in case component is cached and beforeCreate
914
+ // never gets called
915
+ options._ssrRegister = hook
916
+ } else if (injectStyles) {
917
+ hook = shadowMode
918
+ ? function () {
919
+ injectStyles.call(
920
+ this,
921
+ (options.functional ? this.parent : this).$root.$options.shadowRoot
922
+ )
923
+ }
924
+ : injectStyles
925
+ }
926
+
927
+ if (hook) {
928
+ if (options.functional) {
929
+ // for template-only hot-reload because in that case the render fn doesn't
930
+ // go through the normalizer
931
+ options._injectStyles = hook
932
+ // register for functional component in vue file
933
+ var originalRender = options.render
934
+ options.render = function renderWithStyleInjection(h, context) {
935
+ hook.call(context)
936
+ return originalRender(h, context)
937
+ }
938
+ } else {
939
+ // inject component registration as beforeCreate hook
940
+ var existing = options.beforeCreate
941
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
942
+ }
943
+ }
944
+
945
+ return {
946
+ exports: scriptExports,
947
+ options: options
948
+ }
949
+ }
950
+
951
+ // CONCATENATED MODULE: ./src/components/UserBehaviorMonitor.vue
952
+
953
+
954
+
955
+
956
+
957
+
958
+ /* normalize component */
959
+
960
+ var component = normalizeComponent(
961
+ components_UserBehaviorMonitorvue_type_script_lang_js,
962
+ render,
963
+ staticRenderFns,
964
+ false,
965
+ null,
966
+ "06a138e4",
967
+ null
968
+
969
+ )
970
+
971
+ /* harmony default export */ var UserBehaviorMonitor = (component.exports);
972
+ // CONCATENATED MODULE: ./src/index.js
973
+
974
+
975
+ // 为使用 CDN 方式引入的用户提供组件注册方法
976
+ UserBehaviorMonitor.install = function(Vue) {
977
+ Vue.component(UserBehaviorMonitor.name, UserBehaviorMonitor);
978
+ };
979
+
980
+ // 导出组件
981
+ /* harmony default export */ var src = (UserBehaviorMonitor);
982
+
983
+ // 如果是直接引入文件,则自动注册组件
984
+ if (typeof window !== 'undefined' && window.Vue) {
985
+ UserBehaviorMonitor.install(window.Vue);
986
+ }
987
+
988
+ // 同时支持按需导入
989
+
990
+ // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
991
+
992
+
993
+ /* harmony default export */ var entry_lib = __webpack_exports__["default"] = (src);
994
+
995
+
996
+
997
+ /***/ })
998
+
999
+ /******/ });
1000
+ });
1001
+ //# sourceMappingURL=user-behavior-monitor.umd.js.map