fix: display all quota models, center card content vertically
- Handle all quota types in providersQuota, not just TIME_LIMIT - Extract model name from model field or type field - Use explicit limit value when available - Add vertical center alignment to quota card content 💘 Generated with Crush Assisted-by: MiniMax-M2.7 via Crush <crush@charm.land>
This commit is contained in:
@@ -496,22 +496,34 @@ func (s *Server) handleProvidersQuota(w http.ResponseWriter, r *http.Request) {
|
|||||||
if json.Unmarshal(body, &data) == nil {
|
if json.Unmarshal(body, &data) == nil {
|
||||||
if d, ok := data["data"].(map[string]interface{}); ok {
|
if d, ok := data["data"].(map[string]interface{}); ok {
|
||||||
if limits, ok := d["limits"].([]interface{}); ok {
|
if limits, ok := d["limits"].([]interface{}); ok {
|
||||||
timeLimit := map[string]interface{}{}
|
models := make([]map[string]interface{}, 0)
|
||||||
for _, l := range limits {
|
for _, l := range limits {
|
||||||
if lm, ok := l.(map[string]interface{}); ok && lm["type"] == "TIME_LIMIT" {
|
if lm, ok := l.(map[string]interface{}); ok {
|
||||||
|
name := "Z.AI"
|
||||||
|
if model, ok := lm["model"].(string); ok && model != "" {
|
||||||
|
name = model
|
||||||
|
} else if t, ok := lm["type"].(string); ok && t != "TIME_LIMIT" {
|
||||||
|
name = t
|
||||||
|
}
|
||||||
usage, _ := lm["usage"].(float64)
|
usage, _ := lm["usage"].(float64)
|
||||||
remaining, _ := lm["remaining"].(float64)
|
remaining, _ := lm["remaining"].(float64)
|
||||||
|
limitVal, hasLimit := lm["limit"].(float64)
|
||||||
total := usage + remaining
|
total := usage + remaining
|
||||||
timeLimit = map[string]interface{}{
|
if hasLimit && limitVal > 0 {
|
||||||
"model": "Z.AI",
|
total = limitVal
|
||||||
"used": usage,
|
}
|
||||||
"total": total,
|
if total > 0 {
|
||||||
"remaining": remaining,
|
models = append(models, map[string]interface{}{
|
||||||
|
"model": name,
|
||||||
|
"used": usage,
|
||||||
|
"total": total,
|
||||||
|
"remaining": remaining,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(timeLimit) > 0 {
|
if len(models) > 0 {
|
||||||
q.Data = map[string]interface{}{"models": []map[string]interface{}{timeLimit}}
|
q.Data = map[string]interface{}{"models": models}
|
||||||
q.Healthy = true
|
q.Healthy = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ input::placeholder { color: var(--text-disabled); }
|
|||||||
position: relative;
|
position: relative;
|
||||||
background: var(--bg-card); border: 1px solid var(--border);
|
background: var(--bg-card); border: 1px solid var(--border);
|
||||||
border-radius: var(--radius-lg); padding: 14px 16px;
|
border-radius: var(--radius-lg); padding: 14px 16px;
|
||||||
display: flex; flex-direction: column; gap: 8px;
|
display: flex; flex-direction: column; justify-content: center; gap: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user