feat: add better auto refresh

This commit is contained in:
2025-07-31 23:33:53 +08:00
parent 17ec80652c
commit 6ccf71ec81
3 changed files with 18 additions and 16 deletions

View File

@@ -99,16 +99,17 @@
document.getElementById('last-updated').textContent = new Date().toLocaleString(); document.getElementById('last-updated').textContent = new Date().toLocaleString();
} }
// Update timestamp every 30 seconds // Auto refresh functionality for all pages except logs
setInterval(updateTimestamp, 30000); if (window.location.pathname !== '/dashboard/logs') {
updateTimestamp(); // Update timestamp and refresh page every 10 seconds
// Auto refresh page every 5 minutes for dashboard
if (window.location.pathname === '/dashboard') {
setInterval(() => { setInterval(() => {
updateTimestamp();
window.location.reload(); window.location.reload();
}, 300000); }, 10000);
} }
// Initial timestamp update
updateTimestamp();
</script> </script>
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}

View File

@@ -151,7 +151,10 @@
document.getElementById('current-time').textContent = new Date().toLocaleString(); document.getElementById('current-time').textContent = new Date().toLocaleString();
} }
// Initial update
updateCurrentTime(); updateCurrentTime();
setInterval(updateCurrentTime, 1000);
// Note: Page auto-refreshes every 10 seconds via base.html
// The current time will be updated on each refresh
</script> </script>
{% endblock %} {% endblock %}

View File

@@ -209,9 +209,7 @@
{% block scripts %} {% block scripts %}
<script> <script>
// Auto-refresh every 60 seconds // Note: Page auto-refreshes every 10 seconds via base.html
setInterval(() => { // No additional refresh logic needed here
window.location.reload();
}, 60000);
</script> </script>
{% endblock %} {% endblock %}