mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-03 06:52:13 +08:00
fix(billing): allow clearing group quota limits and treat 0 as zero-limit
Previously, v-model.number produced "" when input was cleared, causing JSON decode errors on the backend. Also, normalizeLimit treated 0 as "unlimited" which prevented setting a zero quota. Now "" is converted to null (unlimited) in frontend, and 0 is preserved as a valid limit. Closes Wei-Shaw/sub2api#1021
This commit is contained in:
@@ -2382,6 +2382,11 @@ const handleCreateGroup = async () => {
|
||||
sora_storage_quota_bytes: createQuotaGb ? Math.round(createQuotaGb * 1024 * 1024 * 1024) : 0,
|
||||
model_routing: convertRoutingRulesToApiFormat(createModelRoutingRules.value)
|
||||
}
|
||||
// v-model.number 清空输入框时产生 "",转为 null 让后端设为无限制
|
||||
const emptyToNull = (v: any) => v === '' ? null : v
|
||||
requestData.daily_limit_usd = emptyToNull(requestData.daily_limit_usd)
|
||||
requestData.weekly_limit_usd = emptyToNull(requestData.weekly_limit_usd)
|
||||
requestData.monthly_limit_usd = emptyToNull(requestData.monthly_limit_usd)
|
||||
await adminAPI.groups.create(requestData)
|
||||
appStore.showSuccess(t('admin.groups.groupCreated'))
|
||||
closeCreateModal()
|
||||
@@ -2465,6 +2470,11 @@ const handleUpdateGroup = async () => {
|
||||
: editForm.fallback_group_id_on_invalid_request,
|
||||
model_routing: convertRoutingRulesToApiFormat(editModelRoutingRules.value)
|
||||
}
|
||||
// v-model.number 清空输入框时产生 "",转为 null 让后端设为无限制
|
||||
const emptyToNull = (v: any) => v === '' ? null : v
|
||||
payload.daily_limit_usd = emptyToNull(payload.daily_limit_usd)
|
||||
payload.weekly_limit_usd = emptyToNull(payload.weekly_limit_usd)
|
||||
payload.monthly_limit_usd = emptyToNull(payload.monthly_limit_usd)
|
||||
await adminAPI.groups.update(editingGroup.value.id, payload)
|
||||
appStore.showSuccess(t('admin.groups.groupUpdated'))
|
||||
closeEditModal()
|
||||
|
||||
Reference in New Issue
Block a user