update
Some checks failed
deploy / deploy (push) Has been cancelled

This commit is contained in:
toom1996
2026-08-25 21:25:20 +08:00
parent 93b6f0bef0
commit d64a046f82
9 changed files with 487 additions and 153 deletions

View File

@ -358,6 +358,13 @@ export async function fetchMe(): Promise<AuthUser | null> {
}
}
// 登录/注册成功后写入本地会话(token + user),供 Layout 顶部已登录态与 fetchMe 读取。
export function saveSession(token: string, user: AuthUser): void {
if (typeof localStorage === "undefined") return
localStorage.setItem(TOKEN_KEY, token)
localStorage.setItem(USER_KEY, JSON.stringify(user))
}
// ===================== SSG 构建专用(/api/ssg/*,仅 Node 构建期) =====================
function ssgEnv(name: string): string | undefined {