index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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, icon: getPlatformIcon('WesterosSealSquare')})
  9. win.loadURL(url.format({
  10. pathname: path.join(__dirname, 'app', 'index.html'),
  11. protocol: 'file:',
  12. slashes: true
  13. }))
  14. win.setMenu(null)
  15. win.on('closed', () => {
  16. win = null
  17. })
  18. }
  19. function getPlatformIcon(filename){
  20. if (process.platform === 'darwin') {
  21. filename = filename + '.icns'
  22. } else if (process.platform === 'win32') {
  23. filename = filename + '.ico'
  24. } else {
  25. filename = filename + '.png'
  26. }
  27. return path.join(__dirname, 'app', 'assets', 'images', filename)
  28. }
  29. app.on('ready', createWindow);
  30. app.on('window-all-closed', () => {
  31. // On macOS it is common for applications and their menu bar
  32. // to stay active until the user quits explicitly with Cmd + Q
  33. if (process.platform !== 'darwin') {
  34. app.quit()
  35. }
  36. })
  37. app.on('activate', () => {
  38. // On macOS it's common to re-create a window in the app when the
  39. // dock icon is clicked and there are no other windows open.
  40. if (win === null) {
  41. createWindow()
  42. }
  43. })