feat: enhance ProgressBar and UsageInfo for storage mode (#31273)

Co-authored-by: CodingOnStar <hanxujiang@dify.ai>
This commit is contained in:
Coding On Star
2026-01-21 14:04:33 +08:00
committed by GitHub
parent 2512227868
commit 76a0249eaf
15 changed files with 859 additions and 132 deletions

View File

@ -1,7 +1,33 @@
import type { BillingQuota, CurrentPlanInfoBackend } from '../type'
import type { BasicPlan, BillingQuota, CurrentPlanInfoBackend } from '../type'
import dayjs from 'dayjs'
import { ALL_PLANS, NUM_INFINITE } from '@/app/components/billing/config'
/**
* Parse vectorSpace string from ALL_PLANS config and convert to MB
* @example "50MB" -> 50, "5GB" -> 5120, "20GB" -> 20480
*/
export const parseVectorSpaceToMB = (vectorSpace: string): number => {
const match = vectorSpace.match(/^(\d+)(MB|GB)$/i)
if (!match)
return 0
const value = Number.parseInt(match[1], 10)
const unit = match[2].toUpperCase()
return unit === 'GB' ? value * 1024 : value
}
/**
* Get the vector space limit in MB for a given plan type from ALL_PLANS config
*/
export const getPlanVectorSpaceLimitMB = (planType: BasicPlan): number => {
const planInfo = ALL_PLANS[planType]
if (!planInfo)
return 0
return parseVectorSpaceToMB(planInfo.vectorSpace)
}
const parseLimit = (limit: number) => {
if (limit === 0)
return NUM_INFINITE