From 8720ba1f8a1563b0b4d0101b235314ae051659e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Fri, 24 Feb 2023 18:05:48 +0800 Subject: [PATCH] fix(#344): `location.reload()` causes open browser --- electron/main/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index 5e429cd..a1bed6c 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -68,10 +68,11 @@ async function createWindow() { }) // Make all links open with the browser, not with the application - win.webContents.on('will-navigate', (event, url) => { - event.preventDefault() - shell.openExternal(url) + win.webContents.setWindowOpenHandler(({ url }) => { + if (url.startsWith('https:')) shell.openExternal(url) + return { action: 'deny' } }) + // win.webContents.on('will-navigate', (event, url) => { }) #344 } app.whenReady().then(createWindow)