diff --git a/src/components/sections/Header.tsx b/src/components/sections/Header.tsx index e5ceef9..4fd24aa 100644 --- a/src/components/sections/Header.tsx +++ b/src/components/sections/Header.tsx @@ -6,6 +6,7 @@ import { Table2, Moon, Sun, + SunMoon, CircleUserIcon, Menu, } from "lucide-react"; @@ -18,23 +19,19 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; interface HeaderProps { - viewMode: "grid" | "table"; - setViewMode: (mode: "grid" | "table") => void; searchTerm: string; setSearchTerm: (term: string) => void; } -export const Header = ({ - viewMode, - setViewMode, - searchTerm, - setSearchTerm, -}: HeaderProps) => { - const { appearance, setAppearance } = useTheme(); +export const Header = ({ searchTerm, setSearchTerm }: HeaderProps) => { + const { rawAppearance, setAppearance, viewMode, setViewMode } = useTheme(); const [isSearchOpen, setIsSearchOpen] = useState(false); const location = useLocation(); const isInstancePage = location.pathname.startsWith("/instance"); @@ -52,10 +49,6 @@ export const Header = ({ } }, [sitename]); - const toggleAppearance = () => { - setAppearance(appearance === "light" ? "dark" : "light"); - }; - return (
@@ -128,16 +121,35 @@ export const Header = ({ {viewMode === "grid" ? "表格视图" : "网格视图"} - - {appearance === "dark" ? ( - - ) : ( - - )} - - {appearance === "dark" ? "浅色模式" : "深色模式"} - - + + + {rawAppearance === "light" ? ( + + ) : rawAppearance === "dark" ? ( + + ) : ( + + )} + 切换主题 + + + setAppearance("light")}> + + 浅色模式 + + setAppearance("dark")}> + + 深色模式 + + setAppearance("system")}> + + 跟随系统 + + + {enableAdminButton && ( )} - + + + + + + setAppearance("light")}> + + 浅色模式 + + setAppearance("dark")}> + + 深色模式 + + setAppearance("system")}> + + 跟随系统 + + + {enableAdminButton && ( + + + + + + setAppearance("light")}> + + 浅色模式 + + setAppearance("dark")}> + + 深色模式 + + setAppearance("system")}> + + 跟随系统 + + + {enableAdminButton && (