feat: 添加国际化支持,优化语言切换器和登录界面,增强用户体验
Some checks failed
lotteryfront CI / build (push) Has been cancelled
Some checks failed
lotteryfront CI / build (push) Has been cancelled
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useHydrationSafeEntryT } from "@/i18n/hydration-t";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { getPlayerMe } from "@/api/player";
|
||||
@@ -30,7 +32,8 @@ function stripSearchParamFromBrowserUrl(name: string): void {
|
||||
}
|
||||
|
||||
export function PlayerLoginScreen(): React.ReactElement {
|
||||
const { t } = useTranslation("entry");
|
||||
const { t: tErrors } = useTranslation("entry");
|
||||
const t = useHydrationSafeEntryT();
|
||||
const tRef = useRef(t);
|
||||
useEffect(() => {
|
||||
tRef.current = t;
|
||||
@@ -87,9 +90,9 @@ export function PlayerLoginScreen(): React.ReactElement {
|
||||
|
||||
sessionExpiredHandled.current = true;
|
||||
clearBearerToken();
|
||||
toast.error(t("errors.sessionExpired"));
|
||||
toast.error(tErrors("errors.sessionExpired"));
|
||||
stripSearchParamFromBrowserUrl("session");
|
||||
}, [clearBearerToken, searchParams, t]);
|
||||
}, [clearBearerToken, searchParams, tErrors]);
|
||||
|
||||
async function handleSubmit(event: React.FormEvent): Promise<void> {
|
||||
event.preventDefault();
|
||||
@@ -173,11 +176,8 @@ export function PlayerLoginScreen(): React.ReactElement {
|
||||
</div>
|
||||
</EntryHeroBanner>
|
||||
|
||||
<div className="mx-auto flex w-full max-w-md flex-1 flex-col px-4 py-8">
|
||||
<div className="w-full max-w-md">
|
||||
<h1 className="text-xl font-bold text-gray-900">{t("login.title")}</h1>
|
||||
<p className="mt-2 text-sm text-muted-foreground">{t("login.hint")}</p>
|
||||
|
||||
<div className="mx-auto flex w-full max-w-md flex-1 flex-col px-5 py-6">
|
||||
<div className="w-full rounded-2xl bg-white px-1 py-2">
|
||||
<PlayerLoginForm variant="mobile" {...formProps} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user