Merge remote-tracking branch 'upstream/main'

This commit is contained in:
ckt1031 2023-07-16 13:12:45 +08:00
commit 203471d7a9
2 changed files with 22 additions and 16 deletions

View File

@ -8,7 +8,8 @@ import (
) )
func GetSubscription(c *gin.Context) { func GetSubscription(c *gin.Context) {
var quota int var remainQuota int
var usedQuota int
var err error var err error
var expirationDate int64 var expirationDate int64
@ -18,10 +19,14 @@ func GetSubscription(c *gin.Context) {
expirationDate = token.ExpiredTime expirationDate = token.ExpiredTime
if common.DisplayTokenStatEnabled { if common.DisplayTokenStatEnabled {
quota = token.RemainQuota tokenId := c.GetInt("token_id")
token, err = model.GetTokenById(tokenId)
remainQuota = token.RemainQuota
usedQuota = token.UsedQuota
} else { } else {
userId := c.GetInt("id") userId := c.GetInt("id")
quota, err = model.GetUserQuota(userId) remainQuota, err = model.GetUserQuota(userId)
usedQuota, err = model.GetUserUsedQuota(userId)
} }
if err != nil { if err != nil {
openAIError := OpenAIError{ openAIError := OpenAIError{
@ -33,6 +38,7 @@ func GetSubscription(c *gin.Context) {
}) })
return return
} }
quota := remainQuota + usedQuota
amount := float64(quota) amount := float64(quota)
if common.DisplayInCurrencyEnabled { if common.DisplayInCurrencyEnabled {
amount /= common.QuotaPerUnit amount /= common.QuotaPerUnit

View File

@ -59,19 +59,19 @@ const EditChannel = () => {
data.models = []; data.models = [];
} else { } else {
data.models = data.models.split(','); data.models = data.models.split(',');
// setTimeout(() => { setTimeout(() => {
// let localModelOptions = [...modelOptions]; let localModelOptions = [...data.models];
// data.models.forEach((model) => { data.models.forEach((model) => {
// if (!localModelOptions.find((option) => option.key === model)) { if (!localModelOptions.find((option) => option.key === model)) {
// localModelOptions.push({ localModelOptions.push({
// key: model, key: model,
// text: model, text: model,
// value: model, value: model
// }); });
// } }
// }); });
// setModelOptions(localModelOptions); setModelOptions(localModelOptions);
// }, 1000); }, 1000);
} }
if (data.group === '') { if (data.group === '') {
data.groups = []; data.groups = [];