import type { IAuthLoginRes, ICaptcha } from '@/api/types/login'
import { http } from '@/http/http'

/**
 * 登录表单
 */
export interface ILoginForm {
  username: string
  password: string
  code?: string
  uuid?: string
}

/**
 * 获取验证码
 * @returns ICaptcha 验证码
 */
export function getCaptcha() {
  return http.get<ICaptcha>('/captchaImage')
}

/**
 * 用户登录
 * @param loginForm 登录表单
 */
export function login(loginForm: ILoginForm) {
  return http.post<IAuthLoginRes>('/login', loginForm)
}
