user.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { usePost, stringify, useGet } from "@/.cool";
  2. export type LoginData = {
  3. access_token: string;
  4. refresh_token: string;
  5. }
  6. export interface GetInfoResult {
  7. permissions: any[]
  8. roles: any[]
  9. sysRoles: any[]
  10. userInfo: any
  11. }
  12. export interface CONFIG_OPEN_CHILDREN_ALL {
  13. code: string
  14. name: string
  15. id: string
  16. content: string
  17. description: string
  18. type: number
  19. openFlag: boolean
  20. }
  21. export interface DICT_CHILDREN_ALL {
  22. code: string
  23. label: string
  24. value: string
  25. }
  26. export interface CONFIG_OPEN_VALUE {
  27. [key: string]: string
  28. }
  29. export interface DICT_DATA {
  30. 'config:open:children-all': CONFIG_OPEN_CHILDREN_ALL[]
  31. 'config:open:value': CONFIG_OPEN_VALUE
  32. 'dict:children': {
  33. [key: string]: CONFIG_OPEN_VALUE
  34. }
  35. 'dict:value:obj': {
  36. [key: string]: CONFIG_OPEN_VALUE
  37. }
  38. 'dict:value': { [key: string]: CONFIG_OPEN_VALUE }
  39. 'dict:code': { [key: string]: CONFIG_OPEN_VALUE }
  40. 'dict:label': { [key: string]: CONFIG_OPEN_VALUE }
  41. 'dict:children-all': { [key: string]: DICT_CHILDREN_ALL[] }
  42. }
  43. export function loginApi(params) {
  44. return usePost(`/oauth/token?${stringify(params)}`) as Promise<LoginData>
  45. }
  46. export function sendSmsCode(params) {
  47. return usePost(`/verify/sms/code/send`, params) as Promise<string>
  48. }
  49. export function getUsersInfo() {
  50. return useGet(`/upms/users/info`) as Promise<GetInfoResult>
  51. }
  52. export function dictData() {
  53. return useGet(`/upms/dicts/data`) as Promise<DICT_DATA>
  54. }