-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
68 lines (55 loc) · 1.58 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
const { app, BrowserWindow } = require('electron')
const path = require('path')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
enableRemoteModule: false
// offscreen: true, // Enables offscreen rendering
},
transparent: true, // Set to true for transparency
frame: false, // Remove window frame
backgroundColor: '#00000000', // Fully transparent background
hasShadow: true,
visualEffectState: 'active'
})
win.loadFile('index.html')
// Open DevTools by default
// win.webContents.openDevTools()
win.webContents.on('did-fail-load', (event, errorCode, errorDescription) => {
console.error(`Failed to load: ${errorDescription} (${errorCode})`);
});
// Make sure the window is always on top
win.setAlwaysOnTop(true, 'floating')
// Hide the window from the taskbar
win.setSkipTaskbar(true)
win.once('ready-to-show', () => {
win.show()
})
// Add this line to focus the window
win.focus()
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
// Add these lines to handle any unhandled exceptions
process.on('uncaughtException', (error) => {
console.error('Uncaught Exception:', error)
})
// Add these lines to log when the app is ready
app.on('ready', () => {
console.log('App is ready')
})