From 0ba3f638f4130e0e2623fc801cdda3f7c6670738 Mon Sep 17 00:00:00 2001 From: fengyarnom Date: Sat, 24 May 2025 13:32:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E4=B8=BA30=E5=88=86?= =?UTF-8?q?=E9=92=9F=E6=9F=A5=E8=AF=A2=E4=B8=80=E6=AC=A1=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=B8=94=E5=89=8D=E7=AB=AF=E5=8F=96=E6=B6=88=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=9C=80=E6=96=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tcp_server.go | 4 ++-- templates/index.html | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) 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(); // 也刷新一下表格数据