import { UserInfo } from '@/api/interface/system/user'
import { LoginData, LoginResult, VerifyCodeResult } from '@/api/interface/login'
import http from '@/api'

/**
 *
 * 用户登录
 * @param data {LoginData}
 */
export const loginApi = (data: LoginData) => {
  return http.post<LoginResult>('/auth/login', data, { loading: true, isEncrypt: true }) // 正常 post json 请求  ==>  application/json
}

// 用户退出登录
export const logoutApi = () => {
  return http.post('/auth/logout', {}, { loading: false })
}

// 获取用户详细信息
export const getInfoApi = () => {
  return http.get<UserInfo>('/system/user/getInfo', {}, { loading: false })
}
// 获取验证码
export const getCodeImg = () => {
  return http.get<VerifyCodeResult>('/captchaImage', {}, { loading: false })
}
