2024-04-24 20:12:28 +03:00
|
|
|
diff --git a/./app/main/lib/createTray.js b/./app1/main/lib/createTray.js
|
2024-02-09 23:13:29 +03:00
|
|
|
--- a/main/lib/createTray.js
|
|
|
|
+++ b/main/lib/createTray.js
|
2024-02-10 20:48:13 +03:00
|
|
|
@@ -0,0 +1,20 @@
|
2024-02-10 19:14:52 +03:00
|
|
|
+const { app, Menu, Tray, nativeImage } = require('electron');
|
|
|
|
+const path = require('path');
|
2024-02-09 23:13:29 +03:00
|
|
|
+
|
|
|
|
+function createTray(window) {
|
2024-02-10 19:14:52 +03:00
|
|
|
+ const iconPath = path.join(__dirname, '../../build/next-desktop/favicon.png');
|
2024-04-24 20:12:28 +03:00
|
|
|
+ const tray = new Tray(iconPath);
|
2024-02-09 23:13:29 +03:00
|
|
|
+ const contextMenu = Menu.buildFromTemplate([
|
2024-02-20 16:10:09 +03:00
|
|
|
+ {label: 'Открыть', click: () => window.show()},
|
|
|
|
+ {label: 'Закрыть Яндекс Музыку', click: () => app.quit()}
|
2024-02-09 23:13:29 +03:00
|
|
|
+ ]);
|
2024-02-20 16:10:09 +03:00
|
|
|
+ tray.setToolTip('Яндекс Музыка');
|
2024-02-09 23:13:29 +03:00
|
|
|
+ tray.setContextMenu(contextMenu);
|
|
|
|
+
|
|
|
|
+ tray.on('click', () => {
|
|
|
|
+ window.show();
|
|
|
|
+ });
|
|
|
|
+ tray.setIgnoreDoubleClickEvents(true);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+exports.createTray = createTray;
|
|
|
|
|
2024-04-24 20:12:28 +03:00
|
|
|
|
2024-02-09 23:13:29 +03:00
|
|
|
diff --git a/main/index.js b/main/index.js
|
|
|
|
--- a/main/index.js
|
|
|
|
+++ b/main/index.js
|
2024-04-24 20:12:28 +03:00
|
|
|
@@ -33,6 +33,9 @@ const handleWindowSessionEvents_js_1 = require("./lib/handlers/handleWindowSessi
|
2024-02-09 23:13:29 +03:00
|
|
|
(0, safeRedirects_js_1.safeRedirects)(window);
|
|
|
|
(0, handleWindowLifecycleEvents_js_1.handleWindowLifecycleEvents)(window);
|
|
|
|
(0, handleWindowSessionEvents_js_1.handleWindowSessionEvents)(window);
|
2024-04-24 20:12:28 +03:00
|
|
|
+ const {createTray} = require('./lib/createTray.js');
|
|
|
|
+ const trayEnabled = process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0;
|
|
|
|
+ if (trayEnabled){createTray(window);}
|
|
|
|
(0, events_js_1.handleApplicationEvents)(window);
|
|
|
|
(0, handleExternalLink_js_1.handleExternalLink)(window);
|
|
|
|
(0, logger_js_1.logWindowLifecycle)(window);
|
|
|
|
|
|
|
|
diff --git a/./app/main/lib/handlers/handleWindowLifecycleEvents.js b/./app1/main/lib/handlers/handleWindowLifecycleEvents.js
|
|
|
|
--- a/main/lib/handlers/handleWindowLifecycleEvents.js
|
|
|
|
+++ b/main/lib/handlers/handleWindowLifecycleEvents.js
|
|
|
|
@@ -29,9 +29,8 @@ const handleWindowLifecycleEvents = (window) => {
|
|
|
|
state_js_1.state.willQuit = true;
|
|
|
|
});
|
|
|
|
electron_1.app.on('window-all-closed', () => {
|
|
|
|
- if (node_os_1.default.platform() === platform_js_1.Platform.WINDOWS) {
|
|
|
|
- electron_1.app.quit();
|
|
|
|
- }
|
|
|
|
+ const trayEnabled = process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0;
|
|
|
|
+ if (!trayEnabled) {electron_1.app.quit();}
|
|
|
|
});
|
|
|
|
electron_1.app.on('browser-window-blur', () => {
|
|
|
|
setBlurredTime();
|
|
|
|
@@ -49,22 +48,11 @@ const handleWindowLifecycleEvents = (window) => {
|
|
|
|
checkAndUpdateApplicationData(window);
|
|
|
|
});
|
|
|
|
window.on('close', (event) => {
|
|
|
|
- if (node_os_1.default.platform() !== platform_js_1.Platform.MACOS) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (state_js_1.state.willQuit) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
+ const trayEnabled = process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0;
|
|
|
|
+ if (!trayEnabled) {electron_1.app.quit();}
|
|
|
|
+ if (state_js_1.state.willQuit) {return;}
|
|
|
|
event.preventDefault();
|
|
|
|
- if (window.isFullScreen()) {
|
|
|
|
- window.once('leave-full-screen', () => {
|
|
|
|
- (0, createWindow_js_1.toggleWindowVisibility)(window, false);
|
|
|
|
- });
|
|
|
|
- window.setFullScreen(false);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- (0, createWindow_js_1.toggleWindowVisibility)(window, false);
|
|
|
|
- }
|
|
|
|
+ (0, createWindow_js_1.toggleWindowVisibility)(window, false);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
exports.handleWindowLifecycleEvents = handleWindowLifecycleEvents;
|