套餐管理添加IP检查状态字段 &修复套餐提取和购买的数量显示问题

This commit is contained in:
Eamon-meng
2026-04-22 10:27:19 +08:00
parent eb4c2d2d5f
commit 7ff42861f1
5 changed files with 28 additions and 19 deletions

View File

@@ -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})