index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const {app, BrowserWindow} = require('electron')
  2. const path = require('path')
  3. const url = require('url')
  4. const ejse = require('ejs-electron')
  5. // Keep a global reference of the window object, if you don't, the window will
  6. // be closed automatically when the JavaScript object is garbage collected.
  7. let win
  8. function createWindow() {
  9. win = new BrowserWindow({ width: 980, height: 552, icon: getPlatformIcon('WesterosSealSquare'), frame: false})
  10. win.loadURL(url.format({
  11. pathname: path.join(__dirname, 'app', 'index.ejs'),
  12. protocol: 'file:',
  13. slashes: true
  14. }))
  15. win.setMenu(null)
  16. win.setResizable(true)
  17. win.on('closed', () => {
  18. win = null
  19. })
  20. }
  21. function getPlatformIcon(filename){
  22. const opSys = process.platform
  23. if (opSys === 'darwin') {
  24. filename = filename + '.icns'
  25. } else if (opSys === 'win32') {
  26. filename = filename + '.ico'
  27. } else {
  28. filename = filename + '.png'
  29. }
  30. return path.join(__dirname, 'app', 'assets', 'images', filename)
  31. }
  32. app.on('ready', createWindow);
  33. app.on('window-all-closed', () => {
  34. // On macOS it is common for applications and their menu bar
  35. // to stay active until the user quits explicitly with Cmd + Q
  36. if (process.platform !== 'darwin') {
  37. app.quit()
  38. }
  39. })
  40. app.on('activate', () => {
  41. // On macOS it's common to re-create a window in the app when the
  42. // dock icon is clicked and there are no other windows open.
  43. if (win === null) {
  44. createWindow()
  45. }
  46. })