vue2-client 1.19.36 → 1.19.37
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/package.json
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
<script>
|
|
21
21
|
import { useWebSocket } from '@vue2-client/utils/websocket/websocket'
|
|
22
|
+
import { isDebugUser } from '@/utils/common'
|
|
22
23
|
|
|
23
24
|
export default {
|
|
24
25
|
name: 'XWebSocketProgress',
|
|
@@ -59,15 +60,16 @@ export default {
|
|
|
59
60
|
reconnectAttempts: 0
|
|
60
61
|
},
|
|
61
62
|
websocketUrl: '',
|
|
63
|
+
wsSend: null,
|
|
64
|
+
heartbeatTimer: null,
|
|
62
65
|
}
|
|
63
66
|
},
|
|
64
67
|
computed: {
|
|
65
68
|
// 是否显示连接状态
|
|
66
69
|
showConnectionStatus () {
|
|
67
|
-
return this.progressValue < 100
|
|
70
|
+
return this.progressValue < 100 && isDebugUser()
|
|
68
71
|
},
|
|
69
72
|
|
|
70
|
-
// 连接状态文本
|
|
71
73
|
connectionStatusText () {
|
|
72
74
|
if (this.connectionState.isConnected) {
|
|
73
75
|
return '已连接'
|
|
@@ -150,10 +152,12 @@ export default {
|
|
|
150
152
|
// 使用 WebSocket 工具
|
|
151
153
|
const wsManager = useWebSocket(wsOptions)
|
|
152
154
|
|
|
155
|
+
|
|
153
156
|
// 保存方法引用
|
|
154
157
|
this.wsConnect = wsManager.connect
|
|
155
158
|
this.wsDisconnect = wsManager.disconnect
|
|
156
159
|
this.wsOn = wsManager.on
|
|
160
|
+
this.wsSend = wsManager.send
|
|
157
161
|
// 绑定事件监听器
|
|
158
162
|
this.setupEventListeners()
|
|
159
163
|
|
|
@@ -177,6 +181,10 @@ export default {
|
|
|
177
181
|
this.connectionState.isConnected = true
|
|
178
182
|
this.connectionState.reconnectAttempts = 0
|
|
179
183
|
this.$emit('websocket-connected', data)
|
|
184
|
+
this.heartbeatTimer = setInterval(() => {
|
|
185
|
+
console.log('>>>> 30秒 心跳')
|
|
186
|
+
this.wsSend('ping')
|
|
187
|
+
}, 30 * 1000)
|
|
180
188
|
})
|
|
181
189
|
|
|
182
190
|
// 连接中
|
|
@@ -263,6 +271,9 @@ export default {
|
|
|
263
271
|
cleanup () {
|
|
264
272
|
if (this.wsDisconnect) {
|
|
265
273
|
this.wsDisconnect()
|
|
274
|
+
if (this.heartbeatTimer) {
|
|
275
|
+
clearInterval(this.heartbeatTimer)
|
|
276
|
+
}
|
|
266
277
|
}
|
|
267
278
|
}
|
|
268
279
|
}
|