import type * as Login from "./types/login"
import { request } from "@/utils/service"

/** 获取用户详情 */
export function getUserInfoApi() {
  return request<Login.UserInfoResponseData>({
    url: "/api/user/info",
    method: "get"
  })
}

/** 用 SSO 回跳的 code 兑换登录态 */
export function getAuthCode(code: string) {
  return request<Login.getAuthCodeResponseData>({
    url: "/api/token/create",
    method: "post",
    data: { code }
  })
}

/** 刷新 Token（自身禁用刷新重试，避免死循环） */
export function refreshTokenApi() {
  return request({
    url: "/api/token/refresh",
    method: "post",
    config: {
      enableRefresh: false
    }
  })
}
