"use client" import * as React from "react" import Link from "next/link" import {Check, Loader2, Monitor, Moon, Sun} from "lucide-react" import {useTheme} from "next-themes" import {toast} from "sonner" import {Button} from "@/components/ui/button" import {useCustomTheme} from "@/lib/theme" import {cn} from "@/lib/utils" import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "@/components/ui/breadcrumb" function ThemeModeSection() { const { theme, setTheme } = useTheme() const [mounted, setMounted] = React.useState(false) React.useEffect(() => { setMounted(true) }, []) const modes = [ { id: "light", name: "明亮", icon: Sun }, { id: "dark", name: "黑暗", icon: Moon }, { id: "system", name: "自动", icon: Monitor } ] if (!mounted) { return (

主题模式

选择应用程序的整体明暗主题

{modes.map((mode) => { const Icon = mode.icon return ( ) })}
) } return (

主题模式

选择应用程序的整体明暗主题

{modes.map((mode) => { const Icon = mode.icon const isActive = theme === mode.id return ( ) })}
) } function InterfaceAppearanceSection() { const { themes, currentThemeId, setTheme: setCustomTheme, isLoading } = useCustomTheme() const { theme: mode } = useTheme() const [mounted, setMounted] = React.useState(false) const [switching, setSwitching] = React.useState(null) React.useEffect(() => { setMounted(true) }, []) const handleSetTheme = (themeId: string) => { if (switching === themeId) return setSwitching(themeId) try { setCustomTheme(themeId) const themeName = themes.find(t => t.id === themeId)?.name || themeId toast.success(`外观已切换为 ${ themeName }`) } catch { toast.error("切换失败") } finally { setSwitching(null) } } const isDark = mounted && (mode === 'dark' || (mode === 'system' && typeof window !== 'undefined' && window.matchMedia('(prefers-color-scheme: dark)').matches)) return (

界面外观

选择界面的配色方案和视觉风格

{isLoading ? (
) : (
{themes.map((theme) => { const isActive = currentThemeId === theme.id || (!currentThemeId && theme.id === "default.css") const isSwitching = switching === theme.id const colors = isDark ? theme.colors.dark : theme.colors.light return (
handleSetTheme(theme.id)} className={cn( "group relative cursor-pointer rounded-xl border transition-all overflow-hidden", isActive ? "border-primary ring-2 ring-primary/20" : "border-border hover:border-border/50 hover:shadow-md" )} >
{isActive && !isSwitching && (
)}
{theme.name}
) })}
)}
) } export function AppearanceMain() { return (
设置 外观设置

即将推出

更多自定义选项正在开发中...
) }