fix: 侧边栏watcher泄漏、目录刷新防抖、清理过时注释

This commit is contained in:
thzxx
2026-05-21 11:43:42 +08:00
parent 5d64e4401f
commit f6f1c4f717
2 changed files with 5 additions and 2 deletions
+1
View File
@@ -111,6 +111,7 @@ function createWindow() {
mainWindow.on('closed', () => { mainWindow.on('closed', () => {
stopWatching(); stopWatching();
stopSidebarWatching();
mainWindow = null; mainWindow = null;
}); });
} }
+4 -2
View File
@@ -1263,8 +1263,11 @@
btnOpenFolder.addEventListener('click', openFolder); btnOpenFolder.addEventListener('click', openFolder);
if (typeof window.electronAPI !== 'undefined') { if (typeof window.electronAPI !== 'undefined') {
let dirRefreshTimer = null;
window.electronAPI.onDirChanged(() => { window.electronAPI.onDirChanged(() => {
if (currentRootPath) refreshTree(); if (!currentRootPath) return;
if (dirRefreshTimer) clearTimeout(dirRefreshTimer);
dirRefreshTimer = setTimeout(() => refreshTree(), 300);
}); });
} }
} }
@@ -1275,7 +1278,6 @@
} }
async function openFolderDialog() { async function openFolderDialog() {
// We'll add a dir:openDialog IPC
if (typeof window.electronAPI !== 'undefined' && window.electronAPI.openFolderDialog) { if (typeof window.electronAPI !== 'undefined' && window.electronAPI.openFolderDialog) {
const result = await window.electronAPI.openFolderDialog(); const result = await window.electronAPI.openFolderDialog();
if (result) { if (result) {