diff --git a/control/frontend/src/App.tsx b/control/frontend/src/App.tsx index 80b1ff1..1e7f7de 100644 --- a/control/frontend/src/App.tsx +++ b/control/frontend/src/App.tsx @@ -12,6 +12,33 @@ import MonitorPage from "./pages/Monitor"; import SettingsPage from "./pages/Settings"; import StatsPage from "./pages/Stats"; +function formatBeijingTime(ms: number): string { + return new Date(ms).toLocaleString("zh-CN", { + timeZone: "Asia/Shanghai", + hour12: false, + year: "numeric", + month: "2-digit", + day: "2-digit", + hour: "2-digit", + minute: "2-digit", + second: "2-digit", + }); +} + +function BeijingClock() { + const [nowMs, setNowMs] = useState(() => Date.now()); + useEffect(() => { + const t = window.setInterval(() => setNowMs(Date.now()), 1000); + return () => window.clearInterval(t); + }, []); + return ( +
+ 北京时间 + {formatBeijingTime(nowMs)} +
+ ); +} + function Shell({ children }: { children: ReactNode }) { const user = getUsername(); const [lanClient, setLanClient] = useState(false); @@ -30,6 +57,7 @@ function Shell({ children }: { children: ReactNode }) {
对冲舰队指挥中心
—— 比特骆驼定制开发
+