diff --git a/src/App.tsx b/src/App.tsx index 4205103..3240569 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,7 +8,6 @@ import { DashCommand } from "./components/DashCommand"; import ErrorBoundary from "./components/ErrorBoundary"; import Footer from "./components/Footer"; import Header, { RefreshToast } from "./components/Header"; -import { Skeleton } from "./components/ui/skeleton"; import { useBackground } from "./hooks/use-background"; import { useTheme } from "./hooks/use-theme"; import { InjectContext } from "./lib/inject"; @@ -18,29 +17,8 @@ import ErrorPage from "./pages/ErrorPage"; import Server from "./pages/Server"; const NotFound = lazy(() => import("./pages/NotFound")); -const ServerDetail = lazy(() => import("./pages/ServerDetail")); - -function ServerDetailRouteFallback() { - return ( -
-
-
- - -
- -
-
- - - - - - -
-
- ); -} +const loadServerDetail = () => import("./pages/ServerDetail"); +const ServerDetail = lazy(loadServerDetail); // Route checker component const RouteChecker: React.FC = () => { @@ -59,6 +37,10 @@ const MainApp: React.FC = () => { const [isCustomCodeInjected, setIsCustomCodeInjected] = useState(false); const { backgroundImage: customBackgroundImage } = useBackground(); + useEffect(() => { + loadServerDetail(); + }, []); + useEffect(() => { if (settingData?.data?.config?.custom_code) { InjectContext(settingData?.data?.config?.custom_code); @@ -137,7 +119,7 @@ const MainApp: React.FC = () => { }> + } diff --git a/src/components/MapTooltip.tsx b/src/components/MapTooltip.tsx index d8da965..0a39a90 100644 --- a/src/components/MapTooltip.tsx +++ b/src/components/MapTooltip.tsx @@ -11,14 +11,22 @@ const MapTooltip = memo(function MapTooltip() { if (!tooltipData) return null; + const verticalPlacement = + tooltipData.centroid[1] < 120 + ? "translate(20%, 8px)" + : tooltipData.centroid[1] > 380 + ? "translate(20%, calc(-100% - 8px))" + : "translate(20%, -50%)"; + return (
{ e.stopPropagation(); diff --git a/src/test/components/info-components.test.tsx b/src/test/components/info-components.test.tsx index 11036c6..bbed08e 100644 --- a/src/test/components/info-components.test.tsx +++ b/src/test/components/info-components.test.tsx @@ -161,6 +161,9 @@ describe("MapTooltip", () => { ); expect(await screen.findByText("Mainland China")).toBeInTheDocument(); + expect(screen.getByTestId("map-tooltip")).toHaveStyle({ + transform: "translate(20%, 8px)", + }); expect(screen.getByText("2 map.Servers")).toBeInTheDocument(); await user.click(screen.getByRole("button", { name: /edge-2/ }));