/**
* Route Guard Component
* 路由守卫组件 - 处理认证和授权
*/
import { Navigate } from "react-router-dom";
import type { ReactNode } from "react";
interface RouteGuardProps {
isAuthenticated: boolean;
redirectTo?: string;
children: ReactNode;
}
/**
* Protected route wrapper
* Redirects to auth page if not authenticated
*/
export const ProtectedRoute = ({
isAuthenticated,
redirectTo = "/",
children
}: RouteGuardProps) => {
return isAuthenticated ? <>{children}> : ;
};
/**
* Public route wrapper
* Redirects to home if already authenticated
*/
export const PublicRoute = ({
isAuthenticated,
redirectTo = "/home",
children
}: RouteGuardProps) => {
return !isAuthenticated ? <>{children}> : ;
};