Skip to content

Commit 4744ea3

Browse files
committed
Remove Tray, it confuses the people
1 parent 592504a commit 4744ea3

File tree

1 file changed

+6
-43
lines changed

1 file changed

+6
-43
lines changed

main.js

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {app, BrowserWindow, Tray, Notification, Menu, globalShortcut, powerSaveBlocker } = require('electron/main');
1+
const {app, BrowserWindow, globalShortcut, powerSaveBlocker } = require('electron/main');
22
const path = require('node:path');
33
const {ipcMain} = require('electron')
44
const http = require('http');
@@ -8,7 +8,6 @@ const net = require('net');
88
const gotTheLock = app.requestSingleInstanceLock();
99

1010
let powerSaveBlockerId;
11-
let tray;
1211
let s_mainWindow;
1312
let msgbacklog=[];
1413
let httpServer;
@@ -185,9 +184,6 @@ app.on('before-quit', () => {
185184
if (httpServer) {
186185
httpServer.close();
187186
}
188-
if (tray) {
189-
tray.destroy();
190-
}
191187
});
192188

193189
process.on('SIGINT', () => {
@@ -217,45 +213,12 @@ if (!gotTheLock) {
217213
app.on('activate', function () {
218214
if (BrowserWindow.getAllWindows().length === 0) createWindow()
219215
});
220-
s_mainWindow.webContents.once('dom-ready', function() {
221-
if (msgbacklog.length>0) {
222-
s_mainWindow.webContents.send('updateMsg',msgbacklog.pop());
223-
}
224-
});
225-
226-
// Create the tray icon
227-
const path = require('path');
228-
const iconPath = path.join(__dirname, 'icon1616.png');
229-
tray = new Tray(iconPath);
230-
231-
const contextMenu = Menu.buildFromTemplate([
232-
{ label: 'Show App', click: () => s_mainWindow.show() },
233-
{ label: 'Quit', click: () => {
234-
console.log("Exiting");
235-
app.isQuitting = true;
236-
app.quit();
237-
}
238-
},
239-
]);
240-
241-
tray.setContextMenu(contextMenu);
242-
tray.setToolTip(require('./package.json').name + " V" + require('./package.json').version);
243-
244-
s_mainWindow.on('minimize', (event) => {
245-
event.preventDefault();
246-
s_mainWindow.hide(); // Hides the window instead of minimizing it to the taskbar
247-
});
248-
249-
s_mainWindow.on('close', (event) => {
250-
if (!app.isQuitting) {
251-
event.preventDefault();
252-
s_mainWindow.hide();
253-
}
216+
s_mainWindow.webContents.once('dom-ready', function() {
217+
if (msgbacklog.length>0) {
218+
s_mainWindow.webContents.send('updateMsg',msgbacklog.pop());
219+
}
220+
});
254221
});
255-
if (app.isPackaged && (process.platform === 'darwin')) {
256-
app.dock.hide();
257-
}
258-
})
259222
}
260223

261224
app.on('window-all-closed', function () {

0 commit comments

Comments
 (0)