diff --git a/app/home/layout.tsx b/app/home/layout.tsx index 7e8f5c4..55baa44 100644 --- a/app/home/layout.tsx +++ b/app/home/layout.tsx @@ -18,11 +18,11 @@ export default function DashboardLayout({ // 从 SSEContext 中获取侧边栏状态及其 setter 函数 const { isNavCollapsed } = useSSEContext(); + // 避免页面初始化时侧边栏闪烁的问题 const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); - if (!mounted) { return null; } diff --git a/app/home/utils/fixedButton.tsx b/app/home/utils/fixedButton.tsx index acccc19..7231398 100644 --- a/app/home/utils/fixedButton.tsx +++ b/app/home/utils/fixedButton.tsx @@ -10,6 +10,7 @@ const FixedButton = () => { const switchMode = (theme: string) => { setTheme(theme); }; + // 避免按钮闪烁的问题 useEffect(() => { setMounted(true); }, []);