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

@@ -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();
</script>
{% block scripts %}{% endblock %}

View File

@@ -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
</script>
{% endblock %}
{% endblock %}

View File

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