mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 12:15:44 +01:00
electron open pages in external browser
This commit is contained in:
parent
c564de40b3
commit
c3ac16f330
@ -1,4 +1,4 @@
|
||||
const { app, BrowserWindow, Menu, globalShortcut } = require("electron");
|
||||
const { app, BrowserWindow, Menu, globalShortcut, shell } = require("electron");
|
||||
|
||||
Menu.setApplicationMenu(false);
|
||||
function createWindow() {
|
||||
@ -20,6 +20,17 @@ function createWindow() {
|
||||
globalShortcut.register("f8", function () {
|
||||
win.loadFile("index.html", { query: { noScripts: "true" } });
|
||||
});
|
||||
|
||||
win.webContents.on("new-window", function (e, url) {
|
||||
// make sure local urls stay in electron perimeter
|
||||
if ("file://" === url.substr(0, "file://".length)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// and open every other protocols on the browser
|
||||
e.preventDefault();
|
||||
shell.openExternal(url);
|
||||
});
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user