From 3670f23a1cbf039bb1f0cb6795f5e27c443cdce1 Mon Sep 17 00:00:00 2001 From: Memory <134070804+Memory2314@users.noreply.github.com> Date: Tue, 18 Nov 2025 23:55:07 +0800 Subject: [PATCH] fix: Improve app instance lock handling --- src/main/index.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index e401eee..12711bb 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -68,26 +68,20 @@ async function fixUserDataPermissions(): Promise { let quitTimeout: NodeJS.Timeout | null = null export let mainWindow: BrowserWindow | null = null +const gotTheLock = app.requestSingleInstanceLock() + +if (!gotTheLock) { + app.quit() +} async function initApp(): Promise { await fixUserDataPermissions() } initApp() - .then(() => { - const gotTheLock = app.requestSingleInstanceLock() - - if (!gotTheLock) { - app.quit() - } - }) - .catch(() => { - // ignore permission fix errors - const gotTheLock = app.requestSingleInstanceLock() - - if (!gotTheLock) { - app.quit() - } + .catch((e) => { + showSafeErrorBox('common.error.initFailed', `${e}`) + app.quit() }) export function customRelaunch(): void {