1
0

index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. 'use strict';
  2. const electron = require('electron');
  3. const app = electron.app; // Module to control application life.
  4. const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
  5. const autoUpdater = require('auto-updater');
  6. const packageInfo = require('./package.json');
  7. // Keep a global reference of the window object, if you don't, the window will
  8. // be closed automatically when the JavaScript object is garbage collected.
  9. var mainWindow = null;
  10. // Quit when all windows are closed.
  11. app.on('window-all-closed', function() {
  12. // On OS X it is common for applications and their menu bar
  13. // to stay active until the user quits explicitly with Cmd + Q
  14. if (process.platform != 'darwin') {
  15. app.quit();
  16. }
  17. });
  18. autoUpdater.on("checking-for-update", () => {
  19. new Notification("Checking for updates");
  20. });
  21. // This method will be called when Electron has finished
  22. // initialization and is ready to create browser windows.
  23. app.on('ready', function() {
  24. // Create the browser window.
  25. mainWindow = new BrowserWindow({
  26. width: 450,
  27. height: 160,
  28. 'min-width': 450,
  29. 'min-height': 160,
  30. 'max-width': 500,
  31. 'max-height': 550,
  32. 'accept-first-mouse': true,
  33. 'title-bar-style': 'hidden'
  34. });
  35. // and load the index.html of the app.
  36. mainWindow.loadURL('file://' + __dirname + '/front-end/index.html');
  37. // Open the DevTools.
  38. //mainWindow.webContents.openDevTools();
  39. let updateFeed = `http://localhost:3000/updates/${packageInfo.name}/latest`;
  40. autoUpdater.setFeedURL(updateFeed + '?v=' + packageInfo.version);
  41. autoUpdater.checkForUpdates();
  42. // Emitted when the window is closed.
  43. mainWindow.on('closed', function() {
  44. // Dereference the window object, usually you would store windows
  45. // in an array if your app supports multi windows, this is the time
  46. // when you should delete the corresponding element.
  47. mainWindow = null;
  48. });
  49. });