From e2d2710823cfed4f843f2de13004f9bcde1bce5a Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Tue, 23 Jan 2024 09:36:57 +0800 Subject: [PATCH] Optimize AuthRoute --- src/AuthRoute.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/AuthRoute.tsx b/src/AuthRoute.tsx index ae0e24a..c93526f 100644 --- a/src/AuthRoute.tsx +++ b/src/AuthRoute.tsx @@ -4,6 +4,7 @@ import { getLoginStatus, getVerifyStatus_async } from '@/util/auth' import { Navigate } from 'react-router' const AuthRoute = () => { + const [searchParams] = useSearchParams() const matches = useMatches() const lastMatch = matches.reduce((_, second) => second) const handle = lastMatch.handle as RouteHandle @@ -30,7 +31,11 @@ const AuthRoute = () => { } } if (isLogin && ['/login', '/forget'].includes(lastMatch.pathname)) { - return + if (searchParams.has('redirect')) { + return + } else { + return + } } if (location.pathname.length > 1 && location.pathname.endsWith('/')) {