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.
package/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # User Behavior Monitor Component
2
+
3
+ Vue 2.5.2 兼容的用户行为监控组件,用于监测用户操作并在超时后自动登出。
4
+
5
+ ## 安装
6
+
7
+ \`\`\`bash
8
+ npm install git+https://code.mysugoncloud.com/linmingchuang/usermonitor.git
9
+ # 安装特定分支
10
+ npm install git+https://code.mysugoncloud.com/linmingchuang/usermonitor.git#branch-name
11
+
12
+ # 安装特定标签
13
+ npm install git+https://code.mysugoncloud.com/linmingchuang/usermonitor.git#v1.0.0
14
+ \`\`\`
15
+ "user-behavior-monitor": "file:/var/jenkins_home/workspace/web-usermonitor"
16
+ ## 使用方法
17
+
18
+ ### 方式一:全局注册
19
+
20
+ \`\`\`javascript
21
+ import Vue from 'vue';
22
+ import UserBehaviorMonitor from 'user-behavior-monitor';
23
+ import 'element-ui/lib/theme-chalk/index.css';
24
+
25
+ Vue.use(UserBehaviorMonitor);
26
+ \`\`\`
27
+
28
+ ### 方式二:局部注册
29
+
30
+ \`\`\`javascript
31
+ import UserBehaviorMonitor from 'user-behavior-monitor';
32
+
33
+ export default {
34
+ components: {
35
+ UserBehaviorMonitor
36
+ }
37
+ }
38
+ \`\`\`
39
+
40
+ ### 在模板中使用
41
+
42
+ \`\`\`vue
43
+ <template>
44
+ <div id="app">
45
+ <!-- 其他组件 -->
46
+ <user-behavior-monitor
47
+ websocket-url="ws://localhost:8080/websocket"
48
+ :timeout-minutes="10"
49
+ :warning-minutes="1"
50
+ @logout="handleLogout"
51
+ @user-active="handleUserActive"
52
+ @timeout-warning="handleTimeoutWarning"
53
+ />
54
+ </div>
55
+ </template>
56
+
57
+ <script>
58
+ import UserBehaviorMonitor from 'user-behavior-monitor';
59
+
60
+ export default {
61
+ components: {
62
+ UserBehaviorMonitor
63
+ },
64
+ methods: {
65
+ handleLogout() {
66
+ // 处理登出逻辑,例如跳转到登录页
67
+ this.$router.push('/login');
68
+ },
69
+ handleUserActive() {
70
+ console.log('用户有活动');
71
+ },
72
+ handleTimeoutWarning() {
73
+ console.log('即将超时警告');
74
+ }
75
+ }
76
+ };
77
+ </script>
78
+ \`\`\`
79
+
80
+ ## Props
81
+
82
+ | 属性名 | 类型 | 默认值 | 说明 |
83
+ | --- | --- | --- | --- |
84
+ | websocket-url | String | 必填 | WebSocket服务器地址 |
85
+ | timeout-minutes | Number | 10 | 超时时间(分钟) |
86
+ | warning-minutes | Number | 1 | 警告提前时间(分钟) |
87
+
88
+ ## Events
89
+
90
+ | 事件名 | 说明 |
91
+ | --- | --- |
92
+ | websocket-open | WebSocket连接建立 |
93
+ | websocket-message | 收到WebSocket消息 |
94
+ | websocket-error | WebSocket连接错误 |
95
+ | websocket-close | WebSocket连接关闭 |
96
+ | user-active | 用户有活动 |
97
+ | timeout-warning | 超时警告 |
98
+ | timeout | 超时 |
99
+ | logout | 登出 |
100
+
101
+ ## 方法
102
+
103
+ | 方法名 | 说明 |
104
+ | --- | --- |
105
+ | reset() | 手动重置监控计时器 |
106
+ | reconnect() | 重新连接WebSocket |
package/dist/demo.html ADDED
@@ -0,0 +1,8 @@
1
+ <meta charset="utf-8">
2
+ <title>user-behavior-monitor demo</title>
3
+ <script src="./user-behavior-monitor.umd.js"></script>
4
+
5
+
6
+ <script>
7
+ console.log(user-behavior-monitor)
8
+ </script>