final final final

This commit is contained in:
Maikiwi 2022-10-16 18:49:18 -07:00
parent 775dd53283
commit 97cc718dc0
6 changed files with 25 additions and 13 deletions

View file

@ -290,6 +290,20 @@ const app = new Vue({
); );
}, },
methods: { methods: {
_fetch(url, opts = {}) {
if (app.cfg.advanced.experiments.includes("cider_mirror") === true) {
if (url.includes("api.github.com/")) {
return fetch(url.replace("api.github.com/", "mirror.api.cider.sh/v2/api/"), opts);
} else if (url.includes("raw.githubusercontent.com/")) {
return fetch(url.replace("raw.githubusercontent.com/", "mirror.api.cider.sh/v2/raw/"), opts);
} else {
return fetch(url, opts);
}
} else {
return fetch(url, opts);
}
}
,
setWindowHash(route = "") { setWindowHash(route = "") {
this.setPagePos(); this.setPagePos();
window.location.hash = `#${route}`; window.location.hash = `#${route}`;
@ -1290,9 +1304,8 @@ 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 fetch(`https://api.github.com/repos/${theme.github_repo}/commits`) await app._fetch(`https://api.github.com/repos/${theme.github_repo}/commits`)
.then((res) => res.json()) .then((res) => res.json())
.then((res) => {
if (res[0].sha != theme.commit) { if (res[0].sha != theme.commit) {
const notify = notyf.open({ const notify = notyf.open({
className: "notyf-info", className: "notyf-info",
@ -1304,8 +1317,7 @@ const app = new Vue({
notyf.dismiss(notify); notyf.dismiss(notify);
}); });
} }
}); };
}
}); });
}, },
async setTheme(theme = "", onlyPrefs = false) { async setTheme(theme = "", onlyPrefs = false) {

View file

@ -107,7 +107,7 @@
redirect: 'follow' redirect: 'follow'
}; };
fetch(readmeUrl, requestOptions) app._fetch(readmeUrl, requestOptions)
.then(response => response.text()) .then(response => response.text())
.then(result => { .then(result => {
self.openRepo = repo self.openRepo = repo
@ -178,7 +178,7 @@
redirect: 'follow' redirect: 'follow'
}; };
fetch("https://api.github.com/search/repositories?q=topic:cidermusicplugin fork:true&per_page=100", requestOptions) app._fetch("https://api.github.com/search/repositories?q=topic:cidermusicplugin fork:true&per_page=100", requestOptions)
.then(response => response.text()) .then(response => response.text())
.then(result => { .then(result => {
self.repos = JSON.parse(result).items self.repos = JSON.parse(result).items

View file

@ -126,7 +126,7 @@
redirect: 'follow' redirect: 'follow'
}; };
fetch(readmeUrl, requestOptions) app._fetch(readmeUrl, requestOptions)
.then(response => response.text()) .then(response => response.text())
.then(result => { .then(result => {
self.openRepo = repo self.openRepo = repo
@ -184,7 +184,7 @@
redirect: 'follow' redirect: 'follow'
}; };
fetch("https://api.github.com/search/repositories?q=topic:cidermusictheme fork:true&per_page=100", requestOptions) app._fetch("https://api.github.com/search/repositories?q=topic:cidermusictheme fork:true&per_page=100", requestOptions)
.then(response => response.text()) .then(response => response.text())
.then(result => { .then(result => {
let items = JSON.parse(result).items let items = JSON.parse(result).items

View file

@ -297,7 +297,7 @@
redirect: 'follow' redirect: 'follow'
}; };
fetch(readmeUrl, requestOptions) app._fetch(readmeUrl, requestOptions)
.then(response => response.text()) .then(response => response.text())
.then(result => { .then(result => {
self.openRepo = repo self.openRepo = repo

View file

@ -356,7 +356,7 @@
redirect: 'follow' redirect: 'follow'
}; };
fetch("https://api.github.com/search/repositories?q=topic:cidermusictheme fork:true", requestOptions) app._fetch("https://api.github.com/search/repositories?q=topic:cidermusictheme fork:true", requestOptions)
.then(response => response.text()) .then(response => response.text())
.then(result => { .then(result => {
let items = JSON.parse(result).items let items = JSON.parse(result).items
@ -366,4 +366,4 @@
} }
} }
}) })
</script> --> </script> -->

View file

@ -186,7 +186,7 @@
redirect: 'follow' redirect: 'follow'
}; };
fetch("https://api.github.com/search/repositories?q=topic:cidermusictheme fork:true&per_page=100", requestOptions) app._fetch("https://api.github.com/search/repositories?q=topic:cidermusictheme fork:true&per_page=100", requestOptions)
.then(response => response.text()) .then(response => response.text())
.then(result => { .then(result => {
let items = JSON.parse(result).items let items = JSON.parse(result).items
@ -197,4 +197,4 @@
} }
}) })
</script> </script>
--> -->