-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
54 lines (46 loc) · 1.52 KB
/
main.js
File metadata and controls
54 lines (46 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const { app, BrowserWindow, dialog } = require('electron');
const path = require('path');
const PORT = 3535;
let mainWindow = null;
function createWindow(port) {
mainWindow = new BrowserWindow({
width: 1100,
height: 780,
minWidth: 720,
minHeight: 540,
title: 'Tutorial Recorder',
show: false,
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
},
});
mainWindow.loadURL(`http://localhost:${port}`);
mainWindow.once('ready-to-show', () => mainWindow.show());
mainWindow.on('closed', () => { mainWindow = null; });
}
app.whenReady().then(async () => {
// Point Playwright at the bundled browser directory so the app works
// without a separate `playwright install` step.
// - Packaged: browsers are in the app's Resources folder (extraResources)
// - Dev: browsers are in ./playwright-browsers/ (npm run install:browsers)
const browsersPath = app.isPackaged
? path.join(process.resourcesPath, 'playwright-browsers')
: path.join(__dirname, 'playwright-browsers');
process.env.PLAYWRIGHT_BROWSERS_PATH = browsersPath;
// Lazy require — after env vars are in place
const { startServer } = require('./server');
try {
const port = await startServer(PORT);
createWindow(port);
} catch (err) {
dialog.showErrorBox('Startup Error', err.message);
app.quit();
}
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
app.on('activate', () => {
if (mainWindow === null) createWindow(PORT);
});