暂无可用套餐时取消加载中 & 登录页加返回首页 & 加联系专属客服 & 修改白名单上限10个
This commit is contained in:
@@ -6,7 +6,7 @@ import {Card, CardContent} from '@/components/ui/card'
|
|||||||
import {Form, FormField} from '@/components/ui/form'
|
import {Form, FormField} from '@/components/ui/form'
|
||||||
import {Label} from '@/components/ui/label'
|
import {Label} from '@/components/ui/label'
|
||||||
import {Tabs, TabsList, TabsTrigger} from '@/components/ui/tabs'
|
import {Tabs, TabsList, TabsTrigger} from '@/components/ui/tabs'
|
||||||
import {EyeClosedIcon, EyeIcon} from 'lucide-react'
|
import {EyeClosedIcon, EyeIcon, HomeIcon} from 'lucide-react'
|
||||||
import {useState, ReactNode, useEffect, Suspense} from 'react'
|
import {useState, ReactNode, useEffect, Suspense} from 'react'
|
||||||
import zod from 'zod'
|
import zod from 'zod'
|
||||||
import {useForm, useFormContext, useWatch} from 'react-hook-form'
|
import {useForm, useFormContext, useWatch} from 'react-hook-form'
|
||||||
@@ -16,6 +16,7 @@ import {useRouter} from 'next/navigation'
|
|||||||
import {login, LoginMode} from '@/actions/auth'
|
import {login, LoginMode} from '@/actions/auth'
|
||||||
import {useProfileStore} from '@/components/stores/profile'
|
import {useProfileStore} from '@/components/stores/profile'
|
||||||
import dynamic from 'next/dynamic'
|
import dynamic from 'next/dynamic'
|
||||||
|
import Link from 'next/link'
|
||||||
|
|
||||||
const smsSchema = zod.object({
|
const smsSchema = zod.object({
|
||||||
username: zod.string().length(11, '请输入正确的手机号码'),
|
username: zod.string().length(11, '请输入正确的手机号码'),
|
||||||
@@ -88,111 +89,122 @@ export default function LoginCard() {
|
|||||||
const [showPwd, setShowPwd] = useState(false)
|
const [showPwd, setShowPwd] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="w-96 mx-4 shadow-lg relative z-20 py-8">
|
<div className="relative flex flex-col items-center">
|
||||||
<CardContent className="px-8">
|
<div className="relative w-96 mx-4">
|
||||||
{/* 登录方式切换 */}
|
<Link
|
||||||
<Tabs
|
href="/"
|
||||||
value={mode}
|
className="absolute -top-8 right-0 inline-flex items-center text-sm transition-colors"
|
||||||
onValueChange={(val) => {
|
>
|
||||||
setMode(val as LoginMode)
|
<HomeIcon size={18} className="mr-1"/>
|
||||||
form.reset({username: '', password: '', remember: false})
|
返回首页
|
||||||
form.clearErrors()
|
</Link>
|
||||||
}}
|
</div>
|
||||||
className="mb-6">
|
<Card className="w-96 mx-4 shadow-lg relative z-20 py-8">
|
||||||
<TabsList className="w-full p-0 bg-white">
|
<CardContent className="px-8">
|
||||||
<Tab value="password">密码登录</Tab>
|
{/* 登录方式切换 */}
|
||||||
<Tab value="phone_code">验证码登录/注册</Tab>
|
<Tabs
|
||||||
</TabsList>
|
value={mode}
|
||||||
</Tabs>
|
onValueChange={(val) => {
|
||||||
<Form<LoginSchema> className="space-y-6" form={form} handler={handler}>
|
setMode(val as LoginMode)
|
||||||
<FormField name="username" label={mode === 'phone_code' ? '手机号' : '用户名'}>
|
form.reset({username: '', password: '', remember: false})
|
||||||
{({id, field}) => (
|
form.clearErrors()
|
||||||
<Input
|
}}
|
||||||
{...field}
|
className="mb-6">
|
||||||
id={id}
|
<TabsList className="w-full p-0 bg-white">
|
||||||
type="tel"
|
<Tab value="password">密码登录</Tab>
|
||||||
placeholder={mode === 'phone_code' ? '请输入手机号' : '请输入用户名/手机号/邮箱'}
|
<Tab value="phone_code">验证码登录/注册</Tab>
|
||||||
autoComplete="tel-national"
|
</TabsList>
|
||||||
/>
|
</Tabs>
|
||||||
)}
|
<Form<LoginSchema> className="space-y-6" form={form} handler={handler}>
|
||||||
</FormField>
|
<FormField name="username" label={mode === 'phone_code' ? '手机号' : '用户名'}>
|
||||||
<FormField name="password" label={mode === 'phone_code' ? '验证码' : '密码'}>
|
{({id, field}) => (
|
||||||
{({id, field}) =>
|
<Input
|
||||||
mode === 'phone_code' ? (
|
{...field}
|
||||||
<div className="flex space-x-4">
|
|
||||||
<Input
|
|
||||||
{...field}
|
|
||||||
id={id}
|
|
||||||
className="h-10"
|
|
||||||
placeholder="请输入验证码"
|
|
||||||
autoComplete="one-time-code"
|
|
||||||
disabled={submitting}
|
|
||||||
/>
|
|
||||||
<SendMsgByUsername/>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="relative">
|
|
||||||
<Input
|
|
||||||
{...field}
|
|
||||||
id={id}
|
|
||||||
type={showPwd ? 'text' : 'password'}
|
|
||||||
className="h-10 pr-10"
|
|
||||||
placeholder="至少6位密码,需包含字母和数字"
|
|
||||||
autoComplete="current-password"
|
|
||||||
minLength={6}
|
|
||||||
disabled={submitting}
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
tabIndex={-1}
|
|
||||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 cursor-pointer"
|
|
||||||
onClick={() => setShowPwd(v => !v)}
|
|
||||||
aria-label={showPwd ? '隐藏密码' : '显示密码'}
|
|
||||||
>
|
|
||||||
{showPwd ? (
|
|
||||||
<EyeIcon size={20}/>
|
|
||||||
) : (
|
|
||||||
<EyeClosedIcon size={20}/>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</FormField>
|
|
||||||
<FormField name="remember">
|
|
||||||
{({id, field}) => (
|
|
||||||
<div className="flex flex-row items-start space-x-2 space-y-0">
|
|
||||||
<Checkbox
|
|
||||||
id={id}
|
id={id}
|
||||||
checked={field.value}
|
type="tel"
|
||||||
onCheckedChange={field.onChange}
|
placeholder={mode === 'phone_code' ? '请输入手机号' : '请输入用户名/手机号/邮箱'}
|
||||||
disabled={submitting}
|
autoComplete="tel-national"
|
||||||
/>
|
/>
|
||||||
<div className="space-y-1 leading-none">
|
)}
|
||||||
<Label>保持登录</Label>
|
</FormField>
|
||||||
|
<FormField name="password" label={mode === 'phone_code' ? '验证码' : '密码'}>
|
||||||
|
{({id, field}) =>
|
||||||
|
mode === 'phone_code' ? (
|
||||||
|
<div className="flex space-x-4">
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id={id}
|
||||||
|
className="h-10"
|
||||||
|
placeholder="请输入验证码"
|
||||||
|
autoComplete="one-time-code"
|
||||||
|
disabled={submitting}
|
||||||
|
/>
|
||||||
|
<SendMsgByUsername/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="relative">
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id={id}
|
||||||
|
type={showPwd ? 'text' : 'password'}
|
||||||
|
className="h-10 pr-10"
|
||||||
|
placeholder="至少6位密码,需包含字母和数字"
|
||||||
|
autoComplete="current-password"
|
||||||
|
minLength={6}
|
||||||
|
disabled={submitting}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
tabIndex={-1}
|
||||||
|
className="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 cursor-pointer"
|
||||||
|
onClick={() => setShowPwd(v => !v)}
|
||||||
|
aria-label={showPwd ? '隐藏密码' : '显示密码'}
|
||||||
|
>
|
||||||
|
{showPwd ? (
|
||||||
|
<EyeIcon size={20}/>
|
||||||
|
) : (
|
||||||
|
<EyeClosedIcon size={20}/>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</FormField>
|
||||||
|
<FormField name="remember">
|
||||||
|
{({id, field}) => (
|
||||||
|
<div className="flex flex-row items-start space-x-2 space-y-0">
|
||||||
|
<Checkbox
|
||||||
|
id={id}
|
||||||
|
checked={field.value}
|
||||||
|
onCheckedChange={field.onChange}
|
||||||
|
disabled={submitting}
|
||||||
|
/>
|
||||||
|
<div className="space-y-1 leading-none">
|
||||||
|
<Label>保持登录</Label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
)}
|
</FormField>
|
||||||
</FormField>
|
<div className="flex flex-col gap-3">
|
||||||
<div className="flex flex-col gap-3">
|
<Button
|
||||||
<Button
|
className="w-full h-12 text-lg"
|
||||||
className="w-full h-12 text-lg"
|
type="submit"
|
||||||
type="submit"
|
theme="gradient"
|
||||||
theme="gradient"
|
disabled={submitting}
|
||||||
disabled={submitting}
|
>
|
||||||
>
|
{submitting ? '登录中...' : (mode === 'phone_code' ? '首次登录即注册' : '立即登录')}
|
||||||
{submitting ? '登录中...' : (mode === 'phone_code' ? '首次登录即注册' : '立即登录')}
|
</Button>
|
||||||
</Button>
|
<p className="text-xs text-center text-gray-500">
|
||||||
<p className="text-xs text-center text-gray-500">
|
登录即表示您同意
|
||||||
登录即表示您同意
|
<a href="/userAgreement" className="text-blue-600 hover:text-blue-500">《用户协议》</a>
|
||||||
<a href="/userAgreement" className="text-blue-600 hover:text-blue-500">《用户协议》</a>
|
和
|
||||||
和
|
<a href="/privacyPolicy" className="text-blue-600 hover:text-blue-500">《隐私政策》</a>
|
||||||
<a href="/privacyPolicy" className="text-blue-600 hover:text-blue-500">《隐私政策》</a>
|
</p>
|
||||||
</p>
|
</div>
|
||||||
</div>
|
</Form>
|
||||||
</Form>
|
</CardContent>
|
||||||
</CardContent>
|
</Card>
|
||||||
</Card>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {RealnameAuthDialog} from '@/components/composites/dialogs/realname-auth-
|
|||||||
import UserCenter from '@/components/composites/user-center'
|
import UserCenter from '@/components/composites/user-center'
|
||||||
import {Button} from '@/components/ui/button'
|
import {Button} from '@/components/ui/button'
|
||||||
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from '@/components/ui/tooltip'
|
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from '@/components/ui/tooltip'
|
||||||
import {Archive, ArchiveRestore, Eye, HardDriveUpload, IdCard, LockKeyhole, Package, PanelLeftCloseIcon, PanelLeftOpenIcon, ShoppingCart, UserRound, UserRoundPen, Wallet} from 'lucide-react'
|
import {Archive, ArchiveRestore, Eye, HardDriveUpload, IdCard, LockKeyhole, MessageCircleMoreIcon, Package, PanelLeftCloseIcon, PanelLeftOpenIcon, ShoppingCart, UserRound, UserRoundPen, Wallet} from 'lucide-react'
|
||||||
import {merge} from '@/lib/utils'
|
import {merge} from '@/lib/utils'
|
||||||
import logoAvatar from '@/assets/logo-avatar.svg'
|
import logoAvatar from '@/assets/logo-avatar.svg'
|
||||||
import logoText from '@/assets/logo-text.svg'
|
import logoText from '@/assets/logo-text.svg'
|
||||||
@@ -126,6 +126,16 @@ export function Header() {
|
|||||||
<IdCard size={16}/>
|
<IdCard size={16}/>
|
||||||
<span>实名认证</span>
|
<span>实名认证</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
<div className="max-md:hidden h-5 w-px bg-gray-300 mx-2"/>
|
||||||
|
<a
|
||||||
|
href="https://wpa1.qq.com/K0s0cvwf?_type=wpa&qidian=true"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="max-md:hidden flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-800 transition-colors mr-2"
|
||||||
|
>
|
||||||
|
<MessageCircleMoreIcon size={16}/>
|
||||||
|
<span>联系专属客服</span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex-none flex items-center justify-end pr-4 max-md:hidden gap-3">
|
<div className="flex-none flex items-center justify-end pr-4 max-md:hidden gap-3">
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ type SchemaType = z.infer<typeof schema>
|
|||||||
|
|
||||||
export type WhitelistPageProps = {}
|
export type WhitelistPageProps = {}
|
||||||
|
|
||||||
const MAX_WHITELIST_COUNT = 5
|
const MAX_WHITELIST_COUNT = 10
|
||||||
|
|
||||||
export default function WhitelistPage(props: WhitelistPageProps) {
|
export default function WhitelistPage(props: WhitelistPageProps) {
|
||||||
const [wait, setWait] = useState(false)
|
const [wait, setWait] = useState(false)
|
||||||
|
|||||||
@@ -379,12 +379,10 @@ function SelectResource() {
|
|||||||
</div>
|
</div>
|
||||||
) : !profile ? (
|
) : !profile ? (
|
||||||
<div className="p-4 flex gap-1 items-center">
|
<div className="p-4 flex gap-1 items-center">
|
||||||
{/* <Loader className="animate-spin" size={20}/> */}
|
|
||||||
<span className="text-gray-600">请先登录账号,<Link href="/login" className="text-blue-600 hover:text-blue-700 font-medium">去登录</Link></span>
|
<span className="text-gray-600">请先登录账号,<Link href="/login" className="text-blue-600 hover:text-blue-700 font-medium">去登录</Link></span>
|
||||||
</div>
|
</div>
|
||||||
) : resources.length === 0 ? (
|
) : resources.length === 0 ? (
|
||||||
<div className="p-4 flex gap-1 items-center">
|
<div className="p-4 flex gap-1 items-center">
|
||||||
<Loader className="animate-spin" size={20}/>
|
|
||||||
<span>暂无可用套餐</span>
|
<span>暂无可用套餐</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export default function Purchase() {
|
|||||||
const res = profile
|
const res = profile
|
||||||
? await listProduct({})
|
? await listProduct({})
|
||||||
: await listProductHome({})
|
: await listProductHome({})
|
||||||
console.log(res, 'res')
|
|
||||||
|
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
setProductList(res.data)
|
setProductList(res.data)
|
||||||
|
|||||||
@@ -167,14 +167,14 @@ export default function Center({skuData}: {
|
|||||||
<NumberStepperField
|
<NumberStepperField
|
||||||
name="daily_limit"
|
name="daily_limit"
|
||||||
label="每日提取上限"
|
label="每日提取上限"
|
||||||
min={currentCountMin || 100}
|
min={currentCountMin}
|
||||||
step={100}
|
step={100}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<NumberStepperField
|
<NumberStepperField
|
||||||
name="quota"
|
name="quota"
|
||||||
label="IP 购买数量"
|
label="IP 购买数量"
|
||||||
min={currentCountMin || 500}
|
min={currentCountMin}
|
||||||
step={100}
|
step={100}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import {PurchaseSidePanel} from '../shared/side-panel'
|
|||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
type: z.enum(['1', '2']).default('2'),
|
type: z.enum(['1', '2']).default('2'),
|
||||||
live: z.string(),
|
live: z.string(),
|
||||||
quota: z.number().min(500, '购买数量不能少于 500 个'),
|
quota: z.number().min(1, '购买数量不能少于 1 个'),
|
||||||
expire: z.string(),
|
expire: z.string(),
|
||||||
daily_limit: z.number().min(100, '每日限额不能少于 100 个'),
|
daily_limit: z.number().min(1, '每日限额不能少于 1 个'),
|
||||||
pay_type: z.enum(['wechat', 'alipay', 'balance']),
|
pay_type: z.enum(['wechat', 'alipay', 'balance']),
|
||||||
})
|
})
|
||||||
export type Schema = z.infer<typeof schema>
|
export type Schema = z.infer<typeof schema>
|
||||||
@@ -37,8 +37,8 @@ export default function LongForm({skuList}: {skuList: ProductItem['skus']}) {
|
|||||||
type: defaultMode,
|
type: defaultMode,
|
||||||
live: defaultLive,
|
live: defaultLive,
|
||||||
expire: defaultExpire,
|
expire: defaultExpire,
|
||||||
quota: defaultMode === '2' ? Math.max(defaultCountMin, 500) : 500,
|
quota: defaultCountMin,
|
||||||
daily_limit: defaultMode === '1' ? Math.max(defaultCountMin, 100) : 100,
|
daily_limit: defaultCountMin,
|
||||||
pay_type: 'balance', // 余额支付
|
pay_type: 'balance', // 余额支付
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ export default function Center({
|
|||||||
}: {
|
}: {
|
||||||
skuData: PurchaseSkuData
|
skuData: PurchaseSkuData
|
||||||
}) {
|
}) {
|
||||||
// const {setValue} = useFormContext<Schema>()
|
|
||||||
const {setValue, getValues} = useFormContext<Schema>()
|
const {setValue, getValues} = useFormContext<Schema>()
|
||||||
const type = useWatch<Schema>({name: 'type'}) as Schema['type']
|
const type = useWatch<Schema>({name: 'type'}) as Schema['type']
|
||||||
const live = useWatch<Schema>({name: 'live'}) as Schema['live']
|
const live = useWatch<Schema>({name: 'live'}) as Schema['live']
|
||||||
@@ -34,18 +33,13 @@ export default function Center({
|
|||||||
const expireValue = type === '1' ? expire : '0'
|
const expireValue = type === '1' ? expire : '0'
|
||||||
return getPurchaseSkuCountMin(skuData, {mode: type, live, expire: expireValue})
|
return getPurchaseSkuCountMin(skuData, {mode: type, live, expire: expireValue})
|
||||||
}, [type, live, expire, skuData])
|
}, [type, live, expire, skuData])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (type === '1') {
|
if (currentCountMin <= 0) return
|
||||||
const current = getValues('daily_limit')
|
const targetField = type === '1' ? 'daily_limit' : 'quota'
|
||||||
if (current < currentCountMin) {
|
const currentValue = getValues(targetField)
|
||||||
setValue('daily_limit', currentCountMin)
|
if (currentValue < currentCountMin) {
|
||||||
}
|
setValue(targetField, currentCountMin, {shouldValidate: true})
|
||||||
}
|
|
||||||
else {
|
|
||||||
const current = getValues('quota')
|
|
||||||
if (current < currentCountMin) {
|
|
||||||
setValue('quota', currentCountMin)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [currentCountMin, type, setValue, getValues])
|
}, [currentCountMin, type, setValue, getValues])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -171,14 +165,14 @@ export default function Center({
|
|||||||
<NumberStepperField
|
<NumberStepperField
|
||||||
name="daily_limit"
|
name="daily_limit"
|
||||||
label="每日提取上限"
|
label="每日提取上限"
|
||||||
min={currentCountMin || 2000}
|
min={currentCountMin}
|
||||||
step={1000}
|
step={1000}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<NumberStepperField
|
<NumberStepperField
|
||||||
name="quota"
|
name="quota"
|
||||||
label="IP 购买数量"
|
label="IP 购买数量"
|
||||||
min={currentCountMin || 10000}
|
min={currentCountMin}
|
||||||
step={5000}
|
step={5000}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import {PurchaseSidePanel} from '../shared/side-panel'
|
|||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
type: z.enum(['1', '2']).default('2'),
|
type: z.enum(['1', '2']).default('2'),
|
||||||
live: z.string(),
|
live: z.string(),
|
||||||
quota: z.number().min(10000, '购买数量不能少于 10000 个'),
|
quota: z.number(),
|
||||||
expire: z.string(),
|
expire: z.string(),
|
||||||
daily_limit: z.number().min(2000, '每日限额不能少于 2000 个'),
|
daily_limit: z.number(),
|
||||||
pay_type: z.enum(['wechat', 'alipay', 'balance']).default('balance'),
|
pay_type: z.enum(['wechat', 'alipay', 'balance']).default('balance'),
|
||||||
})
|
})
|
||||||
export type Schema = z.infer<typeof schema>
|
export type Schema = z.infer<typeof schema>
|
||||||
@@ -30,14 +30,15 @@ export default function ShortForm({skuList}: {skuList: ProductItem['skus']}) {
|
|||||||
live: defaultLive,
|
live: defaultLive,
|
||||||
expire: defaultExpire,
|
expire: defaultExpire,
|
||||||
})
|
})
|
||||||
|
|
||||||
const form = useForm<Schema>({
|
const form = useForm<Schema>({
|
||||||
resolver: zodResolver(schema),
|
resolver: zodResolver(schema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
type: defaultMode,
|
type: defaultMode,
|
||||||
live: defaultLive,
|
live: defaultLive,
|
||||||
expire: defaultExpire,
|
expire: defaultExpire,
|
||||||
quota: defaultMode === '2' ? defaultCountMin || 10000 : 10000,
|
quota: defaultCountMin,
|
||||||
daily_limit: defaultMode === '1' ? defaultCountMin || 2000 : 2000,
|
daily_limit: defaultCountMin,
|
||||||
pay_type: 'balance', // 余额支付
|
pay_type: 'balance', // 余额支付
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user