import { get, post } from "@/common/http/request";

export interface LoginParams {
  username: string;
  password: string;
  verifyCode?: string;
}

export interface Token {
  accessToken: string;
  refreshToken: string;
}

export const UserService = {
  // 登录
  login(params: LoginParams) {
    const loginParams = new URLSearchParams();
    loginParams.append("username", params.username);
    loginParams.append("password", params.password);
    return post("/auth/login", loginParams);
  },

  checkIsLogined() {
    return get("/auth/user/me");
  },

  // 获取用户信息
  getUserInfo() {
    return get("/auth/getUserInfo");
  },

  getDynamicRouter() {
    return get("/auth/getRouterConfigRawList");
  },

  logout() {
    return post("/auth/logout");
  },
};
