mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
fix(usage): add extensible CURRENCY_SYMBOLS mapping for deepseek currencies
This commit is contained in:
committed by
diegosouzapw
parent
75008d8098
commit
7f0da3d0b2
@@ -45,6 +45,17 @@ const PROVIDER_CONFIG = {
|
||||
deepseek: { label: "DeepSeek", color: "#4D6BFE" },
|
||||
};
|
||||
|
||||
// Currency symbol mapping
|
||||
const CURRENCY_SYMBOLS: Record<string, string> = {
|
||||
USD: "$",
|
||||
CNY: "¥",
|
||||
EUR: "€",
|
||||
GBP: "£",
|
||||
JPY: "¥",
|
||||
KRW: "₩",
|
||||
INR: "₹",
|
||||
};
|
||||
|
||||
const TIER_FILTERS = [
|
||||
{ key: "all", labelKey: "tierAll" },
|
||||
{ key: "enterprise", labelKey: "tierEnterprise" },
|
||||
@@ -644,7 +655,7 @@ export default function ProviderLimits() {
|
||||
className="text-[12px] font-bold tabular-nums"
|
||||
style={{ color: colors.text }}
|
||||
>
|
||||
{q.currency === "CNY" ? "¥" : q.currency === "USD" ? "$" : ""}
|
||||
{CURRENCY_SYMBOLS[q.currency] ?? q.currency ?? ""}
|
||||
{(q.creditCount ?? q.remaining).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
|
||||
@@ -304,15 +304,17 @@ export function parseQuotaData(provider, data) {
|
||||
|
||||
case "deepseek":
|
||||
// DeepSeek balance: credits-style display with currency
|
||||
// Handles both "credits" and "credits_usd"/"credits_cny" key formats
|
||||
// Match any "credits" key with optional 3-letter currency suffix
|
||||
if (data.quotas) {
|
||||
Object.entries(data.quotas).forEach(([quotaKey, quota]: [string, any]) => {
|
||||
// Match credits_usd, credits_cny, or legacy credits
|
||||
if (/^credits(?:_usd|_cny)?$/.test(quotaKey)) {
|
||||
// Match credits, credits_usd, credits_cny, credits_eur, etc.
|
||||
const match = quotaKey.match(/^credits(?:_([a-z]{3}))?$/);
|
||||
if (match) {
|
||||
const remaining = Number(quota?.remaining ?? 0);
|
||||
const currency = quota?.currency ?? (quotaKey.includes("cny") ? "CNY" : "USD");
|
||||
// Extract currency from key suffix or use quota.currency, fallback to USD
|
||||
const currency = quota?.currency ?? (match[1] ? match[1].toUpperCase() : "USD");
|
||||
normalizedQuotas.push({
|
||||
name: `${currency}`,
|
||||
name: currency,
|
||||
used: 0,
|
||||
total: 0,
|
||||
remaining,
|
||||
|
||||
Reference in New Issue
Block a user