From d6197d6d21e584fbbb25d0f93b1f957230eb0ec1 Mon Sep 17 00:00:00 2001 From: coolcoala Date: Wed, 30 Jul 2025 06:30:23 +0300 Subject: [PATCH] added traffic information display to the main page --- src/pages/home.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/pages/home.tsx b/src/pages/home.tsx index 7b543c7e..cf7944c2 100644 --- a/src/pages/home.tsx +++ b/src/pages/home.tsx @@ -25,7 +25,7 @@ import { AlertTriangle, Loader2, Globe, - Send, ExternalLink, RefreshCw, + Send, ExternalLink, RefreshCw, ArrowDown, ArrowUp, } from "lucide-react"; import { useVerge } from "@/hooks/use-verge"; import { useSystemState } from "@/hooks/use-system-state"; @@ -37,6 +37,8 @@ import { closeAllConnections } from "@/services/api"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; import { updateProfile } from "@/services/cmds"; import { SidebarTrigger } from "@/components/ui/sidebar"; +import parseTraffic from "@/utils/parse-traffic"; +import { useAppData } from "@/providers/app-data-provider"; const MinimalHomePage: React.FC = () => { const { t } = useTranslation(); @@ -46,6 +48,7 @@ const MinimalHomePage: React.FC = () => { useProfiles(); const viewerRef = useRef(null); const [uidToActivate, setUidToActivate] = useState(null); + const { connections } = useAppData(); const profileItems = useMemo(() => { const items = @@ -239,13 +242,26 @@ const MinimalHomePage: React.FC = () => { )} )} -
+

{isProxyEnabled ? t("Connected") : t("Disconnected")}

+ {isProxyEnabled && ( +
+
+ + {parseTraffic(connections.downloadTotal)} +
+
+ + {parseTraffic(connections.uploadTotal)} +
+
+ )} +

{isToggling && (isProxyEnabled ? t("Disconnecting...") : t("Connecting..."))} @@ -261,6 +277,7 @@ const MinimalHomePage: React.FC = () => { />

+ {showTunAlert && (