mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-24 19:31:03 +00:00
feat: create start menu shortcut on Windows
This commit is contained in:
7
src/renderer/src/declaration.d.ts
vendored
7
src/renderer/src/declaration.d.ts
vendored
@@ -32,6 +32,7 @@ import type {
|
||||
Theme,
|
||||
Badge,
|
||||
Auth,
|
||||
ShortcutLocation,
|
||||
} from "@types";
|
||||
import type { AxiosProgressEvent } from "axios";
|
||||
import type disk from "diskusage";
|
||||
@@ -101,7 +102,11 @@ declare global {
|
||||
objectId: string,
|
||||
title: string
|
||||
) => Promise<void>;
|
||||
createGameShortcut: (shop: GameShop, objectId: string) => Promise<boolean>;
|
||||
createGameShortcut: (
|
||||
shop: GameShop,
|
||||
objectId: string,
|
||||
location: ShortcutLocation
|
||||
) => Promise<boolean>;
|
||||
updateExecutablePath: (
|
||||
shop: GameShop,
|
||||
objectId: string,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useContext, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button, CheckboxField, Modal, TextField } from "@renderer/components";
|
||||
import type { LibraryGame } from "@types";
|
||||
import type { LibraryGame, ShortcutLocation } from "@types";
|
||||
import { gameDetailsContext } from "@renderer/context";
|
||||
import { DeleteGameModal } from "@renderer/pages/downloads/delete-game-modal";
|
||||
import { useDownload, useToast, useUserDetails } from "@renderer/hooks";
|
||||
@@ -107,15 +107,18 @@ export function GameOptionsModal({
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreateShortcut = async () => {
|
||||
const handleCreateShortcut = async (location: ShortcutLocation) => {
|
||||
window.electron
|
||||
.createGameShortcut(game.shop, game.objectId)
|
||||
.createGameShortcut(game.shop, game.objectId, location)
|
||||
.then((success) => {
|
||||
if (success) {
|
||||
showSuccessToast(t("create_shortcut_success"));
|
||||
} else {
|
||||
showErrorToast(t("create_shortcut_error"));
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
showErrorToast(t("create_shortcut_error"));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -176,6 +179,9 @@ export function GameOptionsModal({
|
||||
const shouldShowWinePrefixConfiguration =
|
||||
window.electron.platform === "linux";
|
||||
|
||||
const shouldShowCreateStartMenuShortcut =
|
||||
window.electron.platform === "win32";
|
||||
|
||||
const handleResetAchievements = async () => {
|
||||
setIsDeletingAchievements(true);
|
||||
try {
|
||||
@@ -278,9 +284,20 @@ export function GameOptionsModal({
|
||||
>
|
||||
{t("open_folder")}
|
||||
</Button>
|
||||
<Button onClick={handleCreateShortcut} theme="outline">
|
||||
<Button
|
||||
onClick={() => handleCreateShortcut("desktop")}
|
||||
theme="outline"
|
||||
>
|
||||
{t("create_shortcut")}
|
||||
</Button>
|
||||
{shouldShowCreateStartMenuShortcut && (
|
||||
<Button
|
||||
onClick={() => handleCreateShortcut("start_menu")}
|
||||
theme="outline"
|
||||
>
|
||||
{t("create_start_menu_shortcut")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user