fix: Improve app instance lock handling

This commit is contained in:
Memory 2025-11-18 23:55:07 +08:00 committed by GitHub
parent 485a936d83
commit 3670f23a1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,26 +68,20 @@ async function fixUserDataPermissions(): Promise<void> {
let quitTimeout: NodeJS.Timeout | null = null
export let mainWindow: BrowserWindow | null = null
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
}
async function initApp(): Promise<void> {
await fixUserDataPermissions()
}
initApp()
.then(() => {
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
.catch((e) => {
showSafeErrorBox('common.error.initFailed', `${e}`)
app.quit()
}
})
.catch(() => {
// ignore permission fix errors
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
}
})
export function customRelaunch(): void {