From d8553c6e2a6a3ae1cc11dd7118856550c47ba97d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 24 Oct 2022 12:17:21 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20iframe=20=E4=BD=BF=E7=94=A8=E7=9F=AD?= =?UTF-8?q?=E7=BD=91=E5=9D=80=E4=BC=9A=E6=89=93=E5=BC=80=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=99=A8=E6=88=96=E8=B7=B3=E8=BD=AC=20APP=20Fix=20https://gith?= =?UTF-8?q?ub.com/siyuan-note/siyuan/issues/6327?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index 171e58160..c405f6df4 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -86,10 +86,8 @@ try { } } catch (e) { console.error(e) - require('electron'). - dialog. - showErrorBox('创建配置目录失败 Failed to create config directory', - '思源需要在用户家目录下创建配置文件夹(~/.config/siyuan),请确保该路径具有写入权限。\n\nSiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.') + require('electron').dialog.showErrorBox('创建配置目录失败 Failed to create config directory', + '思源需要在用户家目录下创建配置文件夹(~/.config/siyuan),请确保该路径具有写入权限。\n\nSiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.') app.exit() } @@ -332,10 +330,19 @@ const boot = () => { if (url.startsWith('http://127.0.0.1:6806')) { return } + console.log("will-navigate", url) event.preventDefault() shell.openExternal(url) }) + // iframe 使用短网址会打开浏览器或跳转 APP https://github.com/siyuan-note/siyuan/issues/6327 + mainWindow.webContents.on('will-redirect', (event, url) => { + if (url.startsWith('http://127.0.0.1:6806')) { + return + } + event.preventDefault() + }) + mainWindow.on('close', (event) => { if (mainWindow && !mainWindow.isDestroyed()) { mainWindow.webContents.send('siyuan-save-close', false)