mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-26 12:21:03 +00:00
chore: merge with main
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { AppUpdaterEvents } from "@types";
|
||||
import { AppUpdaterEvent } from "@types";
|
||||
import { registerEvent } from "../register-event";
|
||||
import updater, { UpdateInfo } from "electron-updater";
|
||||
import { WindowManager } from "@main/services";
|
||||
@@ -6,12 +6,15 @@ import { app } from "electron";
|
||||
|
||||
const { autoUpdater } = updater;
|
||||
|
||||
const sendEvent = (event: AppUpdaterEvents) => {
|
||||
const sendEvent = (event: AppUpdaterEvent) => {
|
||||
WindowManager.mainWindow?.webContents.send("autoUpdaterEvent", event);
|
||||
};
|
||||
|
||||
const sendEventsForDebug = false;
|
||||
|
||||
const mockValuesForDebug = () => {
|
||||
sendEvent({ type: "update-available", info: { version: "1.3.0" } });
|
||||
sendEvent({ type: "update-downloaded" });
|
||||
};
|
||||
|
||||
const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
@@ -25,7 +28,7 @@ const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
|
||||
if (app.isPackaged) {
|
||||
autoUpdater.checkForUpdates();
|
||||
} else {
|
||||
} else if (sendEventsForDebug) {
|
||||
mockValuesForDebug();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -44,6 +44,11 @@ const openGameInstaller = async (
|
||||
return true;
|
||||
}
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
shell.openPath(gamePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fs.lstatSync(gamePath).isFile()) {
|
||||
return executeGameInstaller(gamePath);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
MenuItemConstructorOptions,
|
||||
Tray,
|
||||
app,
|
||||
nativeImage,
|
||||
shell,
|
||||
} from "electron";
|
||||
import { is } from "@electron-toolkit/utils";
|
||||
@@ -88,7 +89,16 @@ export class WindowManager {
|
||||
}
|
||||
|
||||
public static createSystemTray(language: string) {
|
||||
const tray = new Tray(trayIcon);
|
||||
let tray;
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
const macIcon = nativeImage
|
||||
.createFromPath(trayIcon)
|
||||
.resize({ width: 24, height: 24 });
|
||||
tray = new Tray(macIcon);
|
||||
} else {
|
||||
tray = new Tray(trayIcon);
|
||||
}
|
||||
|
||||
const updateSystemTray = async () => {
|
||||
const games = await gameRepository.find({
|
||||
@@ -149,9 +159,14 @@ export class WindowManager {
|
||||
return contextMenu;
|
||||
};
|
||||
|
||||
const showContextMenu = async () => {
|
||||
const contextMenu = await updateSystemTray();
|
||||
tray.popUpContextMenu(contextMenu);
|
||||
};
|
||||
|
||||
tray.setToolTip("Hydra");
|
||||
|
||||
if (process.platform === "win32" || process.platform === "linux") {
|
||||
if (process.platform !== "darwin") {
|
||||
tray.addListener("click", () => {
|
||||
if (this.mainWindow) {
|
||||
if (WindowManager.mainWindow?.isMinimized())
|
||||
@@ -164,10 +179,10 @@ export class WindowManager {
|
||||
this.createMainWindow();
|
||||
});
|
||||
|
||||
tray.addListener("right-click", async () => {
|
||||
const contextMenu = await updateSystemTray();
|
||||
tray.popUpContextMenu(contextMenu);
|
||||
});
|
||||
tray.addListener("right-click", showContextMenu);
|
||||
} else {
|
||||
tray.addListener("click", showContextMenu);
|
||||
tray.addListener("right-click", showContextMenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user