From 8fd9269bef7ba58015070cd1e0690c76a7530d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AC=94=E8=AE=B0=E6=9C=AC=E9=87=8C=E7=9A=84=E6=B0=B8?= =?UTF-8?q?=E5=B9=B3?= Date: Fri, 11 Jul 2025 11:31:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=AC=E6=AC=A1=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9=E5=A6=82=E4=B8=8B=20?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Layout.css | 10 --------- Layout.tsx | 35 -------------------------------- nkebao/src/pages/login/Login.tsx | 27 ++++++++++++++++++++++-- 3 files changed, 25 insertions(+), 47 deletions(-) delete mode 100644 Layout.css delete mode 100644 Layout.tsx diff --git a/Layout.css b/Layout.css deleted file mode 100644 index e6e6cb0b4..000000000 --- a/Layout.css +++ /dev/null @@ -1,10 +0,0 @@ -.container { - display: flex; - height: 100vh; - flex-direction: column; -} - -.container main { - flex: 1; - overflow: auto; -} \ No newline at end of file diff --git a/Layout.tsx b/Layout.tsx deleted file mode 100644 index 5ea387ef2..000000000 --- a/Layout.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; - -interface LayoutProps { - loading?: boolean; - children?: React.ReactNode; - header?: React.ReactNode; - footer?: React.ReactNode; -} - -const Layout: React.FC = ({ - loading, - children, - header, - footer -}) => { - return ( -
- {header && ( -
- {header} -
- )} -
- {children} -
- {footer && ( - - )} -
- ); -}; - -export default Layout; \ No newline at end of file diff --git a/nkebao/src/pages/login/Login.tsx b/nkebao/src/pages/login/Login.tsx index 53ede8b8f..395627ae5 100644 --- a/nkebao/src/pages/login/Login.tsx +++ b/nkebao/src/pages/login/Login.tsx @@ -32,6 +32,17 @@ export default function Login() { const { toast } = useToast(); const { login } = useAuth(); + // 检查URL是否为登录页面 + const isLoginPage = (url: string) => { + try { + const urlObj = new URL(url, window.location.origin); + return urlObj.pathname === '/login' || urlObj.pathname.endsWith('/login'); + } catch { + // 如果URL格式不正确,返回false + return false; + } + }; + // 倒计时效果 useEffect(() => { if (countdown > 0) { @@ -132,7 +143,13 @@ export default function Login() { // 跳转到首页或重定向URL const returnUrl = searchParams.get('returnUrl'); if (returnUrl) { - navigate(decodeURIComponent(returnUrl)); + const decodedUrl = decodeURIComponent(returnUrl); + // 检查重定向URL是否为登录页面,避免无限重定向 + if (isLoginPage(decodedUrl)) { + navigate('/'); + } else { + window.location.href = decodedUrl; + } } else { navigate('/'); } @@ -164,7 +181,13 @@ export default function Login() { // 跳转到首页或重定向URL const returnUrl = searchParams.get('returnUrl'); if (returnUrl) { - navigate(decodeURIComponent(returnUrl)); + const decodedUrl = decodeURIComponent(returnUrl); + // 检查重定向URL是否为登录页面,避免无限重定向 + if (isLoginPage(decodedUrl)) { + navigate('/'); + } else { + window.location.href = decodedUrl; + } } else { navigate('/'); }