feat(core): add insights output (#575)

This commit is contained in:
Simon Lecoq
2021-10-22 12:51:50 -04:00
committed by GitHub
parent 1e71235b48
commit b5a7925315
8 changed files with 120 additions and 41 deletions

View File

@@ -9,6 +9,10 @@
this.palette = (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light")
}
catch (error) {}
//Embed
this.embed = !!(new URLSearchParams(location.search).get("embed"))
//From local storage
this.localstorage = !!(new URLSearchParams(location.search).get("localstorage"))
//User
const user = location.pathname.split("/").pop()
if ((user) && (user !== "about")) {
@@ -18,8 +22,6 @@
else {
this.searchable = true
}
//Embed
this.embed = !!(new URLSearchParams(location.search).get("embed"))
//Init
await Promise.all([
//GitHub limit tracker
@@ -80,6 +82,10 @@
this.error = null
this.metrics = null
this.pending = true
if (this.localstorage) {
this.metrics = JSON.parse(localStorage.getItem("local.metrics") ?? "null")
return
}
this.metrics = (await axios.get(`/about/query/${this.user}`)).data
}
catch (error) {
@@ -143,6 +149,7 @@
hosted: null,
user: "",
embed: false,
localstorage: false,
searchable: false,
requests: { limit: 0, used: 0, remaining: 0, reset: 0 },
palette: "light",