From 7ff42861f1cb817a96c95c7124653bdd192aebdf Mon Sep 17 00:00:00 2001 From: Eamon-meng <17516219072@163.com> Date: Wed, 22 Apr 2026 10:27:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=97=E9=A4=90=E7=AE=A1=E7=90=86=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0IP=E6=A3=80=E6=9F=A5=E7=8A=B6=E6=80=81=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=20&=E4=BF=AE=E5=A4=8D=E5=A5=97=E9=A4=90=E6=8F=90?= =?UTF-8?q?=E5=8F=96=E5=92=8C=E8=B4=AD=E4=B9=B0=E7=9A=84=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/admin/resources/_components/list.tsx | 11 ++++++++ .../composites/purchase/long/center.tsx | 26 ++++++++----------- .../purchase/shared/billing-method-field.tsx | 5 ++-- .../composites/purchase/short/center.tsx | 4 ++- src/lib/models/resource.ts | 1 + 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/app/admin/resources/_components/list.tsx b/src/app/admin/resources/_components/list.tsx index 634d933..1f0a73b 100644 --- a/src/app/admin/resources/_components/list.tsx +++ b/src/app/admin/resources/_components/list.tsx @@ -230,6 +230,17 @@ export default function ResourceList({resourceType}: ResourceListProps) { ) }, }, + { + header: 'IP检查状态', + cell: ({row}) => { + const checkip = row.original.checkip + return ( + + {checkip ? '启用IP检查' : '停用IP检查'} + + ) + }, + }, ] // 短效资源增加到期时间列 diff --git a/src/components/composites/purchase/long/center.tsx b/src/components/composites/purchase/long/center.tsx index 246c7a5..842e7e3 100644 --- a/src/components/composites/purchase/long/center.tsx +++ b/src/components/composites/purchase/long/center.tsx @@ -29,36 +29,32 @@ export default function Center({skuData}: { const currentCountMin = useMemo(() => { if (!type || !live) return 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]) useEffect(() => { - if (type === '1') { - const current = getValues('daily_limit') - if (current < currentCountMin) { - setValue('daily_limit', currentCountMin) - } - } - else { - const current = getValues('quota') - if (current < currentCountMin) { - setValue('quota', currentCountMin) - } + if (currentCountMin <= 0) return + const targetField = type === '1' ? 'daily_limit' : 'quota' + const currentValue = getValues(targetField) + if (currentValue !== currentCountMin) { + setValue(targetField, currentCountMin, {shouldValidate: true}) } }, [currentCountMin, type, setValue, getValues]) useEffect(() => { const nextType = modeList.includes(type) ? type : modeList[0] - if (!nextType) { return } - if (nextType !== type) { setValue('type', nextType) return } - const nextLiveList = nextType === '1' ? getAvailablePurchaseLives(skuData, {mode: nextType, expire}) : getAvailablePurchaseLives(skuData, {mode: nextType}) diff --git a/src/components/composites/purchase/shared/billing-method-field.tsx b/src/components/composites/purchase/shared/billing-method-field.tsx index 89e3d1c..4dc7e26 100644 --- a/src/components/composites/purchase/shared/billing-method-field.tsx +++ b/src/components/composites/purchase/shared/billing-method-field.tsx @@ -11,7 +11,7 @@ export function BillingMethodField(props: { modeList: PurchaseMode[] timeDailyLimit: number }) { - const {setValue} = useFormContext() + const {setValue, getValues} = useFormContext() return ( @@ -30,8 +30,7 @@ export function BillingMethodField(props: { setValue('expire', '0') return } - - setValue('daily_limit', props.timeDailyLimit) + setValue('expire', getValues('expire') || '0') }} className="flex gap-4 max-md:flex-col" > diff --git a/src/components/composites/purchase/short/center.tsx b/src/components/composites/purchase/short/center.tsx index 2a2f7b2..2663fb1 100644 --- a/src/components/composites/purchase/short/center.tsx +++ b/src/components/composites/purchase/short/center.tsx @@ -36,9 +36,11 @@ export default function Center({ useEffect(() => { if (currentCountMin <= 0) return + const targetField = type === '1' ? 'daily_limit' : 'quota' const currentValue = getValues(targetField) - if (currentValue < currentCountMin) { + + if (currentValue !== currentCountMin) { setValue(targetField, currentCountMin, {shouldValidate: true}) } }, [currentCountMin, type, setValue, getValues]) diff --git a/src/lib/models/resource.ts b/src/lib/models/resource.ts index 05f3ad8..62dce1c 100644 --- a/src/lib/models/resource.ts +++ b/src/lib/models/resource.ts @@ -29,6 +29,7 @@ export type Resource = { active: boolean created_at: Date updated_at: Date + checkip: boolean } & ( T extends 1 ? { type: 1