From 7580c79c00b1b100ec8eb294b2d0e2befd9eb35e Mon Sep 17 00:00:00 2001 From: lyswhut Date: Wed, 7 Jul 2021 15:02:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E8=BF=87=E6=97=B6API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index ecfb0800..d087f1d7 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -55,12 +55,12 @@ app.on('web-contents-created', (event, contents) => { if (!navigationUrlWhiteList.some(url => url.test(navigationUrl))) return event.preventDefault() console.log('navigation to url:', navigationUrl) }) - contents.on('new-window', async(event, navigationUrl) => { - event.preventDefault() - if (/^devtools/.test(navigationUrl)) return - console.log(navigationUrl) - if (!/^https?:\/\//.test(navigationUrl)) return - await shell.openExternal(navigationUrl) + contents.setWindowOpenHandler(({ url }) => { + if (!/^devtools/.test(url) && /^https?:\/\//.test(url)) { + shell.openExternal(url) + } + console.log(url) + return { action: 'deny' } }) contents.on('will-attach-webview', (event, webPreferences, params) => { // Strip away preload scripts if unused or verify their location is legitimate