From 8ca94fbafce70d0d3e1e48a5b0b914dcbb960768 Mon Sep 17 00:00:00 2001 From: koko210Serve Date: Sat, 28 Feb 2026 22:59:12 +0200 Subject: [PATCH] fix: persist active tab via localStorage + fix implicit event bug in switchTab - Add data-tab attributes to tab buttons for reliable identification - Replace implicit window.event usage with querySelector by data-tab - Save active tab to localStorage on switch, restore on page load --- bot/static/index.html | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/bot/static/index.html b/bot/static/index.html index f95a36f..66c2fa1 100644 --- a/bot/static/index.html +++ b/bot/static/index.html @@ -660,15 +660,15 @@
- - - - - - - - - + + + + + + + + +
@@ -1830,8 +1830,12 @@ function switchTab(tabId) { // Show the selected tab content document.getElementById(tabId).classList.add('active'); - // Add active class to the clicked tab button - event.target.classList.add('active'); + // Add active class to the matching tab button via data-tab attribute + const activeBtn = document.querySelector(`.tab-button[data-tab="${tabId}"]`); + if (activeBtn) activeBtn.classList.add('active'); + + // Persist active tab to localStorage + localStorage.setItem('miku-active-tab', tabId); console.log(`🔄 Switched to ${tabId}`); if (tabId === 'tab1') { @@ -1846,6 +1850,12 @@ function switchTab(tabId) { // Initialize document.addEventListener('DOMContentLoaded', function() { + // Restore persisted tab from localStorage + const savedTab = localStorage.getItem('miku-active-tab'); + if (savedTab && document.getElementById(savedTab)) { + switchTab(savedTab); + } + loadStatus(); loadServers(); loadLastPrompt();