index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import {app, BrowserWindow} from 'electron'
  2. /**
  3. * Set `__static` path to static files in production
  4. * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
  5. */
  6. if (process.env.NODE_ENV !== 'development') {
  7. global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
  8. }
  9. let mainWindow
  10. const winURL = process.env.NODE_ENV === 'development'
  11. ? `http://localhost:9080`
  12. : `file://${__dirname}/index.html`
  13. function createWindow() {
  14. /**
  15. * Initial window options
  16. */
  17. mainWindow = new BrowserWindow({
  18. height: 563,
  19. useContentSize: true,
  20. width: 1000
  21. })
  22. mainWindow.loadURL(winURL)
  23. mainWindow.on('closed', () => {
  24. mainWindow = null
  25. })
  26. }
  27. app.on('ready', createWindow)
  28. app.on('window-all-closed', () => {
  29. if (process.platform !== 'darwin') {
  30. app.quit()
  31. }
  32. })
  33. app.on('activate', () => {
  34. if (mainWindow === null) {
  35. createWindow()
  36. }
  37. })
  38. /**
  39. * Auto Updater
  40. *
  41. * Uncomment the following code below and install `electron-updater` to
  42. * support auto updating. Code Signing with a valid certificate is required.
  43. * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-builder.html#auto-updating
  44. */
  45. /*
  46. import { autoUpdater } from 'electron-updater'
  47. autoUpdater.on('update-downloaded', () => {
  48. autoUpdater.quitAndInstall()
  49. })
  50. app.on('ready', () => {
  51. if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdates()
  52. })
  53. */