feat(app/web): bypass metrics.api.github.overuse with OAuth (#1171)

This commit is contained in:
Simon Lecoq
2022-08-06 06:09:24 +02:00
committed by GitHub
parent 0937317aa7
commit 587ceecc84
13 changed files with 660 additions and 114 deletions

View File

@@ -7,6 +7,8 @@
//Interpolate config from browser
try {
this.palette = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
if (localStorage.getItem("session.metrics"))
axios.defaults.headers.common["x-metrics-session"] = localStorage.getItem("session.metrics")
}
catch (error) {}
//Init
@@ -31,6 +33,11 @@
const {data: modes} = await axios.get("/.modes")
this.modes = modes
})(),
//OAuth
(async () => {
const {data: enabled} = await axios.get("/.oauth/enabled")
this.oauth = enabled
})(),
])
},
//Watchers
@@ -49,12 +56,17 @@
user1: "",
user2: "",
palette: "light",
requests: {rest: {limit: 0, used: 0, remaining: 0, reset: NaN}, graphql: {limit: 0, used: 0, remaining: 0, reset: NaN}},
requests: {rest: {limit: 0, used: 0, remaining: 0, reset: NaN}, graphql: {limit: 0, used: 0, remaining: 0, reset: NaN}, search: {limit: 0, used: 0, remaining: 0, reset: NaN}},
hosted: null,
modes: [],
oauth: false,
},
//Computed data
computed: {
//URL parameters
params() {
return new URLSearchParams({from:location.href})
},
//Is in preview mode
preview() {
return /-preview$/.test(this.version)