token.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2022 Pnoker All Rights Reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * https://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import request from '@/config/axios'
  17. import { Login } from '@/config/types'
  18. /**
  19. * 获取 Salt
  20. *
  21. * @param login Login
  22. * @returns MyAxiosPromise
  23. */
  24. export const generateSalt = (login: Login) =>
  25. request<R>({
  26. url: `api/v3/auth/token/salt`,
  27. method: 'post',
  28. data: login,
  29. })
  30. /**
  31. * 登录
  32. *
  33. * @param login Login
  34. * @returns MyAxiosPromise
  35. */
  36. export const generateToken = (login: Login) =>
  37. request<R>({
  38. url: `api/v3/auth/token/generate`,
  39. method: 'post',
  40. data: login,
  41. })
  42. /**
  43. * 注销
  44. *
  45. * @param login Login
  46. * @returns MyAxiosPromise
  47. */
  48. export const cancelToken = (login: Login) =>
  49. request<R>({
  50. url: `api/v3/auth/token/cancel`,
  51. method: 'post',
  52. data: login,
  53. })
  54. /**
  55. * 校验 Token
  56. *
  57. * @param login Login
  58. * @returns MyAxiosPromise
  59. */
  60. export const checkTokenValid = (login: Login) =>
  61. request<R>({
  62. url: `api/v3/auth/token/check`,
  63. method: 'post',
  64. data: login,
  65. })