-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
98 lines (83 loc) · 2.38 KB
/
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
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
90
91
92
93
94
95
96
97
98
const { app, BrowserWindow, ipcMain, screen } = require('electron');
const path = require('path');
// Flag to track if it's the first window load
let firstLoad = true;
let mainWindow;
// Function to create and configure the main window
function createMainWindow() {
mainWindow = new BrowserWindow({
width: 1280,
height: 720,
frame: false, // Remove window frame
show: true,
backgroundColor: '#202124',
webPreferences: {
nodeIntegration: true, // Allow Node.js integration
webviewTag: true,
plugins: true,
additionalArguments: ['filePath'],
preload: path.join(__dirname, 'preload.js'), // Path to preload script
}
});
mainWindow.loadURL('https://app.flutterflow.io/');
}
// Event handler for when Electron is ready
app.on("ready", () => {
createMainWindow();
});
// Event handler for when a new browser window is created
app.on("browser-window-created", function (event, window) {
// Configure new windows
if (!firstLoad) {
window.setMenu(null); // Remove the menu
window.removeMenu();
window.setMenuBarVisibility(false);
window.menuBarVisible = false;
window.autoHideMenuBar = true;
window.flashFrame(false);
window.webContents.on('dom-ready', () => {
// Handle new windows, such as setting custom headers
// You might want to set the preload for all new windows here.
});
}
firstLoad = false;
});
// Event handlers for window control
ipcMain.on('move-window', (event, deltaX, deltaY) => {
const currentWindow = BrowserWindow.getFocusedWindow();
if (currentWindow) {
const { x, y } = currentWindow.getBounds();
const newX = x + deltaX;
const newY = y + deltaY;
currentWindow.setPosition(newX, newY);
}
});
ipcMain.on('close-window', () => {
if (mainWindow) {
mainWindow.close();
}
});
ipcMain.on('minimize-window', () => {
if (mainWindow) {
mainWindow.minimize();
}
});
ipcMain.on('maximize-window', () => {
if (mainWindow) {
//const { height } = screen.getPrimaryDisplay().workAreaSize;
if (mainWindow.isMaximized()) {
mainWindow.unmaximize();
} else {
mainWindow.maximize();
}
}
});
ipcMain.on('cleancache-all', async () => {
await mainWindow.webContents.session.clearCache();
await mainWindow.webContents.session.clearStorageData();
app.relaunch();
app.exit();
});
ipcMain.on('refresh-window', () => {
mainWindow.reload()
});