feat: 添加用户会话管理功能,包括登录状态、用户名计算和会话初始化

This commit is contained in:
2025-12-24 23:06:45 +08:00
parent 365427c851
commit 21cbb60480
3 changed files with 147 additions and 31 deletions

View File

@@ -1,4 +1,5 @@
import { requestJson, setPortalAuthToken } from './apiClient';
import { requestJson } from './apiClient';
import { setTokenAndLoadMe } from './session';
export async function register({ username, password, confirmPassword, verifyCode }) {
const data = await requestJson('/v1/auth/register', {
@@ -6,7 +7,6 @@ export async function register({ username, password, confirmPassword, verifyCode
body: { username, password, confirmPassword, verifyCode }
});
const token = data?.token ?? '';
if (token) setPortalAuthToken(token);
if (token) await setTokenAndLoadMe(token);
return token;
}