-
Notifications
You must be signed in to change notification settings - Fork 0
/
electron_main.js
42 lines (36 loc) · 1.13 KB
/
electron_main.js
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
const { app, BrowserWindow, desktopCapturer, ipcMain } = require('electron');
const path = require('path')
const { Worker } = require('worker_threads');
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true
}
})
// win.loadFile('index.html')
win.loadURL('http://localhost:5500/src');
win.openDevTools();
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
});
require('dns').lookup(require('os').hostname(), (err, add, fam) => {
let worker = new Worker(`${__dirname}/server.js`, { workerData: { ip: add } });
ipcMain.handle('ip', () => add);
ipcMain.handle('getSources', async () => {
return await desktopCapturer.getSources({ types: ['window', 'screen', 'audio'] });
});
});
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})