fix(mining-admin-web): 修复auth API类型定义
更新 TypeScript 类型以匹配后端响应格式: - ApiResponse<T> 包装器 - LoginData 和 ProfileData 接口 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e28fe56489
commit
9fca17e7ed
|
|
@ -1,14 +1,32 @@
|
||||||
import { apiClient } from './client';
|
import { apiClient } from './client';
|
||||||
|
|
||||||
|
// 后端统一响应格式
|
||||||
|
interface ApiResponse<T> {
|
||||||
|
success: boolean;
|
||||||
|
data: T;
|
||||||
|
timestamp: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LoginData {
|
||||||
|
token: string;
|
||||||
|
admin: { id: string; username: string; name: string; role: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProfileData {
|
||||||
|
id: string;
|
||||||
|
username: string;
|
||||||
|
role: string;
|
||||||
|
}
|
||||||
|
|
||||||
export const authApi = {
|
export const authApi = {
|
||||||
login: (username: string, password: string) =>
|
login: (username: string, password: string) =>
|
||||||
apiClient.post<{ accessToken: string; admin: { id: string; username: string; role: string } }>('/auth/login', {
|
apiClient.post<ApiResponse<LoginData>>('/auth/login', {
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getProfile: () =>
|
getProfile: () =>
|
||||||
apiClient.get<{ id: string; username: string; role: string }>('/auth/profile'),
|
apiClient.get<ApiResponse<ProfileData>>('/auth/profile'),
|
||||||
|
|
||||||
changePassword: (oldPassword: string, newPassword: string) =>
|
changePassword: (oldPassword: string, newPassword: string) =>
|
||||||
apiClient.post('/auth/change-password', { oldPassword, newPassword }),
|
apiClient.post('/auth/change-password', { oldPassword, newPassword }),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue