|
Size: 804
Comment:
|
← Revision 6 as of 2023-03-02 17:39:24 ⇥
Size: 977
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 11: | Line 11: |
| An example `app`: |
|
| Line 13: | Line 15: |
| const path = require('path'); | |
| Line 23: | Line 26: |
| preload: 'preload.js', | preload: path.join(__dirname, 'preload.js'), |
| Line 27: | Line 30: |
| win.loadFile('index.html'); | win.loadFile(path.join(__dirname, 'index.html')); |
| Line 45: | Line 48: |
| For details on `BrowserWindow`, see [[Node/Electron/BrowserWindow|here]]. |
Electron App
Contents
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.
