From 3b1dd4e008e822269e49379863fb72582a5bdedc Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Tue, 6 Oct 2020 14:34:01 -0700 Subject: [PATCH] open external links in system browser --- src/main/index.js | 7 ++++++- src/renderer/about.jsx | 1 - src/renderer/app.jsx | 8 +------- src/renderer/privacy.jsx | 7 +++++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 6362996..8977a3d 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,4 +1,4 @@ -import {BrowserWindow, Menu, app, dialog, ipcMain, systemPreferences} from 'electron'; +import {BrowserWindow, Menu, app, dialog, ipcMain, shell, systemPreferences} from 'electron'; import fs from 'fs-extra'; import path from 'path'; import {URL} from 'url'; @@ -193,6 +193,11 @@ const createWindow = ({search = null, url = 'index.html', ...browserWindowOption } }); + webContents.on('new-window', (event, newWindowUrl) => { + shell.openExternal(newWindowUrl); + event.preventDefault(); + }); + const fullUrl = makeFullUrl(url, search); window.loadURL(fullUrl); diff --git a/src/renderer/about.jsx b/src/renderer/about.jsx index 17ffef1..b07c2e4 100644 --- a/src/renderer/about.jsx +++ b/src/renderer/about.jsx @@ -5,7 +5,6 @@ import {productName, version} from '../../package.json'; import logo from '../icon/ScratchDesktop.svg'; import styles from './about.css'; -// TODO: localization? const AboutElement = () => (