mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
feat: make it possible to select shortcuts (.lnk)
This commit is contained in:
parent
82f72071f9
commit
7be626b3dd
10
src/main/events/helpers/parse-executable-path.ts
Normal file
10
src/main/events/helpers/parse-executable-path.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { shell } from "electron";
|
||||
|
||||
export const parseExecutablePath = (path: string) => {
|
||||
if (process.platform === "win32" && path.endsWith(".lnk")) {
|
||||
const { target } = shell.readShortcutLink(path);
|
||||
|
||||
return target;
|
||||
}
|
||||
return path;
|
||||
};
|
@ -2,15 +2,18 @@ import { gameRepository } from "@main/repository";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { shell } from "electron";
|
||||
import { parseExecutablePath } from "../helpers/parse-executable-path";
|
||||
|
||||
const openGame = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number,
|
||||
executablePath: string
|
||||
) => {
|
||||
await gameRepository.update({ id: gameId }, { executablePath });
|
||||
const parsedPath = parseExecutablePath(executablePath);
|
||||
|
||||
shell.openPath(executablePath);
|
||||
await gameRepository.update({ id: gameId }, { executablePath: parsedPath });
|
||||
|
||||
shell.openPath(parsedPath);
|
||||
};
|
||||
|
||||
registerEvent("openGame", openGame);
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { parseExecutablePath } from "../helpers/parse-executable-path";
|
||||
|
||||
const updateExecutablePath = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
@ -12,7 +13,7 @@ const updateExecutablePath = async (
|
||||
id,
|
||||
},
|
||||
{
|
||||
executablePath,
|
||||
executablePath: parseExecutablePath(executablePath),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -11,7 +11,15 @@ export const getProcesses = async () => {
|
||||
if (process.platform == "win32") {
|
||||
const binaryPath = app.isPackaged
|
||||
? path.join(process.resourcesPath, "fastlist.exe")
|
||||
: path.join(__dirname, "..", "..", "fastlist.exe");
|
||||
: path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"..",
|
||||
"node_modules",
|
||||
"ps-list",
|
||||
"vendor",
|
||||
"fastlist-0.3.0-x64.exe"
|
||||
);
|
||||
|
||||
const { stdout } = await execFile(binaryPath, {
|
||||
maxBuffer: TEN_MEGABYTES,
|
||||
|
@ -140,7 +140,7 @@ export function GameDetailsContextProvider({
|
||||
filters: [
|
||||
{
|
||||
name: "Game executable",
|
||||
extensions: ["exe"],
|
||||
extensions: ["exe", "lnk"],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user