From 867f019d82fb924a69c27b37b19ff4a10fa637b7 Mon Sep 17 00:00:00 2001 From: Rogerio Chaves Date: Mon, 6 Apr 2020 08:26:13 +0200 Subject: [PATCH] Open in browser instead of electron window --- app/index.js | 2 -- app/lib/electron.js | 35 ++++------------------------------- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/app/index.js b/app/index.js index 8fa153c..dbe8025 100644 --- a/app/index.js +++ b/app/index.js @@ -12,7 +12,6 @@ setTimeout(() => { if (process.env.NODE_ENV !== "production") { const chokidar = require("chokidar"); const watcher = chokidar.watch("./lib"); - const { BrowserWindow } = require("electron"); watcher.on("ready", () => { watcher.on("all", () => { @@ -22,7 +21,6 @@ if (process.env.NODE_ENV !== "production") { }); if (server) server.close(); server = require("./lib/express"); - BrowserWindow.getAllWindows()[0].reload(); }); }); } diff --git a/app/lib/electron.js b/app/lib/electron.js index 5ec9fe1..8017621 100644 --- a/app/lib/electron.js +++ b/app/lib/electron.js @@ -1,33 +1,6 @@ -const { app, BrowserWindow } = require("electron"); +const { app, shell } = require("electron"); -const createWindow = () => { - // Create the browser window. - let win = new BrowserWindow({ - width: 800, - height: 600, - webPreferences: { - nodeIntegration: true, - }, - }); - - win.loadURL(`http://localhost:${process.env.EXPRESS_PORT || 3000}`); -}; - -app.whenReady().then(createWindow); - -// Quit when all windows are closed. -app.on("window-all-closed", () => { - // On macOS it is common for applications and their menu bar - // to stay active until the user quits explicitly with Cmd + Q - if (process.platform !== "darwin") { - app.quit(); - } -}); - -app.on("activate", () => { - // On macOS it's common to re-create a window in the app when the - // dock icon is clicked and there are no other windows open. - if (BrowserWindow.getAllWindows().length == 0) { - createWindow(); - } +app.whenReady().then(() => { + let port = process.env.EXPRESS_PORT || 3000; + shell.openExternal(`http://localhost:${port}`); });