From 6ccf71ec81781a21e23545302bd56d811536e4ca Mon Sep 17 00:00:00 2001 From: ZhuangYumin Date: Thu, 31 Jul 2025 23:33:53 +0800 Subject: [PATCH] feat: add better auto refresh --- templates/base.html | 17 +++++++++-------- templates/dashboard.html | 9 ++++++--- templates/users_report.html | 8 +++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/templates/base.html b/templates/base.html index c2b40d5..6e9d988 100644 --- a/templates/base.html +++ b/templates/base.html @@ -98,17 +98,18 @@ function updateTimestamp() { document.getElementById('last-updated').textContent = new Date().toLocaleString(); } - - // Update timestamp every 30 seconds - setInterval(updateTimestamp, 30000); - updateTimestamp(); - - // Auto refresh page every 5 minutes for dashboard - if (window.location.pathname === '/dashboard') { + + // Auto refresh functionality for all pages except logs + if (window.location.pathname !== '/dashboard/logs') { + // Update timestamp and refresh page every 10 seconds setInterval(() => { + updateTimestamp(); window.location.reload(); - }, 300000); + }, 10000); } + + // Initial timestamp update + updateTimestamp(); {% block scripts %}{% endblock %} diff --git a/templates/dashboard.html b/templates/dashboard.html index c845ae9..ef21aad 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -150,8 +150,11 @@ function updateCurrentTime() { document.getElementById('current-time').textContent = new Date().toLocaleString(); } - + + // Initial update updateCurrentTime(); - setInterval(updateCurrentTime, 1000); + + // Note: Page auto-refreshes every 10 seconds via base.html + // The current time will be updated on each refresh -{% endblock %} \ No newline at end of file +{% endblock %} \ No newline at end of file diff --git a/templates/users_report.html b/templates/users_report.html index 6bb51ec..d091fa4 100644 --- a/templates/users_report.html +++ b/templates/users_report.html @@ -209,9 +209,7 @@ {% block scripts %} -{% endblock %} \ No newline at end of file +{% endblock %} \ No newline at end of file