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