mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-07 05:11:51 +08:00
ARTEX — AI 自主渗透测试系统(Go 后端 + Next.js 前端,单二进制内嵌)。 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { Monitor, Moon, Sun } from "lucide-react";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import { persistPreference } from "@/lib/preferences/preferences-storage";
|
|
import { usePreferencesStore } from "@/stores/preferences/preferences-provider";
|
|
|
|
const THEME_CYCLE = ["light", "dark", "system"] as const;
|
|
|
|
export function ThemeSwitcher() {
|
|
const themeMode = usePreferencesStore((s) => s.themeMode);
|
|
const setThemeMode = usePreferencesStore((s) => s.setThemeMode);
|
|
|
|
const cycleTheme = () => {
|
|
const currentIndex = THEME_CYCLE.indexOf(themeMode);
|
|
const nextTheme = THEME_CYCLE[(currentIndex + 1) % THEME_CYCLE.length];
|
|
|
|
setThemeMode(nextTheme);
|
|
void persistPreference("theme_mode", nextTheme);
|
|
};
|
|
|
|
return (
|
|
<Button size="icon" onClick={cycleTheme} aria-label={`Current theme: ${themeMode}. Click to cycle themes`}>
|
|
{/* SYSTEM */}
|
|
<Monitor className="hidden [html[data-theme-mode=system]_&]:block" />
|
|
|
|
{/* DARK (resolved) */}
|
|
<Sun className="hidden dark:block [html[data-theme-mode=system]_&]:hidden" />
|
|
|
|
{/* LIGHT (resolved) */}
|
|
<Moon className="block dark:hidden [html[data-theme-mode=system]_&]:hidden" />
|
|
</Button>
|
|
);
|
|
}
|