arnaucube
arnaucube/openworktimePublic Self-hosted repository
openworktime/desktopapp/main.js
desktopapp/main.jsRaw
 1const electron = require('electron')
 2// Module to control application life.
 3const app = electron.app
 4// Module to create native browser window.
 5const BrowserWindow = electron.BrowserWindow
 6
 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.
 9let mainWindow
10
11function createWindow () {
12  // Create the browser window.
13  mainWindow = new BrowserWindow({width: 1100, height: 650})
14
15  mainWindow.setMenu(null);
16
17  // and load the index.html of the app.
18  mainWindow.loadURL(`file://${__dirname}/index.html`)
19
20  // Open the DevTools.
21  //mainWindow.webContents.openDevTools()
22
23  // Emitted when the window is closed.
24  mainWindow.on('closed', function () {
25    // Dereference the window object, usually you would store windows
26    // in an array if your app supports multi windows, this is the time
27    // when you should delete the corresponding element.
28    mainWindow = null
29  })
30}
31
32// This method will be called when Electron has finished
33// initialization and is ready to create browser windows.
34// Some APIs can only be used after this event occurs.
35app.on('ready', createWindow)
36
37// Quit when all windows are closed.
38app.on('window-all-closed', function () {
39  // On OS X it is common for applications and their menu bar
40  // to stay active until the user quits explicitly with Cmd + Q
41  if (process.platform !== 'darwin') {
42    app.quit()
43  }
44})
45
46app.on('activate', function () {
47  // On OS X it's common to re-create a window in the app when the
48  // dock icon is clicked and there are no other windows open.
49  if (mainWindow === null) {
50    createWindow()
51  }
52})
53
54// In this file you can include the rest of your app's specific main process
55// code. You can also put them in separate files and require them here.