Explorar el Código

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

f-dev hace 1 semana
padre
commit
50705a8f3e
Se han modificado 1 ficheros con 6 adiciones y 2 borrados
  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 页