소스 검색

feat: 重定向页面支持跳转到站外

f-dev 1 주 전
부모
커밋
50705a8f3e
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      src/pages/redirect/index.tsx

+ 6 - 2
src/pages/redirect/index.tsx

@@ -56,8 +56,12 @@ const Redirect: React.FC = () => {
                     setUserConfig(null); // 清除用户信息
                 }
 
-                // 跳转到指定路由
-                navigate(redirectPath || '/home', { replace: true });
+                // 跳转到指定路由,外部链接使用 window.location
+                if (redirectPath?.startsWith('http')) {
+                    window.location.replace(redirectPath);
+                } else {
+                    navigate(redirectPath || '/home', { replace: true });
+                }
             } catch (error) {
                 console.error('处理重定向参数失败:', error);
                 // 出错时跳转到 home 页