index.ts 767 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { RSA } from "@/utils/crypto";
  2. import { post, Result } from "../base";
  3. /**
  4. * 用户登录换取token
  5. * @param username 用户名
  6. * @param password 密码
  7. */
  8. export function login(username: string, password: string) {
  9. return post<any, Result<any>>("/auth/login", {
  10. username: username,
  11. password: RSA.encrypt(password)
  12. });
  13. }
  14. /**
  15. * 登出
  16. *
  17. * @returns .
  18. */
  19. export function logout() {
  20. return post<any, Result<any>>("/auth/logout", {});
  21. }
  22. /**
  23. * 验证谷歌验证器
  24. *
  25. * @returns .
  26. */
  27. export function createGoogleOtp() {
  28. return get<any, Result<any>>("/auth/googleOtp/create", {});
  29. }
  30. /**
  31. * 验证谷歌验证器
  32. *
  33. * @returns .
  34. */
  35. export function save(data: any) {
  36. return post<any, Result<any>>("/auth/googleOtp/save", data);
  37. }