Merge pull request #709 from hydralauncher/hyd-192-select-lnk-as-parse-target-executable

feat: make it possible to select shortcuts (.lnk) on game executable
This commit is contained in:
Zamitto 2024-06-28 11:16:47 -03:00 committed by GitHub
commit e0dca85825
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 35 additions and 8 deletions

View 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;
};

View File

@ -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);

View File

@ -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),
}
);
};

View File

@ -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,

View File

@ -106,10 +106,17 @@ export class HydraApi {
};
}
private static sendSignOutEvent() {
if (WindowManager.mainWindow) {
WindowManager.mainWindow.webContents.send("on-signout");
}
}
private static async revalidateAccessTokenIfExpired() {
if (!this.userAuth.authToken) {
userAuthRepository.delete({ id: 1 });
logger.error("user is not logged in");
this.sendSignOutEvent();
throw new Error("user is not logged in");
}
@ -151,9 +158,7 @@ export class HydraApi {
userAuthRepository.delete({ id: 1 });
if (WindowManager.mainWindow) {
WindowManager.mainWindow.webContents.send("on-signout");
}
this.sendSignOutEvent();
logger.log("user refresh token expired");
}

View File

@ -140,7 +140,7 @@ export function GameDetailsContextProvider({
filters: [
{
name: "Game executable",
extensions: ["exe"],
extensions: ["exe", "lnk"],
},
],
})