diff --git a/src/components/sections/NodeCard.tsx b/src/components/sections/NodeCard.tsx
index c06ceaa..8b97c2b 100644
--- a/src/components/sections/NodeCard.tsx
+++ b/src/components/sections/NodeCard.tsx
@@ -53,7 +53,7 @@ export const NodeCard = ({ node, enableSwap }: NodeCardProps) => {
{node.name}
diff --git a/src/components/sections/StatsBar.tsx b/src/components/sections/StatsBar.tsx
index 4b858d4..c166bdc 100644
--- a/src/components/sections/StatsBar.tsx
+++ b/src/components/sections/StatsBar.tsx
@@ -7,6 +7,7 @@ import {
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Settings2 } from "lucide-react";
+import { useEffect, useState } from "react";
import { Switch } from "@/components/ui/switch";
import { Button } from "@/components/ui/button";
import { formatBytes } from "@/utils";
@@ -31,7 +32,6 @@ interface StatsBarProps {
currentSpeedDown: number;
};
loading: boolean;
- currentTime: Date;
}
export const StatsBar = ({
@@ -39,9 +39,16 @@ export const StatsBar = ({
setDisplayOptions,
stats,
loading,
- currentTime,
}: StatsBarProps) => {
const isMobile = useIsMobile();
+ const [time, setTime] = useState(new Date());
+
+ useEffect(() => {
+ const timer = setInterval(() => {
+ setTime(new Date());
+ }, 1000);
+ return () => clearInterval(timer);
+ }, []);
// 获取已启用的统计项列表
const enabledStats = Object.keys(displayOptions).filter(
@@ -60,7 +67,7 @@ export const StatsBar = ({
当前时间
diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx
index 5f8b809..73f9690 100644
--- a/src/pages/Home.tsx
+++ b/src/pages/Home.tsx
@@ -27,7 +27,6 @@ const HomePage: React.FC = ({ viewMode, searchTerm }) => {
traffic: true,
speed: true,
});
- const [currentTime] = useState(new Date());
const combinedNodes = useMemo(() => {
if (!staticNodes) return [];
@@ -88,7 +87,6 @@ const HomePage: React.FC = ({ viewMode, searchTerm }) => {
setDisplayOptions={setDisplayOptions}
stats={stats}
loading={loading}
- currentTime={currentTime}
/>
)}