|
|
@@ -109,6 +109,7 @@ export default {
|
|
|
info: {},
|
|
|
dataArray:[],
|
|
|
webSockedData: {},
|
|
|
+ reconnectCount: 0,
|
|
|
};
|
|
|
},
|
|
|
components: {
|
|
|
@@ -204,7 +205,12 @@ export default {
|
|
|
uni.onSocketClose(() => {
|
|
|
console.warn('WebSocket 已断开,3 秒后尝试重连');
|
|
|
clearInterval(this.heartbeatTimer);
|
|
|
- setTimeout(() => this.initWebSocket(), 3000);
|
|
|
+ this.reconnectCount = (this.reconnectCount || 0) + 1;
|
|
|
+ if (this.reconnectCount <= 10) {
|
|
|
+ setTimeout(() => this.initWebSocket(), 3000);
|
|
|
+ } else {
|
|
|
+ console.warn('WebSocket 重连次数已达上限,停止重连');
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
mergeTwoObject(firstObject, secondObject) {
|