Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
165151b9d2 | ||
|
|
1e76275f04 | ||
|
|
d9cd5eb41b | ||
|
|
7ff42861f1 | ||
|
|
eb4c2d2d5f | ||
| a0b0956677 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lanhu-web",
|
"name": "lanhu-web",
|
||||||
"version": "1.8.0",
|
"version": "1.10.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -H 0.0.0.0 --turbopack",
|
"dev": "next dev -H 0.0.0.0 --turbopack",
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ if ($confrim -ne "y") {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
docker build -t repo.lanhuip.com:8554/lanhu/web:latest .
|
docker build -t repo.lanhuip.com/lanhu/web:latest .
|
||||||
docker build -t repo.lanhuip.com:8554/lanhu/web:$($args[0]) .
|
docker build -t repo.lanhuip.com/lanhu/web:$($args[0]) .
|
||||||
|
|
||||||
docker push repo.lanhuip.com:8554/lanhu/web:latest
|
docker push repo.lanhuip.com/lanhu/web:latest
|
||||||
docker push repo.lanhuip.com:8554/lanhu/web:$($args[0])
|
docker push repo.lanhuip.com/lanhu/web:$($args[0])
|
||||||
|
|||||||
@@ -103,3 +103,10 @@ export async function getPriceHome(props: CreateResourceReq) {
|
|||||||
discounted?: string
|
discounted?: string
|
||||||
}>('/api/resource/price', props)
|
}>('/api/resource/price', props)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function updateCheckip(props: {
|
||||||
|
id: number
|
||||||
|
checkip: boolean
|
||||||
|
}) {
|
||||||
|
return callByUser('/api/resource/update/checkip', props)
|
||||||
|
}
|
||||||
|
|||||||
@@ -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,6 +89,16 @@ export default function LoginCard() {
|
|||||||
const [showPwd, setShowPwd] = useState(false)
|
const [showPwd, setShowPwd] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div className="relative flex flex-col items-center">
|
||||||
|
<div className="relative w-96 mx-4">
|
||||||
|
<Link
|
||||||
|
href="/"
|
||||||
|
className="absolute -top-8 right-0 inline-flex items-center text-sm transition-colors px-10"
|
||||||
|
>
|
||||||
|
<HomeIcon size={18} className="mr-1"/>
|
||||||
|
返回首页
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
<Card className="w-96 mx-4 shadow-lg relative z-20 py-8">
|
<Card className="w-96 mx-4 shadow-lg relative z-20 py-8">
|
||||||
<CardContent className="px-8">
|
<CardContent className="px-8">
|
||||||
{/* 登录方式切换 */}
|
{/* 登录方式切换 */}
|
||||||
@@ -193,6 +204,7 @@ export default function LoginCard() {
|
|||||||
</Form>
|
</Form>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ export default function CustomPage() {
|
|||||||
<section className="relative rounded-lg overflow-hidden h-48 lg:h-56">
|
<section className="relative rounded-lg overflow-hidden h-48 lg:h-56">
|
||||||
<Image
|
<Image
|
||||||
src={group}
|
src={group}
|
||||||
alt="免费试用背景"
|
alt="立即试用背景"
|
||||||
fill
|
fill
|
||||||
className="object-cover"
|
className="object-cover"
|
||||||
priority
|
priority
|
||||||
@@ -251,9 +251,9 @@ export default function CustomPage() {
|
|||||||
className={merge(
|
className={merge(
|
||||||
'bg-blue-600 hover:bg-blue-700 text-white px-8 py-3 rounded-md whitespace-nowrap',
|
'bg-blue-600 hover:bg-blue-700 text-white px-8 py-3 rounded-md whitespace-nowrap',
|
||||||
)}
|
)}
|
||||||
onClick={() => router.push('/login')}
|
onClick={() => router.push('/product')}
|
||||||
>
|
>
|
||||||
免费试用
|
立即试用
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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'
|
||||||
@@ -93,7 +93,8 @@ function ContentResolved() {
|
|||||||
export function Header() {
|
export function Header() {
|
||||||
const navbar = useLayoutStore(store => store.navbar)
|
const navbar = useLayoutStore(store => store.navbar)
|
||||||
const toggleNavbar = useLayoutStore(store => store.toggleNavbar)
|
const toggleNavbar = useLayoutStore(store => store.toggleNavbar)
|
||||||
|
const profile = use(useProfileStore(store => store.profile))
|
||||||
|
const showRealnameAuth = profile?.id_type === 0
|
||||||
return (
|
return (
|
||||||
<header className={merge(
|
<header className={merge(
|
||||||
`flex-none h-16 overflow-hidden`,
|
`flex-none h-16 overflow-hidden`,
|
||||||
@@ -103,12 +104,23 @@ export function Header() {
|
|||||||
<div className="flex-auto flex items-center gap-2">
|
<div className="flex-auto flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
theme="ghost"
|
theme="ghost"
|
||||||
className="w-9 h-9 ml-4 md:ml-0"
|
className="h-9 ml-4 md:ml-0"
|
||||||
onClick={toggleNavbar}>
|
onClick={toggleNavbar}>
|
||||||
{navbar ? <PanelLeftCloseIcon/> : <PanelLeftOpenIcon/>}
|
{navbar ? (
|
||||||
|
<>
|
||||||
|
<PanelLeftCloseIcon/>
|
||||||
|
<span className="text-foreground/90">关闭菜单</span>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<PanelLeftOpenIcon/>
|
||||||
|
<span className="text-foreground/90">打开菜单</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
<span className="max-md:hidden">欢迎来到,蓝狐代理</span>
|
<span className="max-md:hidden">欢迎来到,蓝狐代理</span>
|
||||||
<div className="max-md:hidden h-5 w-px bg-gray-300 mx-2"/>
|
<div className="max-md:hidden h-5 w-px bg-gray-300 mx-2"/>
|
||||||
|
{showRealnameAuth ? (
|
||||||
<Link
|
<Link
|
||||||
href="/admin/identify"
|
href="/admin/identify"
|
||||||
className="max-md:hidden flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-800 transition-colors"
|
className="max-md:hidden flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-800 transition-colors"
|
||||||
@@ -116,6 +128,25 @@ export function Header() {
|
|||||||
<IdCard size={16}/>
|
<IdCard size={16}/>
|
||||||
<span>实名认证</span>
|
<span>实名认证</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
) : (
|
||||||
|
<Link
|
||||||
|
href=""
|
||||||
|
className="max-md:hidden flex items-center gap-1.5 text-sm text-green-400 hover:text-green-400 transition-colors"
|
||||||
|
>
|
||||||
|
<IdCard size={16}/>
|
||||||
|
<span>已实名</span>
|
||||||
|
</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">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {ReactNode} from 'react'
|
import {ReactNode, Suspense} from 'react'
|
||||||
import {Shell, Content, Header, Navbar, Mask} from './clients'
|
import {Shell, Content, Header, Navbar, Mask} from './clients'
|
||||||
|
|
||||||
export default function Template(props: {
|
export default function Template(props: {
|
||||||
@@ -13,7 +13,9 @@ export default function Template(props: {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-start-2 row-start-1 bg-card overflow-hidden relative z-20">
|
<div className="col-start-2 row-start-1 bg-card overflow-hidden relative z-20">
|
||||||
|
<Suspense>
|
||||||
<Header/>
|
<Header/>
|
||||||
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<svg className="col-start-2 row-start-2 w-full h-full z-20 pointer-events-none" preserveAspectRatio="none">
|
<svg className="col-start-2 row-start-2 w-full h-full z-20 pointer-events-none" preserveAspectRatio="none">
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import zod from 'zod'
|
|||||||
import {toast} from 'sonner'
|
import {toast} from 'sonner'
|
||||||
import {useStatus} from '@/lib/states'
|
import {useStatus} from '@/lib/states'
|
||||||
import {ExtraResp} from '@/lib/api'
|
import {ExtraResp} from '@/lib/api'
|
||||||
import {listResourceLong, listResourceShort} from '@/actions/resource'
|
import {listResourceLong, listResourceShort, updateCheckip} from '@/actions/resource'
|
||||||
import DataTable from '@/components/data-table'
|
import DataTable from '@/components/data-table'
|
||||||
import {ColumnDef} from '@tanstack/react-table'
|
import {ColumnDef} from '@tanstack/react-table'
|
||||||
import {Resource} from '@/lib/models/resource'
|
import {Resource} from '@/lib/models/resource'
|
||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
isValidResourceType,
|
isValidResourceType,
|
||||||
ResourceTypeBadge,
|
ResourceTypeBadge,
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
import {Button} from '@/components/ui/button'
|
||||||
|
|
||||||
const filterSchema = zod.object({
|
const filterSchema = zod.object({
|
||||||
resource_no: zod.string().optional().default(''),
|
resource_no: zod.string().optional().default(''),
|
||||||
@@ -130,11 +131,32 @@ export default function ResourceList({resourceType}: ResourceListProps) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleCheckipChange = async (id: number, currentCheckip: boolean) => {
|
||||||
|
try {
|
||||||
|
const result = await updateCheckip({
|
||||||
|
id: id,
|
||||||
|
checkip: !currentCheckip,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
toast.success(`IP检查已${!currentCheckip ? '启用' : '停用'}`)
|
||||||
|
await refresh(data.page, data.size)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error(result.message || '操作失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
toast.error(e instanceof Error ? e.message : '更新IP检查状态失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(data.list, 'data.list')
|
||||||
|
|
||||||
// 表格列定义
|
// 表格列定义
|
||||||
const columns = useMemo<ColumnDef<Resource<1> | Resource<2>>[]>(() => {
|
const columns = useMemo<ColumnDef<Resource<1> | Resource<2>>[]>(() => {
|
||||||
const resourceKey = isLong ? 'long' : 'short'
|
const resourceKey = isLong ? 'long' : 'short'
|
||||||
|
|
||||||
const baseColumns: ColumnDef<Resource<1> | Resource<2>>[] = [
|
const baseColumns = ([
|
||||||
{
|
{
|
||||||
header: '套餐编号',
|
header: '套餐编号',
|
||||||
cell: ({row}) => {
|
cell: ({row}) => {
|
||||||
@@ -218,7 +240,11 @@ export default function ResourceList({resourceType}: ResourceListProps) {
|
|||||||
{
|
{
|
||||||
header: '开通时间',
|
header: '开通时间',
|
||||||
cell: ({row}) => formatDateTime(row.original.created_at),
|
cell: ({row}) => formatDateTime(row.original.created_at),
|
||||||
},
|
}, // 短效资源增加到期时间列
|
||||||
|
!isLong ? {
|
||||||
|
header: '到期时间',
|
||||||
|
cell: ({row}) => formatDateTime((row.original as Resource<1>).short.expire_at),
|
||||||
|
} : undefined,
|
||||||
{
|
{
|
||||||
header: '状态',
|
header: '状态',
|
||||||
cell: ({row}) => {
|
cell: ({row}) => {
|
||||||
@@ -230,15 +256,22 @@ export default function ResourceList({resourceType}: ResourceListProps) {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
{
|
||||||
|
header: '操作',
|
||||||
// 短效资源增加到期时间列
|
cell: ({row}) => {
|
||||||
if (!isLong) {
|
const checkip = row.original.checkip
|
||||||
baseColumns.push({
|
return (
|
||||||
header: '到期时间',
|
<Button
|
||||||
cell: ({row}) => formatDateTime((row.original as Resource<1>).short.expire_at),
|
theme="default"
|
||||||
})
|
className="h-7 px-3 text-sm"
|
||||||
}
|
onClick={() => handleCheckipChange(row.original.id, row.original.checkip)}
|
||||||
|
>
|
||||||
|
{checkip ? '停用IP检查' : '启用IP检查'}
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
] satisfies ((ColumnDef<Resource<1> | Resource<2>> | undefined)[])).filter(Boolean) as ColumnDef<Resource<1> | Resource<2>>[]
|
||||||
|
|
||||||
return baseColumns
|
return baseColumns
|
||||||
}, [isLong])
|
}, [isLong])
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -29,36 +29,32 @@ export default function Center({skuData}: {
|
|||||||
const currentCountMin = useMemo(() => {
|
const currentCountMin = useMemo(() => {
|
||||||
if (!type || !live) return 0
|
if (!type || !live) return 0
|
||||||
const expireValue = type === '1' ? expire : '0'
|
const expireValue = type === '1' ? expire : '0'
|
||||||
return getPurchaseSkuCountMin(skuData, {mode: type, live, expire: expireValue})
|
const countMin = getPurchaseSkuCountMin(skuData, {
|
||||||
|
mode: type,
|
||||||
|
live,
|
||||||
|
expire: expireValue,
|
||||||
|
})
|
||||||
|
return countMin
|
||||||
}, [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(() => {
|
||||||
const nextType = modeList.includes(type) ? type : modeList[0]
|
const nextType = modeList.includes(type) ? type : modeList[0]
|
||||||
|
|
||||||
if (!nextType) {
|
if (!nextType) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextType !== type) {
|
if (nextType !== type) {
|
||||||
setValue('type', nextType)
|
setValue('type', nextType)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextLiveList = nextType === '1'
|
const nextLiveList = nextType === '1'
|
||||||
? getAvailablePurchaseLives(skuData, {mode: nextType, expire})
|
? getAvailablePurchaseLives(skuData, {mode: nextType, expire})
|
||||||
: getAvailablePurchaseLives(skuData, {mode: nextType})
|
: getAvailablePurchaseLives(skuData, {mode: nextType})
|
||||||
@@ -167,14 +163,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', // 余额支付
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function BillingMethodField(props: {
|
|||||||
modeList: PurchaseMode[]
|
modeList: PurchaseMode[]
|
||||||
timeDailyLimit: number
|
timeDailyLimit: number
|
||||||
}) {
|
}) {
|
||||||
const {setValue} = useFormContext<PurchaseFormValues>()
|
const {setValue, getValues} = useFormContext<PurchaseFormValues>()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormField<PurchaseFormValues, 'type'>
|
<FormField<PurchaseFormValues, 'type'>
|
||||||
@@ -30,8 +30,7 @@ export function BillingMethodField(props: {
|
|||||||
setValue('expire', '0')
|
setValue('expire', '0')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
setValue('expire', getValues('expire') || '0')
|
||||||
setValue('daily_limit', props.timeDailyLimit)
|
|
||||||
}}
|
}}
|
||||||
className="flex gap-4 max-md:flex-col"
|
className="flex gap-4 max-md:flex-col"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -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,15 @@ 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')
|
|
||||||
if (current < currentCountMin) {
|
const targetField = type === '1' ? 'daily_limit' : 'quota'
|
||||||
setValue('daily_limit', currentCountMin)
|
const currentValue = getValues(targetField)
|
||||||
}
|
|
||||||
}
|
if (currentValue !== currentCountMin) {
|
||||||
else {
|
setValue(targetField, currentCountMin, {shouldValidate: true})
|
||||||
const current = getValues('quota')
|
|
||||||
if (current < currentCountMin) {
|
|
||||||
setValue('quota', currentCountMin)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [currentCountMin, type, setValue, getValues])
|
}, [currentCountMin, type, setValue, getValues])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -171,14 +167,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', // 余额支付
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function Resolved(props: {
|
|||||||
router.push(profile ? '/admin/purchase' : '/product')
|
router.push(profile ? '/admin/purchase' : '/product')
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
免费试用
|
立即试用
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ function Pending(props: {
|
|||||||
router.push('/product')
|
router.push('/product')
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
免费试用
|
立即试用
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export type Resource<T extends 1 | 2 = 1 | 2> = {
|
|||||||
active: boolean
|
active: boolean
|
||||||
created_at: Date
|
created_at: Date
|
||||||
updated_at: Date
|
updated_at: Date
|
||||||
|
checkip: boolean
|
||||||
} & (
|
} & (
|
||||||
T extends 1 ? {
|
T extends 1 ? {
|
||||||
type: 1
|
type: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user