index.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { useAxios } from '@/hooks/web/useAxios'
  2. import { getRefreshToken } from '@/utils/auth'
  3. import type { UserLoginVO } from './types'
  4. const request = useAxios()
  5. export interface CodeImgResult {
  6. captchaOnOff: boolean
  7. img: string
  8. uuid: string
  9. }
  10. export interface SmsCodeVO {
  11. mobile: string
  12. scene: number
  13. }
  14. export interface SmsLoginVO {
  15. mobile: string
  16. code: string
  17. }
  18. // 登录
  19. export const loginApi = (data: UserLoginVO) => {
  20. return request.post({ url: '/system/auth/login', data })
  21. }
  22. // 刷新访问令牌
  23. export const refreshToken = () => {
  24. return request.post({ url: '/system/auth/refresh-token?refreshToken=' + getRefreshToken() })
  25. }
  26. // 使用租户名,获得租户编号
  27. export const getTenantIdByNameApi = (name: string) => {
  28. return request.get({ url: '/system/tenant/get-id-by-name?name=' + name })
  29. }
  30. // 登出
  31. export const loginOutApi = () => {
  32. return request.delete({ url: '/system/auth/logout' })
  33. }
  34. // 获取用户权限信息
  35. export const getInfoApi = () => {
  36. return request.get({ url: '/system/auth/get-permission-info' })
  37. }
  38. // 路由
  39. export const getAsyncRoutesApi = () => {
  40. return request.get({ url: '/system/auth/list-menus' })
  41. }
  42. //获取登录验证码
  43. export const sendSmsCodeApi = (data: SmsCodeVO) => {
  44. return request.post({ url: '/system/auth/send-sms-code', data })
  45. }
  46. // 短信验证码登录
  47. export const smsLoginApi = (data: SmsLoginVO) => {
  48. return request.post({ url: '/system/auth/sms-login', data })
  49. }
  50. // 社交授权的跳转
  51. export const socialAuthRedirectApi = (type: string, redirectUri: string) => {
  52. return request.get({
  53. url: '/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri
  54. })
  55. }