feat: create game shortcut

This commit is contained in:
Zamitto 2024-06-05 16:42:45 -03:00
parent 6dfd7279dc
commit 086ee8ac04
7 changed files with 52 additions and 1 deletions

View file

@ -10,6 +10,7 @@ import "./catalogue/search-games";
import "./catalogue/search-game-repacks";
import "./hardware/get-disk-free-space";
import "./library/add-game-to-library";
import "./library/create-game-shortcut";
import "./library/close-game";
import "./library/delete-game-folder";
import "./library/get-game-by-object-id";

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