diff --git a/tcp_server.go b/tcp_server.go index f7437d4..fdfd73f 100644 --- a/tcp_server.go +++ b/tcp_server.go @@ -99,9 +99,9 @@ func handleConnection(conn net.Conn) { } } -// sendPeriodicCommand 每10秒发送一次查询指令 +// sendPeriodicCommand 每30分钟发送一次查询指令 func sendPeriodicCommand(conn net.Conn, remoteAddr string) { - ticker := time.NewTicker(10 * time.Second) + ticker := time.NewTicker(30 * time.Minute) defer ticker.Stop() for { diff --git a/templates/index.html b/templates/index.html index ae9886c..c70bb05 100644 --- a/templates/index.html +++ b/templates/index.html @@ -275,9 +275,6 @@ // 检查连接状态 checkConnectionStatus(); connectionCheckTimer = setInterval(checkConnectionStatus, 30000); // 每30秒检查一次 - - // 获取最新数据显示 - fetchLatestData(); }); // 初始化日期选择器 @@ -784,7 +781,10 @@ latestDataElement.style.opacity = 0.5; document.getElementById('queryLatestBtn').textContent = '查询中...'; - // 这里会触发TCP服务器发送查询指令,等待3秒后获取最新数据 + // 先获取一次当前最新数据 + fetchLatestData(); + + // 触发TCP服务器发送查询指令,等待3秒后再次获取最新数据 setTimeout(() => { fetchLatestData(); loadData(); // 也刷新一下表格数据