From 2010d809141ef03f14e6036d572623de3cf19aa9 Mon Sep 17 00:00:00 2001 From: naiba Date: Sat, 16 May 2026 00:46:15 +0800 Subject: [PATCH] fix: hide admin settings tabs for members Co-authored-by: naiba/CloudCode --- src/components/header.tsx | 53 ++++++++++++++++++--------------- src/components/settings-tab.tsx | 12 ++++---- src/routes/settings.tsx | 4 +-- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/components/header.tsx b/src/components/header.tsx index bbd6a68..246eae3 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -55,6 +55,7 @@ export default function Header() { const { t } = useTranslation() const { logout } = useAuth() const profile = useMainStore((store) => store.profile) + const isAdmin = profile?.role === 0 const location = useLocation() const isDesktop = useMediaQuery("(min-width: 890px)") @@ -142,18 +143,20 @@ export default function Header() { {t("Profile")} - { - setDropdownOpen(false) - navigate("/dashboard/settings") - }} - className="cursor-pointer" - > -
- - {t("Settings")} -
-
+ {isAdmin && ( + { + setDropdownOpen(false) + navigate("/dashboard/settings") + }} + className="cursor-pointer" + > +
+ + {t("Settings")} +
+
+ )} - { - setDropdownOpen(false) - navigate("/dashboard/settings") - }} - className="cursor-pointer" - > -
- - {t("Settings")} -
-
+ {isAdmin && ( + { + setDropdownOpen(false) + navigate("/dashboard/settings") + }} + className="cursor-pointer" + > +
+ + {t("Settings")} +
+
+ )} diff --git a/src/components/settings-tab.tsx b/src/components/settings-tab.tsx index 53e012f..30f260f 100644 --- a/src/components/settings-tab.tsx +++ b/src/components/settings-tab.tsx @@ -20,14 +20,14 @@ export const SettingsTab = ({ className }: { className?: string }) => { {t("User")} + + {t("OnlineUser")} + + + {t("WAF")} + )} - - {t("OnlineUser")} - - - {t("WAF")} - ) diff --git a/src/routes/settings.tsx b/src/routes/settings.tsx index dd0d6d8..8de2958 100644 --- a/src/routes/settings.tsx +++ b/src/routes/settings.tsx @@ -3,6 +3,7 @@ import { SettingsTab } from "@/components/settings-tab" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" import { Checkbox } from "@/components/ui/checkbox" +import { Combobox } from "@/components/ui/combobox" import { Form, FormControl, @@ -21,9 +22,8 @@ import { SelectValue, } from "@/components/ui/select" import { Textarea } from "@/components/ui/textarea" -import { Combobox } from "@/components/ui/combobox" -import { useNotification } from "@/hooks/useNotfication" import { useAuth } from "@/hooks/useAuth" +import { useNotification } from "@/hooks/useNotfication" import useSetting from "@/hooks/useSetting" import { asOptionalField } from "@/lib/utils" import { nezhaLang, settingCoverageTypes } from "@/types"