fix: time loading

This commit is contained in:
hamster1963 2024-10-20 13:09:56 +08:00
parent 7bed9cf4ba
commit adfea0be8e

View File

@ -3,6 +3,7 @@
import { LanguageSwitcher } from "@/components/LanguageSwitcher"; import { LanguageSwitcher } from "@/components/LanguageSwitcher";
import { ModeToggle } from "@/components/ThemeSwitcher"; import { ModeToggle } from "@/components/ThemeSwitcher";
import { Separator } from "@/components/ui/separator"; import { Separator } from "@/components/ui/separator";
import { Skeleton } from "@/components/ui/skeleton";
import getEnv from "@/lib/env-entry"; import getEnv from "@/lib/env-entry";
import { DateTime } from "luxon"; import { DateTime } from "luxon";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
@ -62,7 +63,7 @@ function Header() {
// https://github.com/streamich/react-use/blob/master/src/useInterval.ts // https://github.com/streamich/react-use/blob/master/src/useInterval.ts
const useInterval = (callback: Function, delay?: number | null) => { const useInterval = (callback: Function, delay?: number | null) => {
const savedCallback = useRef<Function>(() => {}); const savedCallback = useRef<Function>(() => { });
useEffect(() => { useEffect(() => {
savedCallback.current = callback; savedCallback.current = callback;
}); });
@ -95,9 +96,9 @@ function Overview() {
<p className="text-sm font-medium opacity-50"> <p className="text-sm font-medium opacity-50">
{t("p_2390-2457_wherethetimeis")} {t("p_2390-2457_wherethetimeis")}
</p> </p>
{mouted && ( {mouted ? (
<p className="opacity-1 text-sm font-medium">{timeString}</p> <p className="opacity-1 text-sm font-medium">{timeString}</p>
)} ) : <Skeleton className="h-[20px] w-[50px] rounded-[5px] bg-muted-foreground/10 animate-none"></Skeleton>}
</div> </div>
</section> </section>
); );