system.api.ts 940 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { http } from '@/api/http'
  2. import { httpErrorHandle } from '@/utils'
  3. import { RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum'
  4. import { LoginResult } from './system'
  5. // * 登录
  6. export const loginApi = async (data: object) => {
  7. try {
  8. const res = await http(RequestHttpEnum.POST)<LoginResult>(`${ModuleTypeEnum.SYSTEM}/login`, data)
  9. return res
  10. } catch (err) {
  11. httpErrorHandle()
  12. }
  13. }
  14. // * 登出
  15. export const logoutApi = async () => {
  16. try {
  17. const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.SYSTEM}/logout`)
  18. return res
  19. } catch (err) {
  20. httpErrorHandle()
  21. }
  22. }
  23. // * 获取 oss 上传接口
  24. export const ossUrlApi = async (data: object) => {
  25. try {
  26. const res = await http(RequestHttpEnum.GET)<{
  27. /**
  28. * bucket 地址
  29. */
  30. bucketURL?: string
  31. }>(`${ModuleTypeEnum.SYSTEM}/getOssInfo`, data)
  32. return res
  33. } catch (err) {
  34. httpErrorHandle()
  35. }
  36. }