Differences between revisions 2 and 3
Revision 2 as of 2023-03-02 17:34:10
Size: 789
Comment:
Revision 3 as of 2023-03-02 17:34:19
Size: 804
Comment:
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:
const { app } = require('electron'); const { app, BrowserWindow } = require('electron');

Electron App


App

const { app, BrowserWindow } = require('electron');

var win;

function initializeWindow() {
  win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      contextIsolation: true,
      nodeIntegration: false,
      preload: 'preload.js',
    }
  });

  win.loadFile('index.html');

  win.on('closed', () => {
    win = null;
  });
};

app.on('ready', initializeWindow);

app.on('window-all-closed', () => {
  if (process.platform !== "darwin") app.quit();
});

app.on('activate', () => {
  if (win === null) initializeWindow();
});


See also

Electron API for app


CategoryRicottone

Node/Electron/App (last edited 2023-03-02 17:39:24 by DominicRicottone)