first commit

Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
HouYunFei
2026-05-19 19:50:36 +08:00
co-authored by Codex
commit 472bf8b732
133 changed files with 16869 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import { apiGet, apiPost } from "@/services/api/request";
export const AUTH_TOKEN_KEY = "infinite-canvas-auth-token-v1";
export type UserRole = "guest" | "user" | "admin";
export type AuthUser = {
id: string;
username: string;
role: UserRole;
createdAt: string;
updatedAt: string;
};
export type AuthSession = {
token: string;
user: AuthUser;
};
export type AuthPayload = {
username: string;
password: string;
};
export async function login(payload: AuthPayload) {
return apiPost<AuthSession>("/api/admin/login", payload);
}
export async function register(payload: AuthPayload) {
return apiPost<AuthSession>("/api/auth/register", payload);
}
export async function fetchCurrentUser(token?: string) {
return apiGet<AuthUser>("/api/auth/me", undefined, token);
}