Base de code pour une application electron a base d'angular.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const { app, BrowserWindow, session, globalShortcut } = require("electron");
  2. const path = require("path");
  3. class Main {
  4. constructor() {
  5. const {
  6. width,
  7. height
  8. } = require("electron").screen.getPrimaryDisplay().workAreaSize;
  9. this.win = new BrowserWindow({
  10. title: "Control",
  11. backgroundColor: "#520000",
  12. x: width / 2,
  13. y: 0,
  14. width: width / 2,
  15. height: height,
  16. resizable: true,
  17. frame: false,
  18. show: false,
  19. webPreferences: {
  20. webSecurity: false
  21. }
  22. });
  23. if (process.env.NODE_ENV == "production")
  24. this.win.loadURL(`file://${__dirname}/dist/index.html`);
  25. else if (process.env.NODE_ENV == "development"){
  26. this.win.loadURL("http://localhost:4200");
  27. this.win.webContents.openDevTools();
  28. }
  29. this.win.once("ready-to-show", () => {
  30. this.win.show();
  31. });
  32. // Open the DevTools.
  33. globalShortcut.register("commandOrControl+shift+c", () => {
  34. this.win.webContents.openDevTools();
  35. });
  36. globalShortcut.register("commandOrControl+shift+r", () => {
  37. this.win.webContents.reload();
  38. });
  39. }
  40. }
  41. app.on("ready", () => {
  42. new Main();
  43. });