mirror of
https://github.com/Mintplex-Labs/nut.js.git
synced 2026-07-01 20:04:00 -04:00
49f146494e
* (#559) Adjust getRegion implementation It’ll now cut off window regions at the borders of the main screen, avoiding errors due to out of bounds regions * (#559) Moved window e2e test into dedicated e2e subpackage
38 lines
874 B
JavaScript
38 lines
874 B
JavaScript
const { app, ipcMain, BrowserWindow } = require("electron");
|
|
const path = require("path");
|
|
const { POS_X, POS_Y, WIDTH, HEIGHT } = require("./constants");
|
|
|
|
function createWindow() {
|
|
const mainWindow = new BrowserWindow({
|
|
width: WIDTH,
|
|
height: HEIGHT,
|
|
alwaysOnTop: true,
|
|
webPreferences: {
|
|
nodeIntegration: true,
|
|
preload: path.join(__dirname, "preload.js"),
|
|
},
|
|
});
|
|
mainWindow.loadFile(path.join(__dirname, "index.html"));
|
|
mainWindow.setPosition(POS_X, POS_Y);
|
|
}
|
|
|
|
ipcMain.on("main", (event, args) => {
|
|
if (args === "quit") {
|
|
app.quit();
|
|
}
|
|
});
|
|
|
|
app.whenReady().then(() => {
|
|
setTimeout(() => app.exit(1), 15000);
|
|
createWindow();
|
|
|
|
app.on("activate", function () {
|
|
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
|
});
|
|
});
|
|
|
|
app.on("window-all-closed", function () {
|
|
console.log("Bye!");
|
|
app.quit();
|
|
});
|