wupengfei
4 天以前 f1582014efff0eb7997d3fa79226319d1fe4ba52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { useUserStore } from '@/store/modules/user';
import { UserUtils } from '@bole-core/core';
import { useQuery, useQueryClient } from '@tanstack/vue-query';
import * as userServices from '@/services/api/user';
 
export function useUser() {
  const userStore = useUserStore();
 
  const { userId, userInfo, userDetail } = storeToRefs(userStore);
 
  return {
    user: userInfo,
    userId: userId,
    userDetail: userDetail,
  };
}
 
type UseUserInfoRolesOptions = {
  userInfoId: MaybeRef<string>;
  userType: EnumUserType;
  clientType: EnumClientType;
};
 
export function useUserInfoRoles({ userInfoId, userType, clientType }: UseUserInfoRolesOptions) {
  const { data: userInfoRoles } = useQuery({
    queryKey: ['userServices/getUserInfoRoles'],
    queryFn: async () => {
      let res = await userServices.getUserInfoRoles(
        {
          userInfoId: unref(userInfoId),
          userType: userType,
          clientType: clientType,
        },
        { showLoading: false }
      );
      return res;
    },
    select(data) {
      return data;
    },
  });
 
  return {
    userInfoRoles,
  };
}