mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 13:34:54 +03:00
Merge branch 'main' into main
This commit is contained in:
commit
0b896b8b7c
@ -253,7 +253,8 @@
|
||||
"must_be_valid_url": "The source must be a valid URL",
|
||||
"blocked_users": "Blocked users",
|
||||
"user_unblocked": "User has been unblocked",
|
||||
"enable_achievement_notifications": "When an achievement in unlocked"
|
||||
"enable_achievement_notifications": "When an achievement in unlocked",
|
||||
"launch_minimized": "Launch Hydra minimized"
|
||||
},
|
||||
"notifications": {
|
||||
"download_complete": "Download complete",
|
||||
|
@ -249,7 +249,8 @@
|
||||
"must_be_valid_url": "A fonte deve ser uma URL válida",
|
||||
"blocked_users": "Usuários bloqueados",
|
||||
"user_unblocked": "Usuário desbloqueado",
|
||||
"enable_achievement_notifications": "Quando uma conquista é desbloqueada"
|
||||
"enable_achievement_notifications": "Quando uma conquista é desbloqueada",
|
||||
"launch_minimized": "Iniciar o Hydra minimizado"
|
||||
},
|
||||
"notifications": {
|
||||
"download_complete": "Download concluído",
|
||||
|
@ -35,6 +35,9 @@ export class UserPreferences {
|
||||
@Column("boolean", { default: false })
|
||||
runAtStartup: boolean;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
startMinimized: boolean;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
|
@ -16,15 +16,16 @@ const windowsStartupPath = path.join(
|
||||
|
||||
const autoLaunch = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
enabled: boolean
|
||||
autoLaunchProps: { enabled: boolean; minimized: boolean }
|
||||
) => {
|
||||
if (!app.isPackaged) return;
|
||||
|
||||
const appLauncher = new AutoLaunch({
|
||||
name: app.getName(),
|
||||
isHidden: autoLaunchProps.minimized,
|
||||
});
|
||||
|
||||
if (enabled) {
|
||||
if (autoLaunchProps.enabled) {
|
||||
appLauncher.enable().catch((err) => {
|
||||
logger.error(err);
|
||||
});
|
||||
|
@ -101,7 +101,10 @@ app.whenReady().then(async () => {
|
||||
i18n.changeLanguage(userPreferences.language);
|
||||
}
|
||||
|
||||
WindowManager.createMainWindow();
|
||||
if (!process.argv.includes("--hidden")) {
|
||||
WindowManager.createMainWindow();
|
||||
}
|
||||
|
||||
WindowManager.createNotificationWindow();
|
||||
WindowManager.createSystemTray(userPreferences?.language || "en");
|
||||
});
|
||||
|
@ -11,7 +11,7 @@ import { AddAchievementNotificationPreference } from "./migrations/2024101301290
|
||||
import { CreateUserSubscription } from "./migrations/20241015235142_create_user_subscription";
|
||||
import { AddBackgroundImageUrl } from "./migrations/20241016100249_add_background_image_url";
|
||||
import { AddWinePrefixToGame } from "./migrations/20241019081648_add_wine_prefix_to_game";
|
||||
|
||||
import { AddStartMinimizedColumn } from "./migrations/20241030171454_add_start_minimized_column";
|
||||
export type HydraMigration = Knex.Migration & { name: string };
|
||||
|
||||
class MigrationSource implements Knex.MigrationSource<HydraMigration> {
|
||||
@ -27,6 +27,7 @@ class MigrationSource implements Knex.MigrationSource<HydraMigration> {
|
||||
CreateUserSubscription,
|
||||
AddBackgroundImageUrl,
|
||||
AddWinePrefixToGame,
|
||||
AddStartMinimizedColumn,
|
||||
]);
|
||||
}
|
||||
getMigrationName(migration: HydraMigration): string {
|
||||
|
@ -0,0 +1,17 @@
|
||||
import type { HydraMigration } from "@main/knex-client";
|
||||
import type { Knex } from "knex";
|
||||
|
||||
export const AddStartMinimizedColumn: HydraMigration = {
|
||||
name: "AddStartMinimizedColumn",
|
||||
up: (knex: Knex) => {
|
||||
return knex.schema.alterTable("user_preferences", (table) => {
|
||||
return table.boolean("startMinimized").notNullable().defaultTo(0);
|
||||
});
|
||||
},
|
||||
|
||||
down: async (knex: Knex) => {
|
||||
return knex.schema.alterTable("user_preferences", (table) => {
|
||||
return table.dropColumn("startMinimized");
|
||||
});
|
||||
},
|
||||
};
|
@ -310,14 +310,15 @@ export class WindowManager {
|
||||
if (process.platform !== "darwin") {
|
||||
tray.addListener("click", () => {
|
||||
if (this.mainWindow) {
|
||||
if (WindowManager.mainWindow?.isMinimized())
|
||||
WindowManager.mainWindow.restore();
|
||||
|
||||
WindowManager.mainWindow?.focus();
|
||||
return;
|
||||
if (
|
||||
WindowManager.mainWindow?.isMinimized() ||
|
||||
!WindowManager.mainWindow?.isVisible()
|
||||
) {
|
||||
WindowManager.mainWindow?.show();
|
||||
}
|
||||
} else {
|
||||
this.createMainWindow();
|
||||
}
|
||||
|
||||
this.createMainWindow();
|
||||
});
|
||||
|
||||
tray.addListener("right-click", showContextMenu);
|
||||
|
@ -101,7 +101,8 @@ contextBridge.exposeInMainWorld("electron", {
|
||||
getUserPreferences: () => ipcRenderer.invoke("getUserPreferences"),
|
||||
updateUserPreferences: (preferences: UserPreferences) =>
|
||||
ipcRenderer.invoke("updateUserPreferences", preferences),
|
||||
autoLaunch: (enabled: boolean) => ipcRenderer.invoke("autoLaunch", enabled),
|
||||
autoLaunch: (autoLaunchProps: { enabled: boolean; minimized: boolean }) =>
|
||||
ipcRenderer.invoke("autoLaunch", autoLaunchProps),
|
||||
authenticateRealDebrid: (apiToken: string) =>
|
||||
ipcRenderer.invoke("authenticateRealDebrid", apiToken),
|
||||
|
||||
|
5
src/renderer/src/declaration.d.ts
vendored
5
src/renderer/src/declaration.d.ts
vendored
@ -114,7 +114,10 @@ declare global {
|
||||
updateUserPreferences: (
|
||||
preferences: Partial<UserPreferences>
|
||||
) => Promise<void>;
|
||||
autoLaunch: (enabled: boolean) => Promise<void>;
|
||||
autoLaunch: (autoLaunchProps: {
|
||||
enabled: boolean;
|
||||
minimized: boolean;
|
||||
}) => Promise<void>;
|
||||
authenticateRealDebrid: (apiToken: string) => Promise<RealDebridUser>;
|
||||
|
||||
/* Download sources */
|
||||
|
@ -17,6 +17,7 @@ export function SettingsBehavior() {
|
||||
const [form, setForm] = useState({
|
||||
preferQuitInsteadOfHiding: false,
|
||||
runAtStartup: false,
|
||||
startMinimized: false,
|
||||
});
|
||||
|
||||
const { t } = useTranslation("settings");
|
||||
@ -26,6 +27,7 @@ export function SettingsBehavior() {
|
||||
setForm({
|
||||
preferQuitInsteadOfHiding: userPreferences.preferQuitInsteadOfHiding,
|
||||
runAtStartup: userPreferences.runAtStartup,
|
||||
startMinimized: userPreferences.startMinimized,
|
||||
});
|
||||
}
|
||||
}, [userPreferences]);
|
||||
@ -58,11 +60,32 @@ export function SettingsBehavior() {
|
||||
label={t("launch_with_system")}
|
||||
onChange={() => {
|
||||
handleChange({ runAtStartup: !form.runAtStartup });
|
||||
window.electron.autoLaunch(!form.runAtStartup);
|
||||
window.electron.autoLaunch({
|
||||
enabled: !form.runAtStartup,
|
||||
minimized: form.startMinimized,
|
||||
});
|
||||
}}
|
||||
checked={form.runAtStartup}
|
||||
/>
|
||||
)}
|
||||
|
||||
{showRunAtStartup && (
|
||||
<div style={{ opacity: form.runAtStartup ? 1 : 0.5 }}>
|
||||
<CheckboxField
|
||||
label={t("launch_minimized")}
|
||||
style={{ cursor: form.runAtStartup ? "pointer" : "not-allowed" }}
|
||||
checked={form.runAtStartup && form.startMinimized}
|
||||
disabled={!form.runAtStartup}
|
||||
onChange={() => {
|
||||
handleChange({ startMinimized: !form.startMinimized });
|
||||
window.electron.autoLaunch({
|
||||
minimized: !form.startMinimized,
|
||||
enabled: form.runAtStartup,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -160,6 +160,7 @@ export interface UserPreferences {
|
||||
realDebridApiToken: string | null;
|
||||
preferQuitInsteadOfHiding: boolean;
|
||||
runAtStartup: boolean;
|
||||
startMinimized: boolean;
|
||||
}
|
||||
|
||||
export interface Steam250Game {
|
||||
|
Loading…
Reference in New Issue
Block a user