-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (32 loc) · 837 Bytes
/
index.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
const { app, BrowserWindow, ipcMain } = require("electron");
const path = require("path");
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, "preload.js"),
nodeIntegration: true,
contextIsolation: false,
},
});
win.webContents.openDevTools();
win.loadFile("index.html");
}
app.whenReady().then(() => {
createWindow();
});
setTimeout(() => {
// 在主进程中.
ipcMain.on("message", (event, arg) => {
console.log("main process message", typeof arg);
// loop();
// console.log(ipcMain, event);
// event.send("reply", JSON.parse(JSON.stringify(arg)));
});
}, 2000);
const loop = () => {
const now = Date.now();
while (Date.now() - now < 5 * 1000) {}
console.log("loop end");
};