forked from alpernae/HackerGPT-2.0-WinApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
46 lines (38 loc) · 1 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
const { app, BrowserWindow, Tray, Menu } = require('electron');
const path = require('path');
let mainWindow;
let tray;
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 800,
autoHideMenuBar: true
});
mainWindow.loadURL('https://chat.hackerai.co');
}
function createTray() {
tray = new Tray(path.join(__dirname, 'tray/icon.jpg'));
const contextMenu = Menu.buildFromTemplate([
{ label: 'Open', click: () => mainWindow.show() },
{ label: 'Quit', click: () => app.quit() }
]);
tray.setToolTip('HackerGPT 2.0');
tray.setContextMenu(contextMenu);
tray.on('click', () => {
if (mainWindow.isVisible()) {
mainWindow.hide();
} else {
mainWindow.show();
}
});
}
app.whenReady().then(() => {
createWindow();
createTray();
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit();
});