Add bepInEx uninstallation

This commit is contained in:
2026-01-22 13:52:13 +01:00
parent da22a80c4a
commit 118a2fd84e
4 changed files with 45 additions and 4 deletions

27
main.js
View File

@@ -9,6 +9,7 @@ const extract = require("extract-zip");
const store = new Store(); const store = new Store();
const userSavePath = app.getPath('userData') const userSavePath = app.getPath('userData')
let silksongPath = store.get('silksong-path') let silksongPath = store.get('silksong-path')
let bepinexVersion
const createWindow = () => { const createWindow = () => {
const win = new BrowserWindow({ const win = new BrowserWindow({
@@ -121,6 +122,7 @@ ipcMain.handle('install-bepinex', async () => {
} }
const release = await res.json(); const release = await res.json();
bepinexVersion = release.tag_name;
const asset = release.assets.find( const asset = release.assets.find(
a => a.name.endsWith(".zip") && a.name.toLowerCase().includes("win_x64") a => a.name.endsWith(".zip") && a.name.toLowerCase().includes("win_x64")
@@ -140,4 +142,29 @@ ipcMain.handle('install-bepinex', async () => {
await extract(filePath, { dir: silksongPath}) await extract(filePath, { dir: silksongPath})
await fs.unlink(filePath) await fs.unlink(filePath)
return bepinexVersion
})
ipcMain.handle('uninstall-bepinex', async () => {
const folderPath = `${silksongPath}\\BepInEx`
if (await fileExists(folderPath)) {
await fs.rm(folderPath, { recursive: true })
}
const bepinexFiles = [
".doorstop_version",
"changelog.txt",
"doorstop_config.ini",
"winhttp.dll"
]
for (const file of bepinexFiles) {
const filePath = `${silksongPath}\\${file}`
if (await fileExists(filePath)) {
await fs.unlink(filePath)
}
}
bepinexVersion = undefined
return bepinexVersion
}) })

View File

@@ -24,5 +24,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
}); });
contextBridge.exposeInMainWorld('bepinex', { contextBridge.exposeInMainWorld('bepinex', {
install: () => ipcRenderer.invoke('install-bepinex') install: () => ipcRenderer.invoke('install-bepinex'),
uninstall: () => ipcRenderer.invoke('uninstall-bepinex')
}) })

View File

@@ -104,7 +104,7 @@
</div> </div>
<br> <br>
<h2>BepInEx</h2> <h2>BepInEx</h2>
<p class="transparent-text">BepInEx V1.0.0 is installed</p> <p class="transparent-text" id="bepinex-version-text"></p>
<div class="horizontal-div"> <div class="horizontal-div">
<button class="default-button" onclick="installBepinex()">Install</button> <button class="default-button" onclick="installBepinex()">Install</button>
<button class="important-button" onclick="uninstallBepinex()">Uninstall</button> <button class="important-button" onclick="uninstallBepinex()">Uninstall</button>

View File

@@ -8,6 +8,7 @@ const settingsTemplate = document.getElementById("settings-template");
const modTemplate = document.getElementById("mod-template"); const modTemplate = document.getElementById("mod-template");
const versionText = HomeTemplate.content.getElementById("version-text"); const versionText = HomeTemplate.content.getElementById("version-text");
let bepinexVersion
navigate("home") navigate("home")
@@ -118,9 +119,21 @@ async function downloadMod() {
} }
async function installBepinex() { async function installBepinex() {
bepinex.install() bepinexVersion = await bepinex.install()
setBepinexVersion()
} }
async function uninstallBepinex() { async function uninstallBepinex() {
console.log("WIP") bepinexVersion = await bepinex.uninstall()
setBepinexVersion()
}
async function setBepinexVersion() {
const bepinexVersionText = document.getElementById("bepinex-version-text")
if(await bepinexVersion == undefined) {
bepinexVersionText.innerText = "BepInEx is not installed"
}
else {
bepinexVersionText.innerText = `BepInEx ${bepinexVersion} is installed`
}
} }