"use client" import { useEffect } from "react" import { Button } from "@/components/ui/button" import { useAuthStore } from "@/store/auth" import { useLoginDialogStore } from "@/store/login-dialog" interface AuthGuardProps { children: React.ReactNode } export function AuthGuard({ children }: AuthGuardProps) { const isAuthenticated = useAuthStore((s) => s.isAuthenticated) const openLoginDialog = useLoginDialogStore((s) => s.openLoginDialog) useEffect(() => { if (!isAuthenticated) { openLoginDialog() } }, [isAuthenticated, openLoginDialog]) if (isAuthenticated) { return <>{children}> } return (
请先登录后继续访问此页面