Open external URLs in OS default browser
This commit is contained in:
parent
3abd3dfd5e
commit
96191e5857
11
src/main.js
11
src/main.js
@ -1,6 +1,6 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import {app, BrowserWindow, ipcMain, Menu, Tray} from "electron";
|
import {app, BrowserWindow, ipcMain, Menu, shell, Tray} from "electron";
|
||||||
|
|
||||||
import Config from "./Config";
|
import Config from "./Config";
|
||||||
|
|
||||||
@ -60,6 +60,15 @@ function createWindow() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open external links in default OS browser
|
||||||
|
app.on('web-contents-created', (e, contents) => {
|
||||||
|
if (contents.getType() === 'webview') {
|
||||||
|
contents.on('new-window', (e, url) => {
|
||||||
|
e.preventDefault();
|
||||||
|
shell.openExternal(url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Sync services with navigation
|
// Sync services with navigation
|
||||||
window.webContents.on('dom-ready', sendServices);
|
window.webContents.on('dom-ready', sendServices);
|
||||||
|
Loading…
Reference in New Issue
Block a user