feat: rbac初步对接完成

This commit is contained in:
Blizzard
2026-04-30 22:53:46 +08:00
parent 3ed0b76fc2
commit e3e38800aa
45 changed files with 1637 additions and 467 deletions
+55 -36
View File
@@ -1,25 +1,42 @@
import { get, post } from '@/lib/request'
// ==================== Types ====================
export interface SystemUser {
id: string; account: string; name: string; nickName?: string; phone?: string
avatar?: SystemOss; avatarId?: string; clientId?: string; tenantId?: string
createdAt: string; updatedAt: string; roles?: string[] // Adjusted based on backend info
menus?: any[]
gender?: number
id: string
name: string
account: string
nickName?: string
phone?: string
avatarId?: string
gender?: number // 0=未知 1=男 2=女
roles?: string[] // 角色 code 列表(仅 /auth/info 返回)
menus?: SystemMenu[] // 菜单树(仅 /auth/info 返回)
createdAt?: number // Unix 时间戳(秒)
roleIds?: string[] // 关联角色 ID(用户管理接口)
}
export interface SystemRole {
id: string; name: string; code: string; sort?: number
menus?: SystemMenu[]; createdAt: string; updatedAt: string
id: string
name: string
code: string
sort?: number
menuIds?: string[] // 关联菜单 ID 列表
}
export interface SystemMenu {
id: string; name: string; title?: string; code?: string; path?: string
icon?: string; locale?: string; parentId?: string; permission?: string
sort?: number; category?: number; children?: SystemMenu[]
createdAt: string; updatedAt: string
id: string
parentId?: string
category?: number // 1=菜单 2=按钮/权限
name: string // 路由名(英文)
title?: string // 显示标题(中文)
code?: string // 权限标识
path?: string // 路由路径
permission?: string // 操作权限标识
locale?: string // 国际化 key
icon?: string // 图标名称
sort?: number // 排序
children?: SystemMenu[]
}
export interface SystemOss {
@@ -29,35 +46,37 @@ export interface SystemOss {
}
export interface SystemClient {
id: string; clientId: string; name: string; grantType?: string
activeTimeout?: number; additionalInfo?: string
createdAt: string; updatedAt: string
id: string
clientId: string
name: string
grantType?: string
additionalInfo?: string
activeTimeout?: number // Token有效期(秒)
}
export interface OperationLog {
id: string; operatorId: string; operatorName: string
clientId: string; clientName: string
method: string; path: string; title: string
statusCode: number; duration: number // ms
ip: string; userAgent?: string
requestBody?: string; responseBody?: string
createdAt: string
id: string
clientId: string
ip: string
method: string
path: string
status: number
latency: number // 纳秒
agent: string
errorMessage: string
body: string // 请求体 JSON 字符串
resp: string // 响应体 JSON 字符串
userId: string
createdAt: number // Unix 时间戳(秒)
}
export interface CaptchaRes { captchaImg: string; captchaId: string }
export interface LoginParams { account: string; password: string; captcha: string; captchaId: string }
export interface LoginResponse { token: string; userInfo: SystemUser }
// ==================== Auth ====================
export async function getCaptcha() {
return get<{ code: number; data: CaptchaRes; msg: string }>('/auth/captcha')
export interface DictInfo {
id: string
type: string
label: string
value: string
sort: number
desc: string
}
export async function login(data: LoginParams) {
return post<{ code: number; data: LoginResponse; msg: string }>('/auth/login', data)
}
export async function logout() {
return get<{ code: number; data: null; msg: string }>('/auth/logout') // If backend doesn't have it, we just clear local token
}