From 945ffc257a5791a587bfa7d3144041619df69495 Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Fri, 17 Apr 2026 18:31:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=97=B4=E9=9A=94=E6=97=B6=E9=97=B4=E8=AE=BE=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=A2=91=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 399cbc8..afde96e 100644 --- a/app.py +++ b/app.py @@ -248,6 +248,13 @@ HTML_TEMPLATE = ''' +
+ 间隔: + + s +
@@ -740,8 +747,26 @@ HTML_TEMPLATE = ''' loadProjects(); loadCrons(); - // 每30秒自动刷新 - setInterval(loadProjects, 30000); + // 动态刷新间隔 + let refreshIntervalMs = parseInt(localStorage.getItem('refreshInterval') || '30') * 1000; + document.getElementById('refreshInterval').value = refreshIntervalMs / 1000; + + let refreshTimer = setInterval(loadProjects, refreshIntervalMs); + + function updateRefreshInterval() { + const seconds = parseInt(document.getElementById('refreshInterval').value) || 30; + const clampedSeconds = Math.max(5, Math.min(300, seconds)); // 限制5-300秒 + document.getElementById('refreshInterval').value = clampedSeconds; + + localStorage.setItem('refreshInterval', clampedSeconds); + refreshIntervalMs = clampedSeconds * 1000; + + // 清除旧定时器,设置新定时器 + clearInterval(refreshTimer); + refreshTimer = setInterval(loadProjects, refreshIntervalMs); + + console.log('刷新间隔已更新为:', clampedSeconds, '秒'); + } // 每10秒检查连接状态 setInterval(checkConnection, 10000);