index.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import request from '@/config/axios'
  2. import type { UserType } from './types'
  3. interface RoleParams {
  4. roleName: string
  5. }
  6. export const loginApi = (data: UserType): Promise<IResponse<UserType>> => {
  7. return request.post({
  8. url: '/uc/oauth/token',
  9. data: Object.assign({}, data, {
  10. client_id: 'chelvc_client',
  11. client_secret: 'qWBe6jD%GCuPPTkP',
  12. grant_type: 'password'
  13. }),
  14. headersType: 'application/x-www-form-urlencoded',
  15. headers: {
  16. Platform: 'PC',
  17. Terminal: 'ADMIN'
  18. }
  19. })
  20. }
  21. export const loginOutApi = (): Promise<IResponse> => {
  22. return request.get({ url: '/user/loginOut' })
  23. }
  24. export const getUserListApi = ({ params }: AxiosConfig) => {
  25. return request.get<{
  26. code: string
  27. data: {
  28. list: UserType[]
  29. total: number
  30. }
  31. }>({ url: '/user/list', params })
  32. }
  33. export const getAdminRoleApi = (
  34. params: RoleParams
  35. ): Promise<IResponse<AppCustomRouteRecordRaw[]>> => {
  36. return request.get({ url: '/role/list', params })
  37. }
  38. export const getTestRoleApi = (params: RoleParams): Promise<IResponse<string[]>> => {
  39. return request.get({ url: '/role/list', params })
  40. }