- 新增 ProfileView 共享个人信息页面 - 扩展 auth API UserProfile 支持各角色 - 为 admin/school/teacher/parent 添加 profile 路由 - 各端 Layout 用户菜单增加个人信息入口及跳转 - 家长端移动版抽屉菜单增加个人信息入口 Made-with: Cursor
58 lines
1.1 KiB
TypeScript
58 lines
1.1 KiB
TypeScript
import { http } from './index';
|
|
|
|
export interface LoginParams {
|
|
account: string;
|
|
password: string;
|
|
role: string;
|
|
}
|
|
|
|
export interface LoginResponse {
|
|
token: string;
|
|
user: {
|
|
id: number;
|
|
name: string;
|
|
role: 'admin' | 'school' | 'teacher';
|
|
tenantId?: number;
|
|
tenantName?: string;
|
|
email?: string;
|
|
phone?: string;
|
|
};
|
|
}
|
|
|
|
export interface UserProfile {
|
|
id: number;
|
|
username?: string;
|
|
name: string;
|
|
role: 'admin' | 'school' | 'teacher' | 'parent';
|
|
tenantId?: number;
|
|
tenantName?: string;
|
|
email?: string;
|
|
phone?: string;
|
|
avatar?: string;
|
|
avatarUrl?: string;
|
|
}
|
|
|
|
// 登录
|
|
export function login(params: LoginParams): Promise<LoginResponse> {
|
|
return http.post('/v1/auth/login', {
|
|
username: params.account,
|
|
password: params.password,
|
|
role: params.role,
|
|
});
|
|
}
|
|
|
|
// 登出
|
|
export function logout(): Promise<void> {
|
|
return http.post('/v1/auth/logout');
|
|
}
|
|
|
|
// 刷新Token
|
|
export function refreshToken(): Promise<{ token: string }> {
|
|
return http.post('/v1/auth/refresh');
|
|
}
|
|
|
|
// 获取当前用户信息
|
|
export function getProfile(): Promise<UserProfile> {
|
|
return http.get('/v1/auth/profile');
|
|
}
|