mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: create game shortcut
This commit is contained in:
parent
6dfd7279dc
commit
086ee8ac04
7 changed files with 52 additions and 1 deletions
26
src/main/events/library/create-game-shortcut.ts
Normal file
26
src/main/events/library/create-game-shortcut.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { gameRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { IsNull, Not } from "typeorm";
|
||||
import createDesktopShortcut from "create-desktop-shortcuts";
|
||||
|
||||
const createGameShortcut = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
id: number
|
||||
): Promise<boolean> => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: { id, executablePath: Not(IsNull()) },
|
||||
});
|
||||
|
||||
if (game) {
|
||||
const filePath = game.executablePath;
|
||||
return createDesktopShortcut({
|
||||
windows: { filePath },
|
||||
linux: { filePath },
|
||||
osx: { filePath },
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
registerEvent("createGameShortcut", createGameShortcut);
|
Loading…
Add table
Add a link
Reference in a new issue