duoqi-admin/src/types/api.ts
Wang Zhuoxuan 8e3d4ed190 refactor: 对接 duoqi-api 管理员管理接口规范
- 精简角色类型:移除 moderator,仅保留 super_admin 和 admin
- Admin 数据模型补全 isActive、updatedAt 字段
- 创建/重置密码改为展示服务端生成的 plainPassword(含复制按钮)
- 新增编辑管理员对话框(用户名、角色、启用/停用状态)
- fetchAdmins 支持分页和筛选参数
- loginWithToken 适配向后兼容的 { authenticated } 响应格式
- 添加内联成功/错误消息提示
2026-04-11 18:53:37 +08:00

59 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// API 响应错误结构
export interface ApiError {
code: string
message: string
}
// 统一 API 响应格式(匹配 duoqi-api 规范)
export interface ApiResponse<T> {
success: boolean
data: T | null
error: ApiError | null
}
// 分页元数据
export interface PaginationMeta {
total: number
page: number
limit: number
}
// 分页响应(额外包含 pagination
export interface PaginatedResponse<T> {
success: boolean
data: T[]
pagination: PaginationMeta
error: null
}
// 管理员用户信息(登录响应中的 admin 字段)
export interface AdminUser {
id: string
username: string
role: "super_admin" | "admin"
}
// Token 登录请求
export interface LoginRequest {
token: string
}
// 密码登录请求
export interface PasswordLoginRequest {
username: string
password: string
}
// 登录响应(匹配 duoqi-api 规范)
export interface LoginResponse {
accessToken: string
refreshToken: string
admin: AdminUser
}
// Token 刷新响应
export interface RefreshTokenResponse {
accessToken: string
refreshToken: string
}