-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
89 lines (78 loc) · 2.31 KB
/
Copy pathmain.js
File metadata and controls
89 lines (78 loc) · 2.31 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const { app, BrowserWindow, ipcMain, contextBridge } = require("electron");
const path = require("node:path");
const Store = require("electron-store");
const store = new Store();
const createWindow = () => {
const mainWindow = new BrowserWindow({
width: 600,
frame: false,
resizable: false,
height: 600,
webPreferences: {
preload: path.join(__dirname, "assets/js/preload.js"),
devTools: true,
},
icon: path.join(__dirname, "assets/images/icon.ico"),
});
var alarm = store.get("alarm");
if (!alarm) {
store.set("alarm", "1");
alarm = "1";
}
ipcMain.on("close-window", (event) => {
mainWindow.close();
});
ipcMain.on("min-window", (event) => {
mainWindow.minimize();
});
ipcMain.on("music-player", (event) => {
musicPlayerWindow();
});
ipcMain.on("setKey", (event, data) => {
store.set(data.key, data.value);
console.log(store.get(data.key));
});
mainWindow.loadFile("index.html");
mainWindow.webContents.on("did-finish-load", () => {
console.log(alarm);
mainWindow.webContents.executeJavaScript(
`document.getElementById('alarm').innerText = '${alarm}';`
);
});
};
// app.on("browser-window-created", (e, window) => {
// window.setMenu(null);
// });
function musicPlayerWindow() {
musicPlayer = new BrowserWindow({
width: 400,
height: 300,
frame: false,
resizable: false,
icon: path.join(__dirname, "assets/images/headphone.png"),
webPreferences: {
preload: path.join(__dirname, "assets/js/MP_preload.js"),
nodeIntegration: true,
devTools: true,
},
});
musicPlayer.loadFile("music_player.html");
musicPlayer.on("closed", function () {
musicPlayer = null;
});
ipcMain.on("close-music-window", (event) => {
musicPlayer.close();
});
ipcMain.on("min-music-window", (event) => {
musicPlayer.minimize();
});
}
app.whenReady().then(() => {
createWindow();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") app.quit();
});