修改登录页面链接对应的登录页和点击登录页的蓝狐代理跳转首页,未登录点击菜单栏产品订购里的导航页面校验
This commit is contained in:
@@ -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<typeof smsSchema>
|
||||
|
||||
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<NodeJS.Timeout>(undefined)
|
||||
|
||||
useEffect(() => {
|
||||
const type = params.get('type')
|
||||
if (type === 'sms') {
|
||||
setLoginMode('sms')
|
||||
}
|
||||
else {
|
||||
setLoginMode('password')
|
||||
}
|
||||
}, [params])
|
||||
|
||||
const form = useForm<FormValues>({
|
||||
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) {
|
||||
)}>
|
||||
<Image src={bg} alt="背景图" fill priority className="absolute -z-20 object-cover"/>
|
||||
<Link href="/">
|
||||
<Image src={logo} alt="logo" priority height={64} className="absolute top-8 left-8 -z-10"/>
|
||||
<Image src={logo} alt="logo" priority height={64} className="absolute top-8 left-8 z-10"/>
|
||||
</Link>
|
||||
|
||||
{/* 登录表单 */}
|
||||
<Card className="w-96 mx-4 shadow-lg">
|
||||
<CardHeader className="text-center">
|
||||
<Card className="w-110 mx-4 shadow-lg">
|
||||
{/* <CardHeader className="text-center">
|
||||
<CardTitle className="text-2xl">登录/注册</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="px-8">
|
||||
</CardHeader> */}
|
||||
<CardContent className="px-12 py-12">
|
||||
{/* 登录方式切换 */}
|
||||
<Tabs
|
||||
value={loginMode}
|
||||
@@ -252,22 +262,22 @@ export default function LoginPage(props: LoginPageProps) {
|
||||
}}
|
||||
className="mb-6">
|
||||
<TabsList className="w-full h-10 flex justify-center gap-2">
|
||||
<TabsTrigger value="sms" className="flex-1">
|
||||
验证码登录
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="password" className="flex-1">
|
||||
密码登录
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="sms" className="flex-1">
|
||||
验证码登录
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
<Form<FormValues> className="space-y-6" onSubmit={onSubmit} form={form}>
|
||||
<FormField name="username" label="手机号码">
|
||||
<FormField name="username" label={loginMode === 'sms' ? '手机号' : '用户名'}>
|
||||
{({id, field}) => (
|
||||
<Input
|
||||
{...field}
|
||||
id={id}
|
||||
type="tel"
|
||||
placeholder="请输入手机号码"
|
||||
placeholder="请输入手机号"
|
||||
autoComplete="tel-national"
|
||||
/>
|
||||
)}
|
||||
@@ -341,7 +351,7 @@ export default function LoginPage(props: LoginPageProps) {
|
||||
theme="gradient"
|
||||
disabled={submitting}
|
||||
>
|
||||
{submitting ? '登录中...' : (loginMode === 'sms' ? '注册 / 登录' : '登录')}
|
||||
{submitting ? '登录中...' : (loginMode === 'sms' ? '首次登录即注册' : '立即登录')}
|
||||
</Button>
|
||||
<p className="text-xs text-center text-gray-500">
|
||||
登录即表示您同意
|
||||
|
||||
@@ -173,7 +173,7 @@ export default function Page(props: ProviderProps) {
|
||||
<span>登录</span>
|
||||
</Link>
|
||||
<Link
|
||||
href="/login"
|
||||
href="/login?type=sms"
|
||||
className={[
|
||||
`w-20 lg:w-24 h-10 lg:h-12 bg-gradient-to-r rounded-sm flex items-center justify-center lg:text-lg text-white`,
|
||||
`transition-colors duration-200 ease-in-out`,
|
||||
|
||||
@@ -18,9 +18,9 @@ export default function Purchase(props: PurchaseProps) {
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
setCurrentTab(props.defaultType)
|
||||
if (!profile) {
|
||||
router.push('/login?redirect=/admin/purchase') // 未登录用户重定向到登录页
|
||||
}
|
||||
// if (!profile) {
|
||||
// router.push('/login?redirect=/admin/purchase') // 未登录用户重定向到登录页
|
||||
// }
|
||||
}, [props.defaultType, profile, router])
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user