Add the ability to update BepInEx

This commit is contained in:
2026-04-17 22:30:07 +02:00
parent 7fe89ff2ab
commit dbad325ca9
3 changed files with 17 additions and 4 deletions

16
main.js
View File

@@ -208,9 +208,13 @@ function saveBepinexVersion(version) {
}
ipcMain.handle("load-bepinex-version", () => {
return loadBepinexVersion();
});
function loadBepinexVersion() {
bepinexVersion = bepinexStore.get("bepinex-version");
return bepinexVersion;
});
}
function saveBepinexBackupVersion(version) {
bepinexBackupVersion = version;
@@ -377,8 +381,6 @@ async function installBepinex() {
saveBepinexVersion(bepinexBackupVersion);
saveBepinexBackupVersion(undefined);
} else {
mainWindow.webContents.send("showToast", "Installing Bepinex from Github");
const GITHUB_URL = "https://api.github.com/repos/bepinex/bepinex/releases/latest";
const res = await fetch(GITHUB_URL, {
@@ -397,6 +399,14 @@ async function installBepinex() {
const release = await res.json();
if (loadBepinexVersion() == release.tag_name) {
mainWindow.webContents.send("showToast", "No new BepInEx update.");
return;
}
mainWindow.webContents.send("showToast", "Installing Bepinex from Github");
await uninstallBepinex();
let asset;
if (process.platform === "win32") {
asset = release.assets.find((a) => a.name.endsWith(".zip") && a.name.toLowerCase().includes("win_x64"));