chore: Prettified Code
[ci skip]
This commit is contained in:
parent
4cb8cf5a19
commit
4a1cf5fed8
2 changed files with 14 additions and 7 deletions
|
@ -921,9 +921,14 @@ export class BrowserWindow {
|
|||
if (url.endsWith("/")) url = url.slice(0, -1);
|
||||
let response = await utils.fetch(`${url}/archive/refs/heads/main.zip`);
|
||||
let repo = url.split("/").slice(-2).join("/");
|
||||
let apiRepo = await utils.fetch(`https://api.github.com/repos/${repo}`, { headers: {
|
||||
"User-Agent": utils.getWindow().webContents.getUserAgent()}}).then((res) => res.json());
|
||||
console.error(apiRepo)
|
||||
let apiRepo = await utils
|
||||
.fetch(`https://api.github.com/repos/${repo}`, {
|
||||
headers: {
|
||||
"User-Agent": utils.getWindow().webContents.getUserAgent(),
|
||||
},
|
||||
})
|
||||
.then((res) => res.json());
|
||||
console.error(apiRepo);
|
||||
console.debug(`REPO ID: ${apiRepo.id}`);
|
||||
// extract the files from the first folder in the zip response
|
||||
let zip = new AdmZip(await response.buffer());
|
||||
|
@ -940,7 +945,7 @@ export class BrowserWindow {
|
|||
theme.commit = commit[0].sha;
|
||||
writeFileSync(join(utils.getPath("themes"), "gh_" + apiRepo.id, "theme.json"), JSON.stringify(theme, null, 4), "utf8");
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
console.error(e);
|
||||
returnVal.success = false;
|
||||
}
|
||||
BrowserWindow.win.webContents.send("theme-installed", returnVal);
|
||||
|
|
|
@ -85,9 +85,11 @@ export class utils {
|
|||
* @param opts {object} Other options
|
||||
*/
|
||||
static async fetch(url: string, opts = {}) {
|
||||
Object.assign(opts, { headers: {
|
||||
"User-Agent": utils.getWindow().webContents.getUserAgent()}
|
||||
})
|
||||
Object.assign(opts, {
|
||||
headers: {
|
||||
"User-Agent": utils.getWindow().webContents.getUserAgent(),
|
||||
},
|
||||
});
|
||||
if (this.getStoreValue("advanced.experiments").includes("cider_mirror") === true) {
|
||||
if (url.includes("api.github.com/")) {
|
||||
return await fetch(url.replace("api.github.com/", "mirror.api.cider.sh/v2/api/"), opts);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue