From 746b5f13bb08c614df290e69946cfd116a550521 Mon Sep 17 00:00:00 2001 From: TC Date: Wed, 11 Sep 2019 23:46:19 +0200 Subject: [PATCH] Fix Google login --- index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 13b6fa3f..fe18f419 100644 --- a/index.js +++ b/index.js @@ -42,8 +42,10 @@ function createMainWindow() { backgroundColor: "#000", show : false, webPreferences : { - nodeIntegration: false, - preload : path.join(__dirname, "preload.js") + nodeIntegration : false, + preload : path.join(__dirname, "preload.js"), + nativeWindowOpen: true, // window.open return Window object(like in regular browsers), not BrowserWindowProxy + affinity : "main-window" // main window, and addition windows should work in one process }, frame : !is.macOS(), titleBarStyle: is.macOS() ? "hiddenInset": "default" @@ -86,6 +88,17 @@ function createMainWindow() { } }); + win.webContents.on( + "new-window", + (e, url, frameName, disposition, options) => { + // hook on new opened window + + // at now new window in mainWindow renderer process. + // Also, this will automatically get an option `nodeIntegration=false`(not override to true, like in iframe's) - like in regular browsers + options.webPreferences.affinity = "main-window"; + } + ); + win.on("move", () => { let position = win.getPosition(); store.set("window-position", { x: position[0], y: position[1] });