open external links in system browser

This commit is contained in:
Christopher Willis-Ford 2020-10-06 14:34:01 -07:00
parent 8fc98e1c37
commit 3b1dd4e008
4 changed files with 12 additions and 11 deletions

View file

@ -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 fs from 'fs-extra';
import path from 'path'; import path from 'path';
import {URL} from 'url'; 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); const fullUrl = makeFullUrl(url, search);
window.loadURL(fullUrl); window.loadURL(fullUrl);

View file

@ -5,7 +5,6 @@ import {productName, version} from '../../package.json';
import logo from '../icon/ScratchDesktop.svg'; import logo from '../icon/ScratchDesktop.svg';
import styles from './about.css'; import styles from './about.css';
// TODO: localization?
const AboutElement = () => ( const AboutElement = () => (
<div className={styles.aboutBox}> <div className={styles.aboutBox}>
<div><img <div><img

View file

@ -1,4 +1,4 @@
import {ipcRenderer, remote, shell} from 'electron'; import {ipcRenderer, remote} from 'electron';
import bindAll from 'lodash.bindall'; import bindAll from 'lodash.bindall';
import omit from 'lodash.omit'; import omit from 'lodash.omit';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
@ -28,12 +28,6 @@ import ElectronStorageHelper from '../common/ElectronStorageHelper';
import styles from './app.css'; import styles from './app.css';
// override window.open so that it uses the OS's default browser, not an electron browser
window.open = function (url, target) {
if (target === '_blank') {
shell.openExternal(url);
}
};
// Register "base" page view // Register "base" page view
// analytics.pageview('/'); // analytics.pageview('/');

View file

@ -3,7 +3,6 @@ import ReactDOM from 'react-dom';
import styles from './privacy.css'; import styles from './privacy.css';
// TODO: localization?
const PrivacyElement = () => ( const PrivacyElement = () => (
<div className={styles.privacyBox}> <div className={styles.privacyBox}>
<h1>Privacy Policy</h1> <h1>Privacy Policy</h1>
@ -11,7 +10,11 @@ const PrivacyElement = () => (
We understand how important privacy is to our community, especially children and their parents. We wrote We understand how important privacy is to our community, especially children and their parents. We wrote
this privacy policy to explain what information we collect through the Scratch application (the this privacy policy to explain what information we collect through the Scratch application (the
&ldquo;App&rdquo;), how we use it, and what we&apos;re doing to keep it safe. If you have any questions &ldquo;App&rdquo;), how we use it, and what we&apos;re doing to keep it safe. If you have any questions
regarding this privacy policy, you can <a href="https://scratch.mit.edu/contact-us">contact us</a>. regarding this privacy policy, you can <a
href="https://scratch.mit.edu/contact-us/"
target="_blank"
rel="noopener noreferrer"
>contact us</a>.
</p> </p>
<h2>What information does the App collect?</h2> <h2>What information does the App collect?</h2>
<p> <p>