From cb8c5bfc088fffbd5c441d7583573226a84e0c53 Mon Sep 17 00:00:00 2001 From: SongPro Date: Tue, 1 Jul 2025 17:25:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(AuthProvider):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E9=80=BB=E8=BE=91=E4=B8=AD/api=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E7=9A=84=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除未使用密码时的直接跳转逻辑 --- src/components/AuthProvider.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/components/AuthProvider.tsx b/src/components/AuthProvider.tsx index 381e276..c972a2f 100644 --- a/src/components/AuthProvider.tsx +++ b/src/components/AuthProvider.tsx @@ -18,7 +18,7 @@ export default function AuthProvider({ children }: Props) { const { siteName } = useSite(); const authenticate = useCallback(async () => { // 登录页 - if (pathname.startsWith('/login') || pathname.startsWith('/api/login')) { + if (pathname.startsWith('/login') || pathname.startsWith('/api')) { setIsAuthenticated(true); return; } @@ -30,13 +30,6 @@ export default function AuthProvider({ children }: Props) { ? window.location.pathname + window.location.search : pathname; - // 没有密码直接跳转 - if (!password) { - router.replace(`/login?redirect=${encodeURIComponent(fullPath)}`); - setIsAuthenticated(false); - return; - } - // 尝试认证 try { const res = await fetch('/api/login', {