- 新增 loading-animation.tsx 组件,从 public/load.html 转换 - 动画特性: SVG路径逐条绘制 + 渐变填充,最少展示1.5秒 - 替换 homepage/layout.tsx, workspace/redirect.tsx, protected-route.tsx 中的全屏加载 - 修复 sidebar-user.tsx 中 Invitations 按钮在缩回状态下的居中问题
19 lines
525 B
TypeScript
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 />;
|
|
}
|