index.ts 1.9 KB

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