mirror of
https://github.com/coaidev/coai.git
synced 2025-05-20 21:40:15 +09:00
feat: support unlimited plan usage
This commit is contained in:
parent
ed14c5a9d6
commit
b56dadce1a
@ -31,7 +31,8 @@ function SubscriptionUsage({ icon, name, usage }: UsageProps) {
|
||||
</div>
|
||||
) : (
|
||||
<div className={`sub-value`}>
|
||||
<p>{usage.used}</p> / <p> {usage.total} </p>
|
||||
<p>{usage.used}</p> /{" "}
|
||||
<p> {usage.total === -1 ? "∞" : usage.total} </p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
@ -67,7 +67,9 @@ function PlanItem({ level }: PlanItemProps) {
|
||||
{plan.items.map((item, index) => (
|
||||
<div key={index}>
|
||||
<SubscriptionIcon type={item.icon} className={`h-4 w-4 mr-1`} />
|
||||
{t("sub.plan-usage", { name: item.name, times: item.value })}
|
||||
{item.value !== -1
|
||||
? t("sub.plan-usage", { name: item.name, times: item.value })
|
||||
: t("sub.plan-unlimited-usage", { name: item.name })}
|
||||
<Tips>
|
||||
<div className={`api-tip text-center`}>
|
||||
<p>{t("sub.plan-tip")}</p>
|
||||
|
@ -203,6 +203,7 @@
|
||||
"plan-price": "{{money}} 元/月",
|
||||
"include-tax": "含税",
|
||||
"plan-usage": "{{name}} 每月使用 {{times}} 次",
|
||||
"plan-unlimited-usage": "{{name}} 无限次使用",
|
||||
"plan-tip": "可调用模型",
|
||||
"enterprise": "企业版",
|
||||
"enterprise-service": "优先技术支持",
|
||||
|
@ -187,7 +187,8 @@
|
||||
"migrate-failed-prompt": "Your subscription migration failed.",
|
||||
"plan-usage": "{{name}} uses {{times}} times per month",
|
||||
"plan-tip": "Callable Model",
|
||||
"disable": "This site's subscription feature has been turned off"
|
||||
"disable": "This site's subscription feature has been turned off",
|
||||
"plan-unlimited-usage": "{{name}} has unlimited uses"
|
||||
},
|
||||
"cancel": "Cancel",
|
||||
"confirm": "Confirm",
|
||||
|
@ -187,7 +187,8 @@
|
||||
"migrate-failed-prompt": "サブスクリプションの変更に失敗しました。",
|
||||
"plan-usage": "{{name}}は月に{{times}}回使用",
|
||||
"plan-tip": "呼び出し可能なモデル",
|
||||
"disable": "このサイトのサブスクリプション機能はオフになっています"
|
||||
"disable": "このサイトのサブスクリプション機能はオフになっています",
|
||||
"plan-unlimited-usage": "{{name}}は無制限に使用できます"
|
||||
},
|
||||
"cancel": "キャンセル",
|
||||
"confirm": "確認",
|
||||
|
@ -187,7 +187,8 @@
|
||||
"migrate-failed-prompt": "Ваша подписка не удалась.",
|
||||
"plan-usage": "{{name}} использует {{times}} раз в месяц",
|
||||
"plan-tip": "Вызываемая модель",
|
||||
"disable": "Функция подписки на этом сайте отключена"
|
||||
"disable": "Функция подписки на этом сайте отключена",
|
||||
"plan-unlimited-usage": "{{name}} имеет неограниченное количество пользователей"
|
||||
},
|
||||
"cancel": "Отмена",
|
||||
"confirm": "Подтвердить",
|
||||
|
@ -462,6 +462,8 @@ function PlanConfig() {
|
||||
</p>
|
||||
<NumberInput
|
||||
value={item.value}
|
||||
min={-1}
|
||||
acceptNegative={true}
|
||||
onValueChange={(value: number) => {
|
||||
formDispatch({
|
||||
type: "set-item-value",
|
||||
|
@ -225,10 +225,8 @@ func (p *PlanItem) IsExceeded(user globals.AuthLike, db *sql.DB, cache *redis.Cl
|
||||
}
|
||||
|
||||
func (p *PlanItem) Increase(user globals.AuthLike, cache *redis.Client) bool {
|
||||
if p.Value == -1 {
|
||||
return true
|
||||
}
|
||||
return IncreaseSubscriptionUsage(cache, user, p.Id, p.Value)
|
||||
state := IncreaseSubscriptionUsage(cache, user, p.Id, p.Value)
|
||||
return state || p.IsInfinity()
|
||||
}
|
||||
|
||||
func (p *PlanItem) Decrease(user globals.AuthLike, cache *redis.Client) bool {
|
||||
|
Loading…
Reference in New Issue
Block a user