fix tray
This commit is contained in:
@ -96,7 +96,16 @@ const ensureTray = () => {
|
|||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
label: 'Выход',
|
label: 'Выход',
|
||||||
click: () => app.quit(),
|
click: () => {
|
||||||
|
isQuitting = true;
|
||||||
|
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.removeAllListeners('close');
|
||||||
|
mainWindow.destroy(); // ⬅ КЛЮЧЕВО
|
||||||
|
}
|
||||||
|
|
||||||
|
app.quit();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -119,6 +128,7 @@ const applyLoginItemSettings = () => {
|
|||||||
|
|
||||||
let tray: Tray | null = null;
|
let tray: Tray | null = null;
|
||||||
let isAuthed = false;
|
let isAuthed = false;
|
||||||
|
let isQuitting = false;
|
||||||
|
|
||||||
let mainWindow: BrowserWindow | null = null;
|
let mainWindow: BrowserWindow | null = null;
|
||||||
|
|
||||||
@ -152,7 +162,19 @@ function buildTrayMenu() {
|
|||||||
|
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: 'Показать', click: () => { mainWindow?.show(); mainWindow?.focus(); } },
|
{ label: 'Показать', click: () => { mainWindow?.show(); mainWindow?.focus(); } },
|
||||||
{ label: 'Выход', click: () => app.quit() },
|
{
|
||||||
|
label: 'Выход',
|
||||||
|
click: () => {
|
||||||
|
isQuitting = true;
|
||||||
|
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.removeAllListeners('close');
|
||||||
|
mainWindow.destroy(); // ⬅ КЛЮЧЕВО
|
||||||
|
}
|
||||||
|
|
||||||
|
app.quit();
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
tray?.setContextMenu(Menu.buildFromTemplate(template));
|
tray?.setContextMenu(Menu.buildFromTemplate(template));
|
||||||
@ -259,9 +281,8 @@ const createWindow = async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.on('close', (e) => {
|
mainWindow.on('close', (e) => {
|
||||||
if (launcherSettings.closeToTray) {
|
if (!isQuitting && launcherSettings.closeToTray) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ensureTray();
|
|
||||||
mainWindow?.hide();
|
mainWindow?.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -317,6 +338,10 @@ app.on('window-all-closed', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.on('before-quit', () => {
|
||||||
|
isQuitting = true;
|
||||||
|
});
|
||||||
|
|
||||||
app
|
app
|
||||||
.whenReady()
|
.whenReady()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user