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 (