feat(billing): add image output range pricing support

This commit is contained in:
ZheFox
2026-05-18 11:52:01 +08:00
parent a3094fda53
commit a10c02ef63
10 changed files with 871 additions and 55 deletions
@@ -948,9 +948,16 @@ async function handleSubmit() {
function tieredPricingHasImageOutputPricing(pricing: TieredPricingConfig | null | undefined): boolean {
if (!pricing) return false
if (toFinitePrice(pricing.image_output_price_default) !== null) return true
return Object.values(pricing.image_output_prices || {}).some((prices) => {
if (Object.values(pricing.image_output_prices || {}).some((prices) => {
if (!prices || typeof prices !== 'object') return false
return Object.values(prices).some((price) => toFinitePrice(price) !== null)
})) return true
return (pricing.image_output_price_ranges || []).some((range) => {
if (!range || typeof range !== 'object') return false
const prices = range.prices && typeof range.prices === 'object'
? range.prices
: range as Record<string, unknown>
return Object.values(prices).some((price) => toFinitePrice(price) !== null)
})
}