mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 23:51:15 +00:00
Add pre-fetch data handling for resources, users, and comments
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user