From f0044e477c2da76d9d2c952e75a66a32fa24f5b6 Mon Sep 17 00:00:00 2001 From: LanQin_ Date: Wed, 17 Jun 2026 10:35:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(auth):=20=E4=BC=98=E5=8C=96=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2=E4=B8=8E=E4=BA=BA?= =?UTF-8?q?=E6=9C=BA=E9=AA=8C=E8=AF=81=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整登录、注册页布局为更一致的卡片式结构,提升表单可读性与视觉层级。 - 为登录/注册按钮与状态区补充图标和文案,优化交互反馈。 - 让 Turnstile 验证组件支持自适应宽度并使用更合适的展示尺寸。 --- apps/web/src/components/turnstile-box.tsx | 5 +- apps/web/src/pages/login.tsx | 73 +++++++------ apps/web/src/pages/register.tsx | 123 ++++++++++++---------- 3 files changed, 114 insertions(+), 87 deletions(-) diff --git a/apps/web/src/components/turnstile-box.tsx b/apps/web/src/components/turnstile-box.tsx index aa6b9af..af31732 100644 --- a/apps/web/src/components/turnstile-box.tsx +++ b/apps/web/src/components/turnstile-box.tsx @@ -3,7 +3,7 @@ import * as React from "react" declare global { interface Window { turnstile?: { - render: (container: HTMLElement, options: { sitekey: string; callback: (token: string) => void; "expired-callback": () => void; "error-callback": () => void }) => string + render: (container: HTMLElement, options: { sitekey: string; size?: "normal" | "compact" | "flexible"; callback: (token: string) => void; "expired-callback": () => void; "error-callback": () => void }) => string remove: (widgetId: string) => void } } @@ -20,6 +20,7 @@ export function TurnstileBox({ siteKey, onToken }: { siteKey: string; onToken: ( ref.current.innerHTML = "" widgetId = window.turnstile.render(ref.current, { sitekey: siteKey, + size: "flexible", callback: onToken, "expired-callback": () => onToken(""), "error-callback": () => onToken(""), @@ -46,5 +47,5 @@ export function TurnstileBox({ siteKey, onToken }: { siteKey: string; onToken: ( if (widgetId && window.turnstile) window.turnstile.remove(widgetId) } }, [siteKey, onToken]) - return
+ return
} diff --git a/apps/web/src/pages/login.tsx b/apps/web/src/pages/login.tsx index 95c047a..c6de1d8 100644 --- a/apps/web/src/pages/login.tsx +++ b/apps/web/src/pages/login.tsx @@ -1,6 +1,7 @@ import * as React from "react" import { Link, Navigate } from "react-router-dom" import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query" +import { ArrowRight, KeyRound, LockKeyhole } from "lucide-react" import { api } from "@/lib/api" import { useMe } from "@/hooks/use-me" import { TurnstileBox } from "@/components/turnstile-box" @@ -34,42 +35,52 @@ export function LoginPage() { const turnstileRequired = !!publicSettings.data?.turnstileEnabled if (me.data?.user) return return ( -
-
-
-

LanQin Email

+
+
+
+

LanQin Email

-
{ e.preventDefault(); if (!challengeToken && turnstileRequired && !turnstileToken) { toast({ title: "请先完成人机验证" }); return }; login.mutate(new FormData(e.currentTarget)) }}> - {!challengeToken ? ( - <> +
+
+ {challengeToken ? : } + {challengeToken ? "双因素验证" : "账号登录"} +
+ { e.preventDefault(); if (!challengeToken && turnstileRequired && !turnstileToken) { toast({ title: "请先完成人机验证" }); return }; login.mutate(new FormData(e.currentTarget)) }}> + {!challengeToken ? ( + <> +
+ + +
+
+ + +
+ + ) : (
- - + +
-
- - -
- - ) : ( -
- - -
- )} - {!challengeToken && turnstileRequired && ( - - )} - - {challengeToken && } - {!challengeToken && ( - + {challengeToken && } + +
+ {!challengeToken && ( +
+ 没有账号? + - )} - +
+ )}
) diff --git a/apps/web/src/pages/register.tsx b/apps/web/src/pages/register.tsx index 9384e77..d4ffcc4 100644 --- a/apps/web/src/pages/register.tsx +++ b/apps/web/src/pages/register.tsx @@ -1,6 +1,7 @@ import * as React from "react" import { Link, Navigate, useNavigate } from "react-router-dom" import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query" +import { ArrowLeft, ArrowRight, UserPlus } from "lucide-react" import { api } from "@/lib/api" import type { PublicDomain } from "@/lib/api" import { useMe } from "@/hooks/use-me" @@ -61,64 +62,78 @@ export function RegisterPage() { const turnstileRequired = !!publicSettings.data?.turnstileEnabled if (me.data?.user) return return ( -
-
-
-

注册账号

+
+
+
+

LanQin Email

- {publicSettings.isSuccess && !publicSettings.data.openRegistration ? ( -
-
当前未开放注册
- +
+ ) : ( +
{ e.preventDefault(); if (turnstileRequired && !turnstileToken) { toast({ title: "请先完成人机验证" }); return }; register.mutate(new FormData(e.currentTarget)) }}> + {domains.length > 0 ? ( +
+ +
+ + +
+
+ ) : ( +
+ + +
+ )} +
+ + +
+
+ + +
+
+ + +
+ {turnstileRequired && } + + + )} +
+ {!(publicSettings.isSuccess && !publicSettings.data.openRegistration) && ( +
+ 已有账号? +
- ) : ( -
{ e.preventDefault(); if (turnstileRequired && !turnstileToken) { toast({ title: "请先完成人机验证" }); return }; register.mutate(new FormData(e.currentTarget)) }}> - {domains.length > 0 ? ( -
- -
- - @ - -
-
- ) : ( -
- - -
- )} -
- - -
-
- - -
-
- - -
- {turnstileRequired && } - - - )}