-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
34 lines (28 loc) · 866 Bytes
/
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
const { app, BrowserWindow, ipcMain } = require("electron");
const fs = require("node:fs");
const path = require("node:path");
const electronReload = require("electron-reload");
electronReload(__dirname);
const createWindow = () => {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, "preloaders", "preloader.js"),
},
});
win.loadFile(path.join(__dirname, "app", "index.html"));
};
app.whenReady().then(() => {
ipcMain.handle("backgrounds", () => {
const backgrounds = fs.readdirSync(path.join(__dirname, "assets", "images"));
return backgrounds;
});
createWindow();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") app.quit();
});