mirror of
https://github.com/Gabi-Zar/Silk-Fly-Launcher.git
synced 2026-04-17 05:26:04 +02:00
Add bepInEx uninstallation
This commit is contained in:
27
main.js
27
main.js
@@ -9,6 +9,7 @@ const extract = require("extract-zip");
|
||||
const store = new Store();
|
||||
const userSavePath = app.getPath('userData')
|
||||
let silksongPath = store.get('silksong-path')
|
||||
let bepinexVersion
|
||||
|
||||
const createWindow = () => {
|
||||
const win = new BrowserWindow({
|
||||
@@ -121,6 +122,7 @@ ipcMain.handle('install-bepinex', async () => {
|
||||
}
|
||||
|
||||
const release = await res.json();
|
||||
bepinexVersion = release.tag_name;
|
||||
|
||||
const asset = release.assets.find(
|
||||
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 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
|
||||
})
|
||||
@@ -24,5 +24,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
});
|
||||
|
||||
contextBridge.exposeInMainWorld('bepinex', {
|
||||
install: () => ipcRenderer.invoke('install-bepinex')
|
||||
install: () => ipcRenderer.invoke('install-bepinex'),
|
||||
uninstall: () => ipcRenderer.invoke('uninstall-bepinex')
|
||||
})
|
||||
@@ -104,7 +104,7 @@
|
||||
</div>
|
||||
<br>
|
||||
<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">
|
||||
<button class="default-button" onclick="installBepinex()">Install</button>
|
||||
<button class="important-button" onclick="uninstallBepinex()">Uninstall</button>
|
||||
|
||||
@@ -8,6 +8,7 @@ const settingsTemplate = document.getElementById("settings-template");
|
||||
const modTemplate = document.getElementById("mod-template");
|
||||
|
||||
const versionText = HomeTemplate.content.getElementById("version-text");
|
||||
let bepinexVersion
|
||||
|
||||
navigate("home")
|
||||
|
||||
@@ -118,9 +119,21 @@ async function downloadMod() {
|
||||
}
|
||||
|
||||
async function installBepinex() {
|
||||
bepinex.install()
|
||||
bepinexVersion = await bepinex.install()
|
||||
setBepinexVersion()
|
||||
}
|
||||
|
||||
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`
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user