feat(web-auth): 前端修改资料、修改密码优化

This commit is contained in:
R524809
2026-09-03 17:12:36 +08:00
parent 2d435143ab
commit cc61967e3b
6 changed files with 104 additions and 112 deletions
+4 -2
View File
@@ -28,12 +28,14 @@ function RequireSession({ children }: { children: ReactNode }) {
return children;
}
/** 认证页互斥:已登录访问 /login、/register 时回到主布局 */
/** 认证页互斥:已登录访问 /login、/register 时回到来源页或主布局 */
function RedirectIfAuthenticated({ children }: { children: ReactNode }) {
const { status } = useSession();
const location = useLocation();
if (status === 'authenticated') {
return <Navigate to="/" replace />;
const from = (location.state as { from?: string } | null)?.from;
return <Navigate to={from && from.startsWith('/') ? from : '/'} replace />;
}
return children;
}