登录页 mode 参数改为服务端直传,消除登录/注册表单切换闪烁
LoginPage 从 searchParams 提取 mode 作为 initialMode prop 传给 LoginClient, 替代客户端 useEffect 从 window.location.search 读取的方式,首次渲染即显示目标表单。 Tested: tsc --noEmit 通过, npm run build 通过
This commit is contained in:
@@ -2,7 +2,7 @@ import { LoginClient } from "@/components/auth/LoginClient";
|
||||
import { I18nProvider } from "@/hooks/useI18n";
|
||||
|
||||
type PageProps = {
|
||||
searchParams?: Promise<{ next?: string }>;
|
||||
searchParams?: Promise<{ next?: string; mode?: string }>;
|
||||
};
|
||||
|
||||
function normalizeNextPath(input: string | undefined) {
|
||||
@@ -14,12 +14,18 @@ function normalizeNextPath(input: string | undefined) {
|
||||
return raw;
|
||||
}
|
||||
|
||||
function normalizeMode(input: string | undefined): "login" | "signup" {
|
||||
if (input === "signup") return "signup";
|
||||
return "login";
|
||||
}
|
||||
|
||||
export default async function LoginPage({ searchParams }: PageProps) {
|
||||
const params = (await searchParams) || {};
|
||||
const nextPath = normalizeNextPath(params.next);
|
||||
const initialMode = normalizeMode(params.mode);
|
||||
return (
|
||||
<I18nProvider>
|
||||
<LoginClient nextPath={nextPath} />
|
||||
<LoginClient nextPath={nextPath} initialMode={initialMode} />
|
||||
</I18nProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user