Open external links (eg. to GitHub or Wiki) in default system browser instead of a new Electron window. (#3159)

This commit is contained in:
Krzysztof Jelski 2020-07-10 15:31:00 +02:00 committed by GitHub
parent fe935e918b
commit 3aa1e8f42b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { app } from 'electron';
import { app, shell } from 'electron';
import { registerAccountStoreHandlers } from '../main/account-store';
import { setupAutoUpdater } from './autoUpdater';
import { createWindow } from './window';
@ -15,4 +15,11 @@ const onReady = async () => {
await setupAutoUpdater();
};
app.on('web-contents-created', (e, webContents) => {
webContents.on('new-window', (e, url) => {
e.preventDefault();
shell.openExternal(url).catch(console.error);
});
});
app.whenReady().then(onReady).catch(console.error);