From 136151a01d70e219eb18e377b34692b2e5e87cdb Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期四, 05 三月 2026 11:00:11 +0800
Subject: [PATCH] feat(登录): 添加管理员获取全部菜单

---
 src/pages/index/index.vue |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 662e7a6..6dd4b40 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -111,6 +111,17 @@
 const userStore = useUserStore();
 const userInfo: any = computed(() => userStore.userInfo);
 
+// 鏄惁涓虹鐞嗗憳
+const isAdmin = computed(() => {
+  if (!userInfo.value || !userInfo.value.roles || !Array.isArray(userInfo.value.roles)) {
+    return false;
+  }
+
+  return userInfo.value.roles.some(
+    (role: any) => role.roleKey === "admin" || role.roleKey === "manager"
+  );
+});
+
 // 鍒ゆ柇鏄惁涓哄贰妫�鍛樿鑹�
 const isInspector = computed(() => {
   if (!userInfo.value || !userInfo.value.roles || !Array.isArray(userInfo.value.roles)) {
@@ -280,18 +291,19 @@
 
   if (
     (data.deviceGroupName && data.deviceGroupName.includes("涓�")) ||
-    (data.deviceGroupName && data.deviceGroupName.includes("缁�"))
+    (data.deviceGroupName && data.deviceGroupName.includes("缁�")) ||
+    isAdmin.value
   ) {
     // 濡傛灉鏄笣鎴栫粸锛屾樉绀虹敓浜х鐞嗚彍鍗�
     navList[0].show = true;
   }
   console.log("isInspector.value", isInspector.value);
-  if (isInspector.value) {
+  if (isInspector.value || isAdmin.value) {
     // 濡傛灉鏄贰妫�鍛橈紝鏄剧ず宸℃鑿滃崟
     navList[1].show = true;
   }
   console.log("isStorage.value", isStorage.value);
-  if (isStorage.value) {
+  if (isStorage.value || isAdmin.value) {
     // 濡傛灉鏄嚭搴撹鑹诧紝鏄剧ず鍑哄簱鑿滃崟
     navList[2].show = true;
   }

--
Gitblit v1.9.3