[Status Page] Preload data

This commit is contained in:
Louis Lam
2022-06-01 13:05:12 +08:00
parent e4ad8cbfc8
commit 091158cfe7
5 changed files with 159 additions and 119 deletions

View File

@@ -538,7 +538,7 @@ export default {
this.slug = "default";
}
axios.get("/api/status-page/" + this.slug).then((res) => {
this.getData().then((res) => {
this.config = res.data.config;
if (!this.config.domainNameList) {
@@ -567,6 +567,21 @@ export default {
},
methods: {
/**
* Get status page data
* It should be preloaded in window.preloadData
* @returns {Promise<any>}
*/
getData: function () {
if (window.preloadData) {
return new Promise(resolve => resolve({
data: window.preloadData
}));
} else {
return axios.get("/api/status-page/" + this.slug);
}
},
highlighter(code) {
return highlight(code, languages.css);
},