electron main js template

Solutions on MaxInterview for electron main js template by the best coders in the world

showing results for - "electron main js template"
Theo
25 Nov 2016
1const {app, BrowserWindow} = require('electron');
2
3function createWindow () {
4	
5  console.log('Hello from electron');
6	
7  // Create the browser window.
8  mainWindow = new BrowserWindow({width: 800, height: 600})
9
10  // and load the index.html of the app.
11  mainWindow.loadURL(`file://${__dirname}/index.html`)
12
13  // Open the DevTools.
14  // mainWindow.webContents.openDevTools()
15
16  // Emitted when the window is closed.
17  mainWindow.on('closed', function () {
18    // Dereference the window object, usually you would store windows
19    // in an array if your app supports multi windows, this is the time
20    // when you should delete the corresponding element.
21    mainWindow = null
22  })
23}
24
25
26app.on('ready', createWindow);
27
28// Quit when all windows are closed.
29app.on('window-all-closed', function () {
30  // On OS X it is common for applications and their menu bar
31  // to stay active until the user quits explicitly with Cmd + Q
32  
33  if (process.platform !== 'darwin') {
34    app.quit()
35  }
36})
37
38app.on('activate', function () {
39  // On OS X it's common to re-create a window in the app when the
40  // dock icon is clicked and there are no other windows open.
41  
42  if (mainWindow === null) {
43    createWindow();
44  }
45})
46