From 13708483fc97a8e6891007ed2209035742f3df20 Mon Sep 17 00:00:00 2001 From: Eamon-meng <17516219072@163.com> Date: Wed, 13 Aug 2025 14:26:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E9=93=BE=E6=8E=A5=E5=AF=B9=E5=BA=94=E7=9A=84=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=A1=B5=E5=92=8C=E7=82=B9=E5=87=BB=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E7=9A=84=E8=93=9D=E7=8B=90=E4=BB=A3=E7=90=86=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E9=A6=96=E9=A1=B5=EF=BC=8C=E6=9C=AA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E8=8F=9C=E5=8D=95=E6=A0=8F=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E8=AE=A2=E8=B4=AD=E9=87=8C=E7=9A=84=E5=AF=BC=E8=88=AA=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(auth)/login/page.tsx | 38 ++++++++++++-------- src/app/(home)/@header/page.tsx | 2 +- src/components/composites/purchase/index.tsx | 6 ++-- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/app/(auth)/login/page.tsx b/src/app/(auth)/login/page.tsx index f48ba3b..d91a93b 100644 --- a/src/app/(auth)/login/page.tsx +++ b/src/app/(auth)/login/page.tsx @@ -1,5 +1,5 @@ 'use client' -import {useState, useCallback, useRef} from 'react' +import {useState, useCallback, useRef, useEffect} from 'react' import {Input} from '@/components/ui/input' import {Button} from '@/components/ui/button' import {Checkbox} from '@/components/ui/checkbox' @@ -50,13 +50,24 @@ type FormValues = zod.infer export default function LoginPage(props: LoginPageProps) { const router = useRouter() + const params = useSearchParams() const [submitting, setSubmitting] = useState(false) const [countdown, setCountdown] = useState(0) const [showCaptcha, setShowCaptcha] = useState(false) - const [loginMode, setLoginMode] = useState<'sms' | 'password'>('sms') + const [loginMode, setLoginMode] = useState<'sms' | 'password'>('password') const [showPwd, setShowPwd] = useState(false) const timerRef = useRef(undefined) + useEffect(() => { + const type = params.get('type') + if (type === 'sms') { + setLoginMode('sms') + } + else { + setLoginMode('password') + } + }, [params]) + const form = useForm({ resolver: zodResolver(loginMode === 'sms' ? smsSchema : pwdSchema), defaultValues: { @@ -218,7 +229,6 @@ export default function LoginPage(props: LoginPageProps) { // 重定向 // ====================== - const params = useSearchParams() const redirect = params.get('redirect') const refreshProfile = useProfileStore(store => store.refreshProfile) @@ -234,15 +244,15 @@ export default function LoginPage(props: LoginPageProps) { )}> 背景图 - logo + logo {/* 登录表单 */} - - + + {/* 登录/注册 - - + */} + {/* 登录方式切换 */} - - 验证码登录 - 密码登录 + + 验证码登录 + className="space-y-6" onSubmit={onSubmit} form={form}> - + {({id, field}) => ( )} @@ -341,7 +351,7 @@ export default function LoginPage(props: LoginPageProps) { theme="gradient" disabled={submitting} > - {submitting ? '登录中...' : (loginMode === 'sms' ? '注册 / 登录' : '登录')} + {submitting ? '登录中...' : (loginMode === 'sms' ? '首次登录即注册' : '立即登录')}

登录即表示您同意 diff --git a/src/app/(home)/@header/page.tsx b/src/app/(home)/@header/page.tsx index 65b8093..eb10bb4 100644 --- a/src/app/(home)/@header/page.tsx +++ b/src/app/(home)/@header/page.tsx @@ -173,7 +173,7 @@ export default function Page(props: ProviderProps) { 登录 { setCurrentTab(props.defaultType) - if (!profile) { - router.push('/login?redirect=/admin/purchase') // 未登录用户重定向到登录页 - } + // if (!profile) { + // router.push('/login?redirect=/admin/purchase') // 未登录用户重定向到登录页 + // } }, [props.defaultType, profile, router]) return (