mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
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:
commit
e0dca85825
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 { registerEvent } from "../register-event";
|
||||||
import { shell } from "electron";
|
import { shell } from "electron";
|
||||||
|
import { parseExecutablePath } from "../helpers/parse-executable-path";
|
||||||
|
|
||||||
const openGame = async (
|
const openGame = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
gameId: number,
|
gameId: number,
|
||||||
executablePath: string
|
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);
|
registerEvent("openGame", openGame);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { gameRepository } from "@main/repository";
|
import { gameRepository } from "@main/repository";
|
||||||
|
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
|
import { parseExecutablePath } from "../helpers/parse-executable-path";
|
||||||
|
|
||||||
const updateExecutablePath = async (
|
const updateExecutablePath = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
@ -12,7 +13,7 @@ const updateExecutablePath = async (
|
|||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
executablePath,
|
executablePath: parseExecutablePath(executablePath),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,15 @@ export const getProcesses = async () => {
|
|||||||
if (process.platform == "win32") {
|
if (process.platform == "win32") {
|
||||||
const binaryPath = app.isPackaged
|
const binaryPath = app.isPackaged
|
||||||
? path.join(process.resourcesPath, "fastlist.exe")
|
? 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, {
|
const { stdout } = await execFile(binaryPath, {
|
||||||
maxBuffer: TEN_MEGABYTES,
|
maxBuffer: TEN_MEGABYTES,
|
||||||
|
@ -106,10 +106,17 @@ export class HydraApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static sendSignOutEvent() {
|
||||||
|
if (WindowManager.mainWindow) {
|
||||||
|
WindowManager.mainWindow.webContents.send("on-signout");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static async revalidateAccessTokenIfExpired() {
|
private static async revalidateAccessTokenIfExpired() {
|
||||||
if (!this.userAuth.authToken) {
|
if (!this.userAuth.authToken) {
|
||||||
userAuthRepository.delete({ id: 1 });
|
userAuthRepository.delete({ id: 1 });
|
||||||
logger.error("user is not logged in");
|
logger.error("user is not logged in");
|
||||||
|
this.sendSignOutEvent();
|
||||||
throw new Error("user is not logged in");
|
throw new Error("user is not logged in");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,9 +158,7 @@ export class HydraApi {
|
|||||||
|
|
||||||
userAuthRepository.delete({ id: 1 });
|
userAuthRepository.delete({ id: 1 });
|
||||||
|
|
||||||
if (WindowManager.mainWindow) {
|
this.sendSignOutEvent();
|
||||||
WindowManager.mainWindow.webContents.send("on-signout");
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.log("user refresh token expired");
|
logger.log("user refresh token expired");
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ export function GameDetailsContextProvider({
|
|||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
name: "Game executable",
|
name: "Game executable",
|
||||||
extensions: ["exe"],
|
extensions: ["exe", "lnk"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user