feat: 10.10线上最新代码提交

This commit is contained in:
zdl
2025-10-11 16:16:02 +08:00
parent 4d0dc109bc
commit 495ad758ea
3338 changed files with 460147 additions and 152745 deletions

19
src/components/ProtectedRoute.js Normal file → Executable file
View File

@@ -25,17 +25,26 @@ const ProtectedRoute = ({ children }) => {
);
}
// 记录当前路径,登录后可以回到这里
let currentPath = window.location.pathname + window.location.search;
let redirectUrl = `/auth/signin?redirect=${encodeURIComponent(currentPath)}`;
// 检查是否已登录
if (!isAuthenticated || !user) {
// 记录当前路径,登录后可以回到这里
const currentPath = window.location.pathname + window.location.search;
const redirectUrl = `/auth/signin?redirect=${encodeURIComponent(currentPath)}`;
return <Navigate to={redirectUrl} replace />;
}
// 已登录,渲染子组件
return children;
// return children;
// 更新逻辑 如果 currentPath 是首页 登陆成功后跳转到个人中心
if (currentPath === '/' || currentPath === '/home') {
currentPath = '/profile';
redirectUrl = `/auth/signin?redirect=${encodeURIComponent(currentPath)}`;
return <Navigate to={redirectUrl} replace />;
} else { // 否则正常渲染
return children;
}
};
export default ProtectedRoute;