import { Links, Meta, Outlet, Scripts, ScrollRestoration, } from "@remix-run/react"; import { NotificationProvider } from "hooks/notification"; import { Theme } from '@radix-ui/themes'; import { useEffect, useState } from "react"; import "~/index.css"; export function Layout() { const [theme, setTheme] = useState<'light' | 'dark'>('light'); useEffect(() => { // 初始化主题 const isDark = document.documentElement.classList.contains('dark'); setTheme(isDark ? 'dark' : 'light'); // 监听主题变化 const handleThemeChange = (event: CustomEvent<{ theme: 'light' | 'dark' }>) => { setTheme(event.detail.theme); }; window.addEventListener('theme-change', handleThemeChange as EventListener); return () => window.removeEventListener('theme-change', handleThemeChange as EventListener); }, []); return (