From f1ff27e72013b5c89de241d4d3ab11244aa91e15 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期三, 12 十一月 2025 17:30:14 +0800
Subject: [PATCH] fix: 四流

---
 src/hooks/useUser.ts |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/hooks/useUser.ts b/src/hooks/useUser.ts
index d0276b5..6a1928c 100644
--- a/src/hooks/useUser.ts
+++ b/src/hooks/useUser.ts
@@ -1,9 +1,10 @@
 import { useUserStore } from '@/store/modules/user';
 import { UserUtils } from '@bole-core/core';
-// import * as userRoleServices from '@/services/api/UserRole';
+import * as userRoleServices from '@/services/api/UserRole';
 import * as userServices from '@/services/api/User';
 import { useQuery, useQueryClient } from '@tanstack/vue-query';
 import { formatRoleName } from '@/utils';
+import { EnumMenuScene } from '@/constants';
 
 export function useIsSystemAdmin() {
   const userStore = useUserStore();
@@ -23,14 +24,18 @@
   };
 }
 
-export function useAllRoleList() {
-  const { data: allRoleList, refetch } = useQuery({
-    queryKey: ['userServices/getAllRoles'],
+type UseAllRoleListOptions = {
+  menuScene?: EnumMenuScene;
+};
+
+export function useAllRoleList(options: UseAllRoleListOptions = {}) {
+  const { menuScene = EnumMenuScene.Goverment } = options;
+  const { data: allRoleList } = useQuery({
+    queryKey: ['userRoleServices/getRoles', menuScene],
     queryFn: async () => {
-      let res = await userServices.getAllRoles({ showLoading: false });
-      return res;
+      let res = await userRoleServices.getRoles({ menuScene }, { showLoading: false });
+      return res.data;
     },
-    placeholderData: () => [] as API.RoleInfo[],
     select(data) {
       return data.map((x) => ({
         ...x,
@@ -40,8 +45,12 @@
     },
   });
 
+  const enableRoleList = computed(() => {
+    return allRoleList.value.filter((x) => x.isEnable);
+  });
+
   return {
     allRoleList,
-    refetch,
+    enableRoleList,
   };
 }

--
Gitblit v1.9.1