You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.2 KiB

  1. const electron = require('electron')
  2. // Module to control application life.
  3. const app = electron.app
  4. // Module to create native browser window.
  5. const BrowserWindow = electron.BrowserWindow
  6. const Tray = electron.Tray
  7. const Menu = electron.Menu
  8. // Keep a global reference of the window object, if you don't, the window will
  9. // be closed automatically when the JavaScript object is garbage collected.
  10. let mainWindow
  11. function createWindow () {
  12. // Create the browser window.
  13. mainWindow = new BrowserWindow({
  14. width: 850,
  15. height: 600,
  16. icon: 'img/darkID-logo-white.png'
  17. })
  18. tray = new Tray('img/darkID-logo-white.png')
  19. const contextMenu = Menu.buildFromTemplate([
  20. {label: 'Obre la finestra', type: 'radio'},
  21. {label: 'javascript madness', type: 'radio'},
  22. {label: 'Tanca', type: 'radio'}
  23. //{label: 'Tanca', type: 'radio', checked: true}
  24. ])
  25. tray.setToolTip('Panopticon, projectNSA')
  26. tray.setContextMenu(contextMenu)
  27. mainWindow.setMenu(null);
  28. // and load the index.html of the app.
  29. mainWindow.loadURL(`file://${__dirname}/index.html`)
  30. // Open the DevTools.
  31. //mainWindow.webContents.openDevTools()
  32. // Emitted when the window is closed.
  33. mainWindow.on('closed', function () {
  34. // Dereference the window object, usually you would store windows
  35. // in an array if your app supports multi windows, this is the time
  36. // when you should delete the corresponding element.
  37. mainWindow = null
  38. })
  39. }
  40. // This method will be called when Electron has finished
  41. // initialization and is ready to create browser windows.
  42. // Some APIs can only be used after this event occurs.
  43. app.on('ready', createWindow)
  44. // Quit when all windows are closed.
  45. app.on('window-all-closed', function () {
  46. // On OS X it is common for applications and their menu bar
  47. // to stay active until the user quits explicitly with Cmd + Q
  48. if (process.platform !== 'darwin') {
  49. app.quit()
  50. }
  51. })
  52. app.on('activate', function () {
  53. // On OS X it's common to re-create a window in the app when the
  54. // dock icon is clicked and there are no other windows open.
  55. if (mainWindow === null) {
  56. createWindow()
  57. }
  58. })
  59. // In this file you can include the rest of your app's specific main process
  60. // code. You can also put them in separate files and require them here.