-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectron-main.js
More file actions
53 lines (43 loc) · 1.33 KB
/
Copy pathelectron-main.js
File metadata and controls
53 lines (43 loc) · 1.33 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
const { app, BrowserWindow, screen, ipcMain } = require("electron");
const path = require("path");
let floatingWindow;
// Listen for window resize requests from Next.js
ipcMain.on("resize-window", (event, { width, height }) => {
if (floatingWindow && !floatingWindow.isDestroyed()) {
floatingWindow.setSize(width, height);
}
});
function createWindows() {
const { width: screenWidth, height: screenHeight } = screen.getPrimaryDisplay().workAreaSize;
// Create the Floating Frameless Desktop Dialog Window
floatingWindow = new BrowserWindow({
width: 480,
height: 650,
x: screenWidth - 520, // Position on the right side of the screen
y: 120,
frame: false,
transparent: true,
alwaysOnTop: true,
resizable: true,
hasShadow: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});
floatingWindow.loadURL("http://localhost:3000/floating");
floatingWindow.on("closed", () => {
app.quit();
});
}
app.whenReady().then(() => {
// Enable macOS transparent visual visuals
app.commandLine.appendSwitch("enable-transparent-visuals");
createWindows();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) createWindows();
});
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") app.quit();
});