Commit 3fd5a70b by T

优化-定时刷新及socket重连

parent 0c1cf9dc
......@@ -275,7 +275,12 @@ return length;
}
//每天固定0点自动刷新界面
setTimeout("window.location.reload()", 24*60*60*1000);
var myDate = new Date();
if(myDate.getHours()==0 && myDate.getMinutes()==0 && myDate.getSeconds()==0) {
window.location.reload();
}
window.onload = function () {
......@@ -369,10 +374,10 @@ window.onload = function () {
} catch(error) {
// 捕获异常,处理重连状态
console.log(`第${reconnectCount+1}次重连失败:${error.message}`);
if (reconnectCount < 2) {
// 如果重连次数不足3次,就再次调用函数进行重连
if (reconnectCount < 10) {
// 如果重连次数不足10次,就再次调用函数进行重连
reconnectCount++;
setTimeout(checkAndReconnectSocket, 5*60 * 1000);
setTimeout('checkAndReconnectSocket()', 30 * 1000);
} else {
// 如果重连次数已达到3次,就结束尝试连接
console.log(`连接无法恢复,已放弃尝试。`);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论