diff --git a/app/(main)/header.tsx b/app/(main)/header.tsx index 149461f..00d115c 100644 --- a/app/(main)/header.tsx +++ b/app/(main)/header.tsx @@ -3,12 +3,13 @@ import { LanguageSwitcher } from "@/components/LanguageSwitcher" import { ModeToggle } from "@/components/ThemeSwitcher" import { Separator } from "@/components/ui/separator" -import { Skeleton } from "@/components/ui/skeleton" + import getEnv from "@/lib/env-entry" +import NumberFlow, { NumberFlowGroup } from "@number-flow/react" import { DateTime } from "luxon" import { useTranslations } from "next-intl" import { useRouter } from "next/navigation" -import { useEffect, useState } from "react" +import React from "react" function Header() { const t = useTranslations("Header") @@ -99,33 +100,51 @@ function Links() { function Overview() { const t = useTranslations("Overview") - const [mouted, setMounted] = useState(false) - useEffect(() => { - setMounted(true) - }, []) - const timeOption = DateTime.TIME_WITH_SECONDS - timeOption.hour12 = true - const [timeString, setTimeString] = useState( - DateTime.now().setLocale("en-US").toLocaleString(timeOption), - ) - useEffect(() => { - const updateTime = () => { - const now = DateTime.now().setLocale("en-US").toLocaleString(timeOption) - setTimeString(now) - requestAnimationFrame(updateTime) - } - requestAnimationFrame(updateTime) + const [time, setTime] = React.useState({ + hh: DateTime.now().setLocale("en-US").hour, + mm: DateTime.now().setLocale("en-US").minute, + ss: DateTime.now().setLocale("en-US").second, + }) + + React.useEffect(() => { + const timer = setInterval(() => { + setTime({ + hh: DateTime.now().setLocale("en-US").hour, + mm: DateTime.now().setLocale("en-US").minute, + ss: DateTime.now().setLocale("en-US").second, + }) + }, 1000) + + return () => clearInterval(timer) }, []) + return (

{t("p_2277-2331_Overview")}

{t("p_2390-2457_wherethetimeis")}

- {mouted ? ( -

{timeString}

- ) : ( - - )} + +
+ + + +
+
) diff --git a/bun.lockb b/bun.lockb index 77e75a0..bb461fa 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 42f16fb..acbe64a 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "dependencies": { "@ducanh2912/next-pwa": "^10.2.9", "@heroicons/react": "^2.2.0", + "@number-flow/react": "^0.5.5", "@radix-ui/react-dialog": "^1.1.5", "@radix-ui/react-dropdown-menu": "^2.1.5", "@radix-ui/react-label": "^2.1.1",