Add pre-fetch data handling for resources, users, and comments

This commit is contained in:
2025-07-14 11:47:59 +08:00
parent 6188b88917
commit 0ef8e14587
6 changed files with 60 additions and 13 deletions

View File

@@ -63,6 +63,21 @@ class App {
canUpload() {
return this.isLoggedIn() && (this.user?.can_upload || this.isAdmin());
}
getPreFetchData() {
const preFetchDataElement = document.getElementById("pre_fetch_data");
if (preFetchDataElement) {
let content = preFetchDataElement.textContent
if (!content) {
return null;
}
content = decodeURIComponent(content);
const res = JSON.parse(content);
preFetchDataElement.remove();
return res;
}
return null;
}
}
export const app = new App();