index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const {app, BrowserWindow} = require('electron')
  2. const path = require('path')
  3. const url = require('url')
  4. // Keep a global reference of the window object, if you don't, the window will
  5. // be closed automatically when the JavaScript object is garbage collected.
  6. let win
  7. function createWindow() {
  8. win = new BrowserWindow({ width: 925, height: 500 })
  9. win.loadURL(url.format({
  10. pathname: path.join(__dirname, 'app', 'index.html'),
  11. protocol: 'file:',
  12. slashes: true
  13. }))
  14. //Open DevTools, this will be removed on release.
  15. win.webContents.openDevTools()
  16. win.setMenu(null)
  17. win.on('closed', () => {
  18. win = null
  19. })
  20. }
  21. app.on('ready', createWindow);
  22. app.on('window-all-closed', () => {
  23. // On macOS it is common for applications and their menu bar
  24. // to stay active until the user quits explicitly with Cmd + Q
  25. if (process.platform !== 'darwin') {
  26. app.quit()
  27. }
  28. })
  29. app.on('activate', () => {
  30. // On macOS it's common to re-create a window in the app when the
  31. // dock icon is clicked and there are no other windows open.
  32. if (win === null) {
  33. createWindow()
  34. }
  35. })