From 2d899cca7e95a0c92f1331d32f3a899ed848f1d3 Mon Sep 17 00:00:00 2001 From: thzxx Date: Thu, 21 May 2026 12:59:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BE=A7=E8=BE=B9=E6=A0=8F=E9=AB=98?= =?UTF-8?q?=E4=BA=AE=E9=80=BB=E8=BE=91=E6=B8=85=E7=90=86=E4=B8=8E=E8=BE=B9?= =?UTF-8?q?=E7=95=8C=E6=83=85=E5=86=B5=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 loadTabState 中冗余的 updateSidebarHighlight 调用(switchToTab/closeTab 已覆盖) - 无文件夹+无标签时自动隐藏侧边栏(之前会空显示) - handleSave/handleSaveAs 后刷新侧边栏(文件路径变化时同步更新) --- renderer/renderer.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/renderer/renderer.js b/renderer/renderer.js index 2f739db..8d9dd4e 100644 --- a/renderer/renderer.js +++ b/renderer/renderer.js @@ -545,15 +545,22 @@ const tab = getActiveTab(); const activePath = tab ? tab.filePath : null; - // If no folder is open, just re-render independent files + // No folder open: manage independent files section if (!currentRootPath) { + if (tabs.length === 0) { + // No tabs and no folder — hide sidebar + sidebar.classList.add('collapsed'); + sidebarTree.innerHTML = ''; + return; + } + sidebar.classList.remove('collapsed'); sidebarTree.innerHTML = ''; const indepSection = renderIndependentFiles(); if (indepSection) sidebarTree.appendChild(indepSection); return; } - // Re-render independent files section (files may have been added/removed) + // Folder is open: re-render independent files section (files may have been added/removed) const oldSection = sidebarTree.querySelector('.independent-files-section'); const newSection = renderIndependentFiles(); if (oldSection) oldSection.remove(); @@ -619,15 +626,6 @@ // Update modified state setModified(tab.isModified); - // Update sidebar highlight and independent files - updateSidebarHighlight(); - // If no folder is open but we have open files, ensure sidebar is visible - if (!currentRootPath && tabs.length > 0) { - sidebar.classList.remove('collapsed'); - } else if (!currentRootPath && tabs.length === 0) { - sidebar.classList.add('collapsed'); - } - // Notify main process about active file if (typeof window.electronAPI !== 'undefined') { window.electronAPI.tabSwitched(tab.filePath); @@ -782,6 +780,7 @@ tab.isModified = false; renderTabBar(); updateTitle(); + updateSidebarHighlight(); statusText.textContent = '已保存'; setTimeout(() => updateTitle(), 2000); } @@ -810,6 +809,7 @@ tab.isModified = false; renderTabBar(); updateTitle(); + updateSidebarHighlight(); statusText.textContent = '已保存'; setTimeout(() => updateTitle(), 2000); }