weird stuff
This commit is contained in:
parent
6a67cd8a54
commit
4cb8cf5a19
3 changed files with 26 additions and 18 deletions
|
@ -770,7 +770,7 @@ export class BrowserWindow {
|
||||||
};
|
};
|
||||||
Object.assign(options, args);
|
Object.assign(options, args);
|
||||||
|
|
||||||
let res = await utils.fetch(
|
let res = await fetch(
|
||||||
`https://amp-api.music.apple.com/${options.route}?${new URLSearchParams({
|
`https://amp-api.music.apple.com/${options.route}?${new URLSearchParams({
|
||||||
...options.GETBody,
|
...options.GETBody,
|
||||||
}).toString()}`,
|
}).toString()}`,
|
||||||
|
@ -921,7 +921,9 @@ export class BrowserWindow {
|
||||||
if (url.endsWith("/")) url = url.slice(0, -1);
|
if (url.endsWith("/")) url = url.slice(0, -1);
|
||||||
let response = await utils.fetch(`${url}/archive/refs/heads/main.zip`);
|
let response = await utils.fetch(`${url}/archive/refs/heads/main.zip`);
|
||||||
let repo = url.split("/").slice(-2).join("/");
|
let repo = url.split("/").slice(-2).join("/");
|
||||||
let apiRepo = await utils.fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json());
|
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}`);
|
console.debug(`REPO ID: ${apiRepo.id}`);
|
||||||
// extract the files from the first folder in the zip response
|
// extract the files from the first folder in the zip response
|
||||||
let zip = new AdmZip(await response.buffer());
|
let zip = new AdmZip(await response.buffer());
|
||||||
|
@ -938,6 +940,7 @@ export class BrowserWindow {
|
||||||
theme.commit = commit[0].sha;
|
theme.commit = commit[0].sha;
|
||||||
writeFileSync(join(utils.getPath("themes"), "gh_" + apiRepo.id, "theme.json"), JSON.stringify(theme, null, 4), "utf8");
|
writeFileSync(join(utils.getPath("themes"), "gh_" + apiRepo.id, "theme.json"), JSON.stringify(theme, null, 4), "utf8");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
returnVal.success = false;
|
returnVal.success = false;
|
||||||
}
|
}
|
||||||
BrowserWindow.win.webContents.send("theme-installed", returnVal);
|
BrowserWindow.win.webContents.send("theme-installed", returnVal);
|
||||||
|
|
|
@ -84,17 +84,20 @@ export class utils {
|
||||||
* @param url {string} URL param
|
* @param url {string} URL param
|
||||||
* @param opts {object} Other options
|
* @param opts {object} Other options
|
||||||
*/
|
*/
|
||||||
static fetch(url: string, opts = {}) {
|
static async fetch(url: string, opts = {}) {
|
||||||
|
Object.assign(opts, { headers: {
|
||||||
|
"User-Agent": utils.getWindow().webContents.getUserAgent()}
|
||||||
|
})
|
||||||
if (this.getStoreValue("advanced.experiments").includes("cider_mirror") === true) {
|
if (this.getStoreValue("advanced.experiments").includes("cider_mirror") === true) {
|
||||||
if (url.includes("api.github.com/")) {
|
if (url.includes("api.github.com/")) {
|
||||||
return fetch(url.replace("api.github.com/", "mirror.api.cider.sh/v2/api/"), opts);
|
return await fetch(url.replace("api.github.com/", "mirror.api.cider.sh/v2/api/"), opts);
|
||||||
} else if (url.includes("raw.githubusercontent.com/")) {
|
} else if (url.includes("raw.githubusercontent.com/")) {
|
||||||
return fetch(url.replace("raw.githubusercontent.com/", "mirror.api.cider.sh/v2/raw/"), opts);
|
return await fetch(url.replace("raw.githubusercontent.com/", "mirror.api.cider.sh/v2/raw/"), opts);
|
||||||
} else {
|
} else {
|
||||||
return fetch(url, opts);
|
return await fetch(url, opts);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return fetch(url, opts);
|
return await fetch(url, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1303,17 +1303,19 @@ const app = new Vue({
|
||||||
const themes = ipcRenderer.sendSync("get-themes");
|
const themes = ipcRenderer.sendSync("get-themes");
|
||||||
await asyncForEach(themes, async (theme) => {
|
await asyncForEach(themes, async (theme) => {
|
||||||
if (theme.commit != "") {
|
if (theme.commit != "") {
|
||||||
await app._fetch(`https://api.github.com/repos/${theme.github_repo}/commits`).then((res) => res.json());
|
if (theme.commit != "") {
|
||||||
if (res[0].sha != theme.commit) {
|
app._fetch(`https://api.github.com/repos/${theme.github_repo}/commits`).then((res) => res.json());
|
||||||
const notify = notyf.open({
|
if (res[0].sha != theme.commit) {
|
||||||
className: "notyf-info",
|
const notify = notyf.open({
|
||||||
type: "info",
|
className: "notyf-info",
|
||||||
message: app.stringTemplateParser(app.getLz("settings.notyf.visual.theme.updateAvailable"), { theme: theme.name }),
|
type: "info",
|
||||||
});
|
message: app.stringTemplateParser(app.getLz("settings.notyf.visual.theme.updateAvailable"), { theme: theme.name }),
|
||||||
notify.on("click", () => {
|
});
|
||||||
app.openSettingsPage("github-themes");
|
notify.on("click", () => {
|
||||||
notyf.dismiss(notify);
|
app.openSettingsPage("github-themes");
|
||||||
});
|
notyf.dismiss(notify);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue