Electron App


App

An example app:

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

var win;

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

  win.loadFile(path.join(__dirname, '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();
});

For details on BrowserWindow, see here.


See also

Electron API for app


CategoryRicottone

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