fix: 侧边栏watcher泄漏、目录刷新防抖、清理过时注释
This commit is contained in:
@@ -111,6 +111,7 @@ function createWindow() {
|
|||||||
|
|
||||||
mainWindow.on('closed', () => {
|
mainWindow.on('closed', () => {
|
||||||
stopWatching();
|
stopWatching();
|
||||||
|
stopSidebarWatching();
|
||||||
mainWindow = null;
|
mainWindow = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user