added ipcRenderer.send("get-github-theme", "url")

This commit is contained in:
booploops 2022-02-11 19:05:59 -08:00
parent ceb61e7e14
commit fb65965d82
3 changed files with 23 additions and 2 deletions

View file

@ -13,6 +13,7 @@ import {wsapi} from "./wsapi";
import {jsonc} from "jsonc";
import {AppImageUpdater, NsisUpdater} from "electron-updater";
import {utils} from './utils';
const AdmZip = require("adm-zip");
export class BrowserWindow {
@ -370,6 +371,20 @@ export class BrowserWindow {
event.returnValue = process.platform;
});
ipcMain.on("get-github-theme", async (event, url) => {
if (url.endsWith("/")) url = url.slice(0, -1);
let response = await fetch(
`${url}/archive/refs/heads/main.zip`
);
let zip = await response.buffer();
let zipFile = new AdmZip(zip);
zipFile.extractAllTo(utils.getPath("themes"), true);
BrowserWindow.win.webContents.send("theme-installed", "");
event.returnValue = {
success: true,
};
});
ipcMain.on("get-themes", (event, _key) => {
if (existsSync(utils.getPath("themes"))) {
// return any .less files and scan any folders in the themes folder for .less files