From aad918483f29ebd7599dd9829c4aa011a3042029 Mon Sep 17 00:00:00 2001 From: Mack_Ignacio Date: Fri, 27 Jul 2018 22:12:42 +0800 Subject: [PATCH 1/2] Add electron:run that wait for main.j before running electron --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b534294..b369988 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "electron:serve": "wait-on ./dist/electron-angular/index.html && npm run electron:watch", "ng:build": "ng build --base-href ./ --watch=true", "electron:tsc": "tsc -w main.ts ", - "electron:watch": "concurrently --kill-others \"npm run electron:tsc \" \"electron . --serve\"" + "electron:run": "wait-on main.js && electron . --serve", + "electron:watch": "concurrently --kill-others \"npm run electron:tsc \" \"npm run electron:run\"" }, "private": true, "dependencies": { From a2817e8bcdda91bbd6abcb0933a645730a6026ec Mon Sep 17 00:00:00 2001 From: Mack_Ignacio Date: Fri, 27 Jul 2018 22:20:00 +0800 Subject: [PATCH 2/2] Create ElectronMain Class and make mainWindow full screen --- main.ts | 50 +++++++++++--------------------------------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/main.ts b/main.ts index 6acfbb5..ae4cec6 100644 --- a/main.ts +++ b/main.ts @@ -3,51 +3,18 @@ import * as path from "path"; import * as url from "url"; process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true"; -require("electron-reload")(__dirname, { - electron: require(`${__dirname}/node_modules/electron`) -}); -let win; -function createWindow() { - win = new BrowserWindow({ width: 800, height: 600 }); - win.loadURL( - url.format({ - pathname: path.join(__dirname, "/dist/electron-angular/index.html"), - protocol: "file:", - slashes: true - }) - ); - win.webContents.openDevTools(); - win.on("closed", () => { - app.quit(); - }); -} - -app.on("ready", createWindow); - -app.on("window-all-closed", () => { - if (process.platform !== "darwin") { - app.quit(); - } -}); - -app.on("activate", () => { - if (win === null) { - createWindow(); - } -}); class ElectronMain { + appTitle = "Electron Angular Quickstart"; args: any; serve: boolean; mainWindow: BrowserWindow; constructor() { - app.on("ready", this.createMainWindow); - require("electron-reload")(__dirname, { - electron: require(`${__dirname}/node_modules/electron`) - }); + this.checkElectronArgs(); this.initApp(); this.initIpc(); } + checkElectronArgs() { this.args = process.argv.slice(1); this.serve = this.args.some(val => val === "--serve"); @@ -60,8 +27,13 @@ class ElectronMain { createMainWindow() { this.mainWindow = new BrowserWindow({ - x: 0, - y: 0 + title: this.appTitle, + fullscreen: true, + minimizable: false, + maximizable: false, + autoHideMenuBar: true, + alwaysOnTop: true, + closable: false }); this.mainWindow.loadURL( url.format({ @@ -94,4 +66,4 @@ class ElectronMain { initIpc() {} } -// export default new ElectronMain(); +export default new ElectronMain();