From ec88707e6b67f8a0f2839d6e55e8de75ca3b6ef6 Mon Sep 17 00:00:00 2001 From: kinghwj Date: Fri, 17 Jul 2026 12:17:10 +0800 Subject: [PATCH] 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. --- static/js/app.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/static/js/app.js b/static/js/app.js index c91cc84..c3f6aa9 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -112,6 +112,17 @@ function showDBAlert(message) { // ===== 标签页切换 ===== 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) => { panel.classList.remove("active"); });