fix: close thoughts page and modal when switching nav tabs

switchTab() now checks if the thoughts detail page or book detail modal
is open and closes them before switching to the target tab. Previously,
when on the thoughts page, clicking any nav tab (charts, ranking, etc.)
would silently fail because mainView was still hidden.
This commit is contained in:
admin committed 2026-07-17 12:17:10 +08:00
1 parent 90b9614b5e
commit ec88707e6b
1 file changed
+11
+11
View File
@@ -112,6 +112,17 @@ function showDBAlert(message) {
// ===== 标签页切换 ===== // ===== 标签页切换 =====
function switchTab(tabName) { function switchTab(tabName) {
// 如果想法详情页正在显示,先关闭它回到主视图
const thoughtsPage = document.getElementById("thoughtsPage");
if (thoughtsPage && thoughtsPage.style.display !== "none") {
thoughtsPage.style.display = "none";
document.getElementById("mainView").style.display = "";
currentThoughtsData = null;
}
// 关闭可能打开的弹窗
closeModal("bookDetailModal");
document.querySelectorAll(".tab-panel").forEach((panel) => { document.querySelectorAll(".tab-panel").forEach((panel) => {
panel.classList.remove("active"); panel.classList.remove("active");
}); });