diff --git a/frontend/src/components/layout/ThemeToggle.tsx b/frontend/src/components/layout/ThemeToggle.tsx index 974c9ee7..957f4d57 100644 --- a/frontend/src/components/layout/ThemeToggle.tsx +++ b/frontend/src/components/layout/ThemeToggle.tsx @@ -1,27 +1,40 @@ -import { Moon, Sun } from 'lucide-react' +import { Monitor, Moon, Sun } from 'lucide-react' import { Button } from '@/components/ui/button' import { useTheme } from '@/lib/hooks/use-theme' +import type { Theme } from '@/lib/hooks/use-theme' import { useReviewLocale } from '@/lib/reviewLocale' +const THEME_CYCLE: Theme[] = ['light', 'dark', 'system'] + +function nextTheme(current: Theme): Theme { + const idx = THEME_CYCLE.indexOf(current) + return THEME_CYCLE[(idx + 1) % THEME_CYCLE.length] +} + export function ThemeToggle() { - const { resolvedTheme, setTheme } = useTheme() + const { theme, resolvedTheme, setTheme } = useTheme() const { text } = useReviewLocale() - const themeLabel = resolvedTheme === 'dark' - ? text('切换到浅色模式', 'Switch to light mode') - : text('切换到深色模式', 'Switch to dark mode') + const next = nextTheme(theme) + const themeLabel = next === 'dark' + ? text('切换到深色模式', 'Switch to dark mode') + : next === 'system' + ? text('切换到跟随系统', 'Switch to system theme') + : text('切换到浅色模式', 'Switch to light mode') return (