feat: adding commonredist

This commit is contained in:
Chubby Granny Chaser
2025-04-02 15:35:40 +01:00
parent 56da86d63d
commit 01d440590b
15 changed files with 70 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ import "./misc/show-open-dialog";
import "./misc/get-features";
import "./misc/show-item-in-folder";
import "./misc/get-badges";
import "./misc/install-commonredist";
import "./torrenting/cancel-game-download";
import "./torrenting/pause-game-download";
import "./torrenting/resume-game-download";

View File

@@ -0,0 +1,26 @@
import { app } from "electron";
import path from "node:path";
import cp from "node:child_process";
import { registerEvent } from "../register-event";
import { logger } from "@main/services";
const installScriptPath = app.isPackaged
? path.join(process.resourcesPath, "commonredist", "install.bat")
: path.join(
__dirname,
"..",
"..",
"resources",
"commonredist",
"install.bat"
);
const installCommonRedist = async (_event: Electron.IpcMainInvokeEvent) => {
cp.execFile(installScriptPath, (error) => {
if (error) {
logger.error(error);
}
});
};
registerEvent("installCommonRedist", installCommonRedist);

View File

@@ -295,6 +295,7 @@ contextBridge.exposeInMainWorld("electron", {
ipcRenderer.invoke("showItemInFolder", path),
getFeatures: () => ipcRenderer.invoke("getFeatures"),
getBadges: () => ipcRenderer.invoke("getBadges"),
installCommonRedist: () => ipcRenderer.invoke("installCommonRedist"),
platform: process.platform,
/* Auto update */

View File

@@ -234,6 +234,7 @@ declare global {
showItemInFolder: (path: string) => Promise<void>;
getFeatures: () => Promise<string[]>;
getBadges: () => Promise<Badge[]>;
installCommonRedist: () => Promise<void>;
platform: NodeJS.Platform;
/* Auto update */

View File

@@ -185,6 +185,10 @@ export function SettingsGeneral() {
})
}
/>
<Button onClick={() => window.electron.installCommonRedist()}>
{t("install_common_redist")}
</Button>
</div>
);
}