// ============================================================ // 路由守卫 — 未登录重定向到 /login // ============================================================ import { Navigate, useLocation } from 'react-router-dom' import { useAuthStore } from '@/stores/authStore' export function AuthGuard({ children }: { children: React.ReactNode }) { const token = useAuthStore((s) => s.token) const location = useLocation() if (!token) { return } return <>{children} }