diff --git a/frontend/src/components/AuthGuard.tsx b/frontend/src/components/AuthGuard.tsx index af548306..49a2ed68 100644 --- a/frontend/src/components/AuthGuard.tsx +++ b/frontend/src/components/AuthGuard.tsx @@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from "react"; import { message } from "antd"; import { LoginDialog } from "@/pages/Layout/LoginDialog"; import { SignupDialog } from "@/pages/Layout/SignupDialog"; -import { post, get } from "@/utils/request"; +import { post } from "@/utils/request"; import { useTranslation } from "react-i18next"; function loginUsingPost(data: { username: string; password: string }) { @@ -39,13 +39,6 @@ export function AuthGuard() { }; }, [openLoginDialog]); - useEffect(() => { - const session = localStorage.getItem("session"); - if (!session) { - get("/api/sys-param/sys.home.page.url").catch(() => {}); - } - }, []); - const handleLogin = async (values: { username: string; password: string }) => { try { setLoading(true); diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index d01d1321..98982f6d 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -12,23 +12,6 @@ import theme from "./theme"; import {errorConfigStore} from "@/utils/errorConfigStore.ts"; import "@/i18n"; -async function checkHomePageRedirect(): Promise { - try { - const response = await fetch('/api/sys-param/sys.home.page.url', { - cache: 'no-store' - }); - - if (response.ok) { - const result = await response.json(); - return result.data?.paramValue?.trim() || null; - } - } catch (error) { - console.error('Failed to fetch home page URL:', error); - } - - return null; -} - function showLoadingUI() { const container = document.getElementById("root"); if (!container) return; @@ -67,21 +50,7 @@ async function bootstrap() { showLoadingUI(); try { - const [, homePageUrl] = await Promise.all([ - errorConfigStore.loadConfig(), - checkHomePageRedirect() - ]); - - if (homePageUrl) { - const currentPath = window.location.pathname; - const targetPath = new URL(homePageUrl, window.location.origin).pathname; - - if (currentPath === '/' && currentPath !== targetPath) { - window.location.href = homePageUrl; - return; - } - } - + await errorConfigStore.loadConfig(); } catch (e) { console.error('Config load failed:', e); } diff --git a/frontend/src/pages/Home/Home.tsx b/frontend/src/pages/Home/Home.tsx index 30d46ca2..2f26c2ec 100644 --- a/frontend/src/pages/Home/Home.tsx +++ b/frontend/src/pages/Home/Home.tsx @@ -10,59 +10,19 @@ import { Sparkles, } from "lucide-react"; import { features, menuItems } from "../Layout/Menu.tsx"; -import { useState, useEffect } from 'react'; +import { useState } from 'react'; import { useNavigate } from "react-router"; -import { Card, Dropdown, Button, Spin } from "antd"; +import { Card, Dropdown, Button } from "antd"; import type { MenuProps } from 'antd'; import { Globe } from "lucide-react"; import { useTranslation } from "react-i18next"; import i18n from "@/i18n"; -import { getHomePageUrl } from '@/utils/systemParam'; export default function WelcomePage() { const navigate = useNavigate(); const [isChecking, setIsChecking] = useState(false); - const [isCheckingRedirect, setIsCheckingRedirect] = useState(true); const { t } = useTranslation(); - useEffect(() => { - let isMounted = true; - - const checkAndRedirect = async () => { - try { - const homePageUrl = await getHomePageUrl(); - - if (!isMounted) return; - - if (homePageUrl) { - window.location.href = homePageUrl; - return; - } - - setIsCheckingRedirect(false); - } catch (error) { - console.error('Failed to check home page URL:', error); - if (isMounted) { - setIsCheckingRedirect(false); - } - } - }; - - checkAndRedirect(); - - return () => { - isMounted = false; - }; - }, []); - - if (isCheckingRedirect) { - return ( -
- -
- ); - } - const languageMenuItems: MenuProps['items'] = [ { key: 'zh',