From 0bb17a61a871153acc0de5784215f61fd70f9d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=20=D0=9C=D1=83=D0=B7=D1=8B=D0=BA?= =?UTF-8?q?=D0=B0?= Date: Mon, 13 Feb 2023 09:19:45 +0300 Subject: [PATCH] fix: links open in app, not browser (#343) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: opening links in browser #342 --------- Co-authored-by: 草鞋没号 <308487730@qq.com> --- electron/main/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index f209629..5e429cd 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -68,9 +68,9 @@ async function createWindow() { }) // Make all links open with the browser, not with the application - win.webContents.setWindowOpenHandler(({ url }) => { - if (url.startsWith('https:')) shell.openExternal(url) - return { action: 'deny' } + win.webContents.on('will-navigate', (event, url) => { + event.preventDefault() + shell.openExternal(url) }) }