mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-21 10:03:56 +00:00
feat: adding deep linking to import sources
This commit is contained in:
@@ -5,7 +5,6 @@ export const downloadSourceSchema = z.object({
|
||||
downloads: z.array(
|
||||
z.object({
|
||||
title: z.string().max(255),
|
||||
downloaders: z.array(z.enum(["real_debrid", "torrent"])),
|
||||
uris: z.array(z.string()),
|
||||
uploadDate: z.string().max(255),
|
||||
fileSize: z.string().max(255),
|
||||
|
||||
@@ -73,7 +73,16 @@ app.on("browser-window-created", (_, window) => {
|
||||
optimizer.watchWindowShortcuts(window);
|
||||
});
|
||||
|
||||
app.on("second-instance", (_event) => {
|
||||
const handleDeepLinkPath = (uri?: string) => {
|
||||
if (!uri) return;
|
||||
const url = new URL(uri);
|
||||
|
||||
if (url.host === "install-source") {
|
||||
WindowManager.redirect(`settings${url.search}`);
|
||||
}
|
||||
};
|
||||
|
||||
app.on("second-instance", (_event, commandLine) => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (WindowManager.mainWindow) {
|
||||
if (WindowManager.mainWindow.isMinimized())
|
||||
@@ -84,16 +93,12 @@ app.on("second-instance", (_event) => {
|
||||
WindowManager.createMainWindow();
|
||||
}
|
||||
|
||||
// const [, path] = commandLine.pop()?.split("://") ?? [];
|
||||
// if (path) {
|
||||
// WindowManager.redirect(path);
|
||||
// }
|
||||
handleDeepLinkPath(commandLine.pop());
|
||||
});
|
||||
|
||||
// app.on("open-url", (_event, url) => {
|
||||
// const [, path] = url.split("://");
|
||||
// WindowManager.redirect(path);
|
||||
// });
|
||||
app.on("open-url", (_event, url) => {
|
||||
handleDeepLinkPath(url);
|
||||
});
|
||||
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
// for applications and their menu bar to stay active until the user quits
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
shell,
|
||||
} from "electron";
|
||||
import { is } from "@electron-toolkit/utils";
|
||||
import { t } from "i18next";
|
||||
import i18next, { t } from "i18next";
|
||||
import path from "node:path";
|
||||
import icon from "@resources/icon.png?asset";
|
||||
import trayIcon from "@resources/tray-icon.png?asset";
|
||||
@@ -100,7 +100,13 @@ export class WindowManager {
|
||||
|
||||
authWindow.removeMenu();
|
||||
|
||||
authWindow.loadURL("https://auth.hydra.losbroxas.org/");
|
||||
const searchParams = new URLSearchParams({
|
||||
lng: i18next.language,
|
||||
});
|
||||
|
||||
authWindow.loadURL(
|
||||
`https://auth.hydra.losbroxas.org/?${searchParams.toString()}`
|
||||
);
|
||||
|
||||
authWindow.once("ready-to-show", () => {
|
||||
authWindow.show();
|
||||
|
||||
Reference in New Issue
Block a user