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

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