Initial commit

This commit is contained in:
2025-05-11 20:32:14 +08:00
commit d97247159f
80 changed files with 13013 additions and 0 deletions

39
frontend/src/app.ts Normal file
View File

@@ -0,0 +1,39 @@
import {User} from "./network/models.ts";
class App {
appName = "资源库"
user: User | null = null;
token: string | null = null;
constructor() {
this.init();
}
init() {
const userJson = localStorage.getItem("user");
const tokenJson = localStorage.getItem("token");
if (userJson) {
this.user = JSON.parse(userJson);
}
if (tokenJson) {
this.token = JSON.parse(tokenJson);
}
}
saveData() {
localStorage.setItem("user", JSON.stringify(this.user));
localStorage.setItem("token", JSON.stringify(this.token));
}
isAdmin() {
return this.user != null && this.user.is_admin;
}
isLoggedIn() {
return this.user != null && this.token != null;
}
}
export const app = new App();