feat: 更新认证逻辑,支持通过openid查找或创建用户,并调整JWT负载字段

This commit is contained in:
2026-05-27 01:49:23 +08:00
parent 3506731061
commit 80904e65d8
6 changed files with 641 additions and 16 deletions

View File

@@ -27,9 +27,9 @@ export function LoginPage() {
if (tokenFromUrl !== oldToken) {
const payload = decodeToken(tokenFromUrl);
setTokenAndUser(tokenFromUrl, {
id: payload.sub,
id: String(payload.uid),
openid: payload.openid,
phone: payload.mobile,
phone: payload.phone,
});
} else {
// token 没变,确保 localStorage 有数据

View File

@@ -55,9 +55,9 @@ async function fetchApi<T>(path: string, options: RequestInit = {}): Promise<T>
// ─── Auth ───
export interface TokenPayload {
sub: string; // user_id
uid: number;
openid: string;
mobile: string;
phone: string;
exp: number;
}