mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
chore: merge with main
This commit is contained in:
commit
53f4394a49
BIN
build/icon.icns
BIN
build/icon.icns
Binary file not shown.
@ -24,7 +24,8 @@
|
|||||||
"downloads": "Downloads",
|
"downloads": "Downloads",
|
||||||
"search_results": "Search results",
|
"search_results": "Search results",
|
||||||
"settings": "Settings",
|
"settings": "Settings",
|
||||||
"version_available": "Version {{version}} available. Click here to restart and install."
|
"version_available_install": "Version {{version}} available. Click here to restart and install.",
|
||||||
|
"version_available_download": "Version {{version}} available. Click here to download."
|
||||||
},
|
},
|
||||||
"bottom_panel": {
|
"bottom_panel": {
|
||||||
"no_downloads_in_progress": "No downloads in progress",
|
"no_downloads_in_progress": "No downloads in progress",
|
||||||
|
@ -29,7 +29,8 @@
|
|||||||
"downloads": "Descargas",
|
"downloads": "Descargas",
|
||||||
"search_results": "Resultados de búsqueda",
|
"search_results": "Resultados de búsqueda",
|
||||||
"settings": "Ajustes",
|
"settings": "Ajustes",
|
||||||
"version_available": "Version {{version}} disponible. Haz clic aquí para reiniciar e instalar."
|
"version_available_install": "Version {{version}} disponible. Haz clic aquí para reiniciar e instalar.",
|
||||||
|
"version_available_download": "Version {{version}} disponible. Haz clic aquí para descargar."
|
||||||
},
|
},
|
||||||
"bottom_panel": {
|
"bottom_panel": {
|
||||||
"no_downloads_in_progress": "Sin descargas en progreso",
|
"no_downloads_in_progress": "Sin descargas en progreso",
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
"search_results": "Resultados da busca",
|
"search_results": "Resultados da busca",
|
||||||
"settings": "Ajustes",
|
"settings": "Ajustes",
|
||||||
"home": "Início",
|
"home": "Início",
|
||||||
"version_available": "Versão {{version}} disponível. Clique aqui para reiniciar e instalar."
|
"version_available_install": "Versão {{version}} disponível. Clique aqui para reiniciar e instalar.",
|
||||||
|
"version_available_download": "Versão {{version}} disponível. Clique aqui para fazer o download."
|
||||||
},
|
},
|
||||||
"bottom_panel": {
|
"bottom_panel": {
|
||||||
"no_downloads_in_progress": "Sem downloads em andamento",
|
"no_downloads_in_progress": "Sem downloads em andamento",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AppUpdaterEvents } from "@types";
|
import { AppUpdaterEvent } from "@types";
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import updater, { UpdateInfo } from "electron-updater";
|
import updater, { UpdateInfo } from "electron-updater";
|
||||||
import { WindowManager } from "@main/services";
|
import { WindowManager } from "@main/services";
|
||||||
@ -6,12 +6,15 @@ import { app } from "electron";
|
|||||||
|
|
||||||
const { autoUpdater } = updater;
|
const { autoUpdater } = updater;
|
||||||
|
|
||||||
const sendEvent = (event: AppUpdaterEvents) => {
|
const sendEvent = (event: AppUpdaterEvent) => {
|
||||||
WindowManager.mainWindow?.webContents.send("autoUpdaterEvent", event);
|
WindowManager.mainWindow?.webContents.send("autoUpdaterEvent", event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const sendEventsForDebug = false;
|
||||||
|
|
||||||
const mockValuesForDebug = () => {
|
const mockValuesForDebug = () => {
|
||||||
sendEvent({ type: "update-available", info: { version: "1.3.0" } });
|
sendEvent({ type: "update-available", info: { version: "1.3.0" } });
|
||||||
|
sendEvent({ type: "update-downloaded" });
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||||
@ -25,7 +28,7 @@ const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
|||||||
|
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
autoUpdater.checkForUpdates();
|
autoUpdater.checkForUpdates();
|
||||||
} else {
|
} else if (sendEventsForDebug) {
|
||||||
mockValuesForDebug();
|
mockValuesForDebug();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -44,6 +44,11 @@ const openGameInstaller = async (
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.platform === "darwin") {
|
||||||
|
shell.openPath(gamePath);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (fs.lstatSync(gamePath).isFile()) {
|
if (fs.lstatSync(gamePath).isFile()) {
|
||||||
return executeGameInstaller(gamePath);
|
return executeGameInstaller(gamePath);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import {
|
|||||||
MenuItemConstructorOptions,
|
MenuItemConstructorOptions,
|
||||||
Tray,
|
Tray,
|
||||||
app,
|
app,
|
||||||
|
nativeImage,
|
||||||
shell,
|
shell,
|
||||||
} from "electron";
|
} from "electron";
|
||||||
import { is } from "@electron-toolkit/utils";
|
import { is } from "@electron-toolkit/utils";
|
||||||
@ -88,7 +89,16 @@ export class WindowManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createSystemTray(language: string) {
|
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 updateSystemTray = async () => {
|
||||||
const games = await gameRepository.find({
|
const games = await gameRepository.find({
|
||||||
@ -149,9 +159,14 @@ export class WindowManager {
|
|||||||
return contextMenu;
|
return contextMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showContextMenu = async () => {
|
||||||
|
const contextMenu = await updateSystemTray();
|
||||||
|
tray.popUpContextMenu(contextMenu);
|
||||||
|
};
|
||||||
|
|
||||||
tray.setToolTip("Hydra");
|
tray.setToolTip("Hydra");
|
||||||
|
|
||||||
if (process.platform === "win32" || process.platform === "linux") {
|
if (process.platform !== "darwin") {
|
||||||
tray.addListener("click", () => {
|
tray.addListener("click", () => {
|
||||||
if (this.mainWindow) {
|
if (this.mainWindow) {
|
||||||
if (WindowManager.mainWindow?.isMinimized())
|
if (WindowManager.mainWindow?.isMinimized())
|
||||||
@ -164,10 +179,10 @@ export class WindowManager {
|
|||||||
this.createMainWindow();
|
this.createMainWindow();
|
||||||
});
|
});
|
||||||
|
|
||||||
tray.addListener("right-click", async () => {
|
tray.addListener("right-click", showContextMenu);
|
||||||
const contextMenu = await updateSystemTray();
|
} else {
|
||||||
tray.popUpContextMenu(contextMenu);
|
tray.addListener("click", showContextMenu);
|
||||||
});
|
tray.addListener("right-click", showContextMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { SyncIcon } from "@primer/octicons-react";
|
||||||
|
import { Link } from "../link/link";
|
||||||
|
import * as styles from "./header.css";
|
||||||
|
import { AppUpdaterEvent } from "@types";
|
||||||
|
|
||||||
|
export const releasesPageUrl =
|
||||||
|
"https://github.com/hydralauncher/hydra/releases/latest";
|
||||||
|
|
||||||
|
const isMac = window.electron.platform === "darwin";
|
||||||
|
|
||||||
|
export function AutoUpdateSubHeader() {
|
||||||
|
const [showUpdateSubheader, setShowUpdateSubheader] = useState(false);
|
||||||
|
const [newVersion, setNewVersion] = useState("");
|
||||||
|
|
||||||
|
const { t } = useTranslation("header");
|
||||||
|
|
||||||
|
const handleClickInstallUpdate = () => {
|
||||||
|
window.electron.restartAndInstallUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const unsubscribe = window.electron.onAutoUpdaterEvent(
|
||||||
|
(event: AppUpdaterEvent) => {
|
||||||
|
if (event.type == "update-available") {
|
||||||
|
setNewVersion(event.info.version);
|
||||||
|
|
||||||
|
if (isMac) {
|
||||||
|
setShowUpdateSubheader(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.type == "update-downloaded") {
|
||||||
|
setShowUpdateSubheader(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
window.electron.checkForUpdates();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsubscribe();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!showUpdateSubheader) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<header className={styles.subheader}>
|
||||||
|
{isMac ? (
|
||||||
|
<Link to={releasesPageUrl} className={styles.newVersionLink}>
|
||||||
|
<SyncIcon size={12} />
|
||||||
|
<small>
|
||||||
|
{t("version_available_download", { version: newVersion })}
|
||||||
|
</small>
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={styles.newVersionButton}
|
||||||
|
onClick={handleClickInstallUpdate}
|
||||||
|
>
|
||||||
|
<SyncIcon size={12} />
|
||||||
|
<small>
|
||||||
|
{t("version_available_install", { version: newVersion })}
|
||||||
|
</small>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
}
|
@ -157,9 +157,17 @@ export const newVersionButton = style({
|
|||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
gap: `${SPACING_UNIT}px`,
|
gap: `${SPACING_UNIT}px`,
|
||||||
color: vars.color.body,
|
color: vars.color.body,
|
||||||
borderBottom: "1px solid transparent",
|
fontSize: "13px",
|
||||||
":hover": {
|
":hover": {
|
||||||
borderBottom: `1px solid ${vars.color.body}`,
|
textDecoration: "underline",
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const newVersionLink = style({
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: `${SPACING_UNIT}px`,
|
||||||
|
color: "#8e919b",
|
||||||
|
fontSize: "13px",
|
||||||
|
});
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useLocation, useNavigate } from "react-router-dom";
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
import {
|
import { ArrowLeftIcon, SearchIcon, XIcon } from "@primer/octicons-react";
|
||||||
ArrowLeftIcon,
|
|
||||||
SearchIcon,
|
|
||||||
SyncIcon,
|
|
||||||
XIcon,
|
|
||||||
} from "@primer/octicons-react";
|
|
||||||
|
|
||||||
import { useAppDispatch, useAppSelector } from "@renderer/hooks";
|
import { useAppDispatch, useAppSelector } from "@renderer/hooks";
|
||||||
|
|
||||||
import * as styles from "./header.css";
|
import * as styles from "./header.css";
|
||||||
import { clearSearch } from "@renderer/features";
|
import { clearSearch } from "@renderer/features";
|
||||||
import { AppUpdaterEvents } from "@types";
|
import { AutoUpdateSubHeader } from "./auto-update-sub-header";
|
||||||
|
|
||||||
export interface HeaderProps {
|
export interface HeaderProps {
|
||||||
onSearch: (query: string) => void;
|
onSearch: (query: string) => void;
|
||||||
@ -40,9 +35,6 @@ export function Header({ onSearch, onClear, search }: HeaderProps) {
|
|||||||
|
|
||||||
const [isFocused, setIsFocused] = useState(false);
|
const [isFocused, setIsFocused] = useState(false);
|
||||||
|
|
||||||
const [showUpdateSubheader, setShowUpdateSubheader] = useState(false);
|
|
||||||
const [newVersion, setNewVersion] = useState("");
|
|
||||||
|
|
||||||
const { t } = useTranslation("header");
|
const { t } = useTranslation("header");
|
||||||
|
|
||||||
const title = useMemo(() => {
|
const title = useMemo(() => {
|
||||||
@ -58,30 +50,6 @@ export function Header({ onSearch, onClear, search }: HeaderProps) {
|
|||||||
}
|
}
|
||||||
}, [location.pathname, search, dispatch]);
|
}, [location.pathname, search, dispatch]);
|
||||||
|
|
||||||
const handleClickRestartAndUpdate = () => {
|
|
||||||
window.electron.restartAndInstallUpdate();
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const unsubscribe = window.electron.onAutoUpdaterEvent(
|
|
||||||
(event: AppUpdaterEvents) => {
|
|
||||||
if (event.type == "update-available") {
|
|
||||||
setNewVersion(event.info.version || "");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.type == "update-downloaded") {
|
|
||||||
setShowUpdateSubheader(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
window.electron.checkForUpdates();
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
unsubscribe();
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const focusInput = () => {
|
const focusInput = () => {
|
||||||
setIsFocused(true);
|
setIsFocused(true);
|
||||||
inputRef.current?.focus();
|
inputRef.current?.focus();
|
||||||
@ -158,18 +126,7 @@ export function Header({ onSearch, onClear, search }: HeaderProps) {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</header>
|
</header>
|
||||||
{showUpdateSubheader && (
|
<AutoUpdateSubHeader />
|
||||||
<header className={styles.subheader}>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className={styles.newVersionButton}
|
|
||||||
onClick={handleClickRestartAndUpdate}
|
|
||||||
>
|
|
||||||
<SyncIcon size={12} />
|
|
||||||
<small>{t("version_available", { version: newVersion })}</small>
|
|
||||||
</button>
|
|
||||||
</header>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
4
src/renderer/src/declaration.d.ts
vendored
4
src/renderer/src/declaration.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
import type {
|
import type {
|
||||||
AppUpdaterEvents,
|
AppUpdaterEvent,
|
||||||
CatalogueEntry,
|
CatalogueEntry,
|
||||||
Game,
|
Game,
|
||||||
LibraryGame,
|
LibraryGame,
|
||||||
@ -102,7 +102,7 @@ declare global {
|
|||||||
|
|
||||||
/* Auto update */
|
/* Auto update */
|
||||||
onAutoUpdaterEvent: (
|
onAutoUpdaterEvent: (
|
||||||
cb: (event: AppUpdaterEvents) => void
|
cb: (event: AppUpdaterEvent) => void
|
||||||
) => () => Electron.IpcRenderer;
|
) => () => Electron.IpcRenderer;
|
||||||
checkForUpdates: () => Promise<void>;
|
checkForUpdates: () => Promise<void>;
|
||||||
restartAndInstallUpdate: () => Promise<void>;
|
restartAndInstallUpdate: () => Promise<void>;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { Aria2Status } from "aria2";
|
import type { Aria2Status } from "aria2";
|
||||||
import type { DownloadSourceStatus, Downloader } from "@shared";
|
import type { DownloadSourceStatus, Downloader } from "@shared";
|
||||||
import { ProgressInfo, UpdateInfo } from "electron-updater";
|
import { UpdateInfo } from "electron-updater";
|
||||||
|
|
||||||
export type GameShop = "steam" | "epic";
|
export type GameShop = "steam" | "epic";
|
||||||
|
|
||||||
@ -154,13 +154,8 @@ export interface SteamGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type AppUpdaterEvent =
|
export type AppUpdaterEvent =
|
||||||
| { type: "error" }
|
| { type: "update-available"; info: { version: string } }
|
||||||
| { type: "checking-for-updates" }
|
| { type: "update-downloaded" };
|
||||||
| { type: "update-not-available" }
|
|
||||||
| { type: "update-available"; info: UpdateInfo }
|
|
||||||
| { type: "update-downloaded" }
|
|
||||||
| { type: "download-progress"; info: ProgressInfo }
|
|
||||||
| { type: "update-cancelled" };
|
|
||||||
|
|
||||||
/* Events */
|
/* Events */
|
||||||
export interface StartGameDownloadPayload {
|
export interface StartGameDownloadPayload {
|
||||||
@ -238,9 +233,6 @@ export interface RealDebridUser {
|
|||||||
premium: number;
|
premium: number;
|
||||||
expiration: string;
|
expiration: string;
|
||||||
}
|
}
|
||||||
export type AppUpdaterEvents =
|
|
||||||
| { type: "update-available"; info: Partial<UpdateInfo> }
|
|
||||||
| { type: "update-downloaded" };
|
|
||||||
|
|
||||||
export interface DownloadSource {
|
export interface DownloadSource {
|
||||||
id: number;
|
id: number;
|
||||||
|
Loading…
Reference in New Issue
Block a user