-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
40 lines (32 loc) · 1.07 KB
/
Copy pathmain.ts
File metadata and controls
40 lines (32 loc) · 1.07 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
import { app, BrowserWindow, ipcMain } from 'electron';
import { Eimer, EimerIpcMainTransport, EimerWorkerThreadTransport } from 'eimer';
import * as path from 'path';
import { Worker } from 'node:worker_threads';
let mainWindow: BrowserWindow;
// Set up main process node
const eimer = new Eimer('main');
// Set up Worker Thread
const worker = new Worker(__dirname + '/worker');
// Connect Worker Thread to Eimer
eimer.connect(new EimerWorkerThreadTransport(worker));
// Start the app
app.whenReady().then(() => {
// Create main window^
mainWindow = new BrowserWindow({
width: 1440,
height: 600,
webPreferences: {
sandbox: true,
preload: path.join(__dirname, 'preload.js')
}
});
eimer.connect(new EimerIpcMainTransport(ipcMain, mainWindow.webContents));
// Load the renderer
mainWindow.loadFile(path.join(__dirname, '../index.html'));
mainWindow.webContents.openDevTools();
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
});