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 } export interface SystemRole { id: string; name: string; code: string; sort?: number menus?: SystemMenu[]; createdAt: string; updatedAt: string } 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 } export interface SystemOss { id: string; name: string; key: string; url: string; suffix?: string tag?: string; md5?: string; width?: number; height?: number createdAt: string; updatedAt: string } export interface SystemClient { id: string; clientId: string; name: string; grantType?: string activeTimeout?: number; additionalInfo?: string createdAt: string; updatedAt: string } 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 } 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 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 }