index.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 getCodeImgApi = () => {
  20. return request.get({ url: '/system/captcha/get-image' })
  21. }
  22. // 登录
  23. export const loginApi = (data: UserLoginVO) => {
  24. return request.post({ url: '/system/auth/login', data })
  25. }
  26. // 刷新访问令牌
  27. export const refreshToken = () => {
  28. return request.post({ url: '/system/auth/refresh-token?refreshToken=' + getRefreshToken() })
  29. }
  30. // 使用租户名,获得租户编号
  31. export const getTenantIdByNameApi = (name: string) => {
  32. return request.get({ url: '/system/tenant/get-id-by-name?name=' + name })
  33. }
  34. // 登出
  35. export const loginOutApi = () => {
  36. return request.delete({ url: '/system/auth/logout' })
  37. }
  38. // 获取用户权限信息
  39. export const getInfoApi = () => {
  40. return request.get({ url: '/system/auth/get-permission-info' })
  41. }
  42. // 路由
  43. export const getAsyncRoutesApi = () => {
  44. return request.get({ url: '/system/auth/list-menus' })
  45. }
  46. //获取登录验证码
  47. export const sendSmsCodeApi = (data: SmsCodeVO) => {
  48. return request.post({ url: '/system/auth/send-sms-code', data })
  49. }
  50. // 短信验证码登录
  51. export const smsLoginApi = (data: SmsLoginVO) => {
  52. return request.post({ url: '/system/auth/sms-login', data })
  53. }