From a17fc0da88d998ed619ca279d64f9252957acdf6 Mon Sep 17 00:00:00 2001 From: Wendong-Fan Date: Fri, 29 Aug 2025 19:39:15 +0800 Subject: [PATCH] =?UTF-8?q?enhance:=20optimize=20Privacy=20page=20UX,=20co?= =?UTF-8?q?py,=20and=20performan=E2=80=A6=20PR256?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main/fileReader.ts | 4 +++- electron/main/index.ts | 3 ++- src/pages/Setting/Privacy.tsx | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/electron/main/fileReader.ts b/electron/main/fileReader.ts index f7da94564..07201cdc8 100644 --- a/electron/main/fileReader.ts +++ b/electron/main/fileReader.ts @@ -380,7 +380,9 @@ export class FileReader { }); fileStream.on('error', (err) => { - fs.unlink(localPath, () => { }); // delete incomplete file + fs.unlink(localPath, (unlinkErr) => { + if (unlinkErr) console.error('Failed to delete incomplete file:', unlinkErr); + }); // delete incomplete file reject(err); }); }); diff --git a/electron/main/index.ts b/electron/main/index.ts index 870f314e6..c3b7de4f3 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -644,7 +644,8 @@ function registerIpcHandlers() { ipcMain.handle("reveal-in-folder", async (event, filePath: string) => { try { - if (filePath.endsWith('/')) { + const stats = await fs.promises.stat(filePath.replace(/\/$/, '')).catch(() => null); + if (stats && stats.isDirectory()) { shell.openPath(filePath); } else { shell.showItemInFolder(filePath); diff --git a/src/pages/Setting/Privacy.tsx b/src/pages/Setting/Privacy.tsx index af8a78127..945995718 100644 --- a/src/pages/Setting/Privacy.tsx +++ b/src/pages/Setting/Privacy.tsx @@ -109,7 +109,9 @@ export default function SettingPrivacy() { }, [email]); const handleOpenFolder = () => { - window.ipcRenderer.invoke("reveal-in-folder", logFolder + "/"); + if (logFolder) { + window.ipcRenderer.invoke("reveal-in-folder", logFolder + "/"); + } }; return ( @@ -172,7 +174,7 @@ export default function SettingPrivacy() { -