0
0
mirror of https://github.com/cucumber-sp/yandex-music-linux.git synced 2025-09-28 01:29:03 +03:00

Update patches and repack script

This commit is contained in:
Andrey Onishchenko
2024-12-06 23:06:35 +03:00
parent 9cd5cdb864
commit 8767a74c0e
7 changed files with 19 additions and 118 deletions

View File

@@ -1,11 +0,0 @@
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -49,5 +49,6 @@
"kk",
"uz"
]
- }
+ },
+ "license": "UNLICENSED"
}

View File

@@ -1,84 +0,0 @@
diff --git a/main/lib/createTray.js b/main/lib/createTray.js
--- a/main/lib/createTray.js
+++ b/main/lib/createTray.js
@@ -0,0 +1,21 @@
+const { app, Menu, Tray, nativeImage } = require('electron');
+const path = require('path');
+
+function createTray(window) {
+ const iconPath = path.join(__dirname, '../../app/favicon.png');
+ const tray = new Tray(iconPath);
+ const contextMenu = Menu.buildFromTemplate([
+ {label: 'Открыть', click: () => window.show()},
+ {label: 'Закрыть Яндекс Музыку', click: () => app.quit()}
+ ]);
+ tray.setToolTip('Яндекс Музыка');
+ tray.setContextMenu(contextMenu);
+
+ tray.on('click', () => {
+ window.show();
+ });
+ tray.setIgnoreDoubleClickEvents(true);
+}
+
+exports.createTray = createTray;
+
diff --git a/main/index.js b/main/index.js
--- a/main/index.js
+++ b/main/index.js
@@ -48,6 +48,9 @@ Logger_js_1.Logger.setupLogger();
(0, handleMetrikaRequests_js_1.handleMetrikaRequests)(window);
(0, handleFrames_js_1.handleFrames)(window);
(0, handleCrash_js_1.handleCrash)();
+ const {createTray} = require('./lib/createTray.js');
+ const trayEnabled = process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0;
+ if (trayEnabled){createTray(window);}
await (0, loadURL_js_1.loadURL)(window);
if (node_os_1.default.platform() === platform_js_1.Platform.WINDOWS) {
(0, customTitleBar_js_1.createCustomTitleBar)(window);
diff --git a/main/lib/handlers/handleWindowLifecycleEvents.js b/main/lib/handlers/handleWindowLifecycleEvents.js
--- a/main/lib/handlers/handleWindowLifecycleEvents.js
+++ b/main/lib/handlers/handleWindowLifecycleEvents.js
@@ -31,9 +31,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();
@@ -54,22 +53,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);
});
const webContents = window.webContents;
webContents.on('did-fail-load', (event, errorCode, errorDescription, validatedUrl) => {

View File

@@ -1,13 +1,17 @@
diff --git a/main/index.js b/main/index.js
--- a/main/index.js
+++ b/main/index.js
@@ -52,7 +52,8 @@ Logger_js_1.Logger.setupLogger();
const trayEnabled = process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0;
if (trayEnabled){createTray(window);}
@@ -46,7 +46,12 @@ Logger_js_1.Logger.setupLogger();
(0, handleBackgroundTasks_js_1.handleBackgroundTasks)(window);
(0, handleCrash_js_1.handleCrash)();
await (0, loadURL_js_1.loadURL)(window);
- if (node_os_1.default.platform() === platform_js_1.Platform.WINDOWS) {
- if ([platform_js_1.Platform.WINDOWS, platform_js_1.Platform.LINUX].includes(deviceInfo_js_1.devicePlatform)) {
+ const customTitleBar = process.env.CUSTOM_TITLE_BAR && process.env.CUSTOM_TITLE_BAR > 0;
+ const platforms = [platform_js_1.Platform.WINDOWS];
+ if (customTitleBar) {
+ platforms.push(platform_js_1.Platform.LINUX);
+ }
+ if (platforms.includes(deviceInfo_js_1.devicePlatform)) {
(0, customTitleBar_js_1.createCustomTitleBar)(window);
}
if (config_js_1.config.enableAutoUpdate) {
@@ -16,22 +20,25 @@ diff --git a/main/index.js b/main/index.js
diff --git a/main/lib/createWindow.js b/main/lib/createWindow.js
--- a/main/lib/createWindow.js
+++ b/main/lib/createWindow.js
@@ -36,11 +36,12 @@ const toggleWindowState = (window) => {
@@ -38,13 +38,13 @@ const toggleWindowState = (window) => {
(0, tray_js_1.updateTrayMenu)(window);
};
exports.toggleWindowState = toggleWindowState;
+const customTitleBar = process.env.CUSTOM_TITLE_BAR && process.env.CUSTOM_TITLE_BAR > 0;
const createWindow = async () => {
- const withFrame = [platform_js_1.Platform.WINDOWS, platform_js_1.Platform.MACOS].includes(deviceInfo_js_1.devicePlatform);
+ const withFrame = !customTitleBar;
const window = new electron_1.BrowserWindow({
show: false,
center: true,
frame: withFrame,
- titleBarStyle: 'hidden',
+ frame: !customTitleBar,
trafficLightPosition: {
x: 16,
y: 10
diff --git a/main/lib/preload.js b/main/lib/preload.js
--- a/main/lib/preload.js
+++ b/main/lib/preload.js

View File

@@ -1,12 +0,0 @@
diff --git a/main/lib/createWindow.js b/main/lib/createWindow.js
--- a/main/lib/createWindow.js
+++ b/main/lib/createWindow.js
@@ -45,8 +45,6 @@ const createWindow = async () => {
x: 16,
y: 10
},
- minWidth: 768,
- minHeight: 650,
width: 1280,
height: 800,
webPreferences: {