Advertisement
Guest User

main.js

a guest
Nov 2nd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. const { app, BrowserWindow } = require("electron"),
  2. path = require("path"),
  3. url = require("url");
  4.  
  5. const {
  6. default: installExtension,
  7. REACT_DEVELOPER_TOOLS
  8. } = require("electron-devtools-installer");
  9.  
  10. let mainWindow;
  11.  
  12. function createWindow() {
  13. mainWindow = new BrowserWindow({
  14. width: 1000,
  15. height: 600,
  16. frame: false
  17. });
  18. mainWindow.loadURL(
  19. url.format({
  20. pathname: path.join(__dirname, "index.html"),
  21. protocol: "file:",
  22. slashes: true
  23. })
  24. );
  25.  
  26. installExtension(REACT_DEVELOPER_TOOLS)
  27. .then(name => console.log(`Add Extension: ${name}`))
  28. .catch(err => console.log(`An error occurred: ${err}`));
  29.  
  30. mainWindow.on("closed", () => {
  31. mainWindow = null;
  32. });
  33. }
  34.  
  35. app.on("ready", createWindow);
  36.  
  37. app.on("window-all-closed", () => {
  38. // quit app when it's not OS X
  39. if (process.platform !== "darwin") {
  40. app.quit();
  41. }
  42. });
  43.  
  44. // Reactivate a window in OS X
  45. app.on("activate", () => {
  46. if (mainWindow === null) {
  47. createWindow();
  48. }
  49. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement