mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
feat: enhance ProgressBar and UsageInfo for storage mode (#31273)
Co-authored-by: CodingOnStar <hanxujiang@dify.ai>
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user