gitdataai/src/components/auth/protected-route.tsx
ZhenYi aab9f0dbf1 feat(frontend): 替换全屏loading动画为SVG逐帧绘制动画
- 新增 loading-animation.tsx 组件,从 public/load.html 转换
- 动画特性: SVG路径逐条绘制 + 渐变填充,最少展示1.5秒
- 替换 homepage/layout.tsx, workspace/redirect.tsx, protected-route.tsx 中的全屏加载
- 修复 sidebar-user.tsx 中 Invitations 按钮在缩回状态下的居中问题
2026-04-28 19:59:31 +08:00

19 lines
525 B
TypeScript

import { Navigate, Outlet, useLocation } from 'react-router-dom';
import LoadingAnimation from '@/components/ui/loading-animation';
import { useUser } from '@/contexts/user-context';
export function ProtectedRoute() {
const { isAuthenticated, isLoading } = useUser();
const location = useLocation();
if (isLoading) {
return <LoadingAnimation />;
}
if (!isAuthenticated) {
return <Navigate to="/auth/login" state={{ from: location.pathname }} replace />;
}
return <Outlet />;
}