fix: convert usd amount by exchange rate in classic quota display
This commit is contained in:
Vendored
+6
-20
@@ -1068,31 +1068,17 @@ export function getQuotaWithUnit(quota, digits = 6) {
|
|||||||
return (quota / quotaPerUnit).toFixed(digits);
|
return (quota / quotaPerUnit).toFixed(digits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// amount 为系统内部的美元值
|
||||||
export function renderQuotaWithAmount(amount) {
|
export function renderQuotaWithAmount(amount) {
|
||||||
const quotaDisplayType = localStorage.getItem('quota_display_type') || 'USD';
|
const { symbol, rate, type } = getCurrencyConfig();
|
||||||
if (quotaDisplayType === 'TOKENS') {
|
if (type === 'TOKENS') {
|
||||||
return renderNumber(renderUnitWithQuota(amount));
|
return renderNumber(renderUnitWithQuota(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
const numericAmount = Number(amount);
|
const numericAmount = Number(amount);
|
||||||
const formattedAmount = Number.isFinite(numericAmount)
|
if (!Number.isFinite(numericAmount)) {
|
||||||
? numericAmount.toFixed(2)
|
return symbol + amount;
|
||||||
: amount;
|
|
||||||
|
|
||||||
if (quotaDisplayType === 'CNY') {
|
|
||||||
return '¥' + formattedAmount;
|
|
||||||
} else if (quotaDisplayType === 'CUSTOM') {
|
|
||||||
const statusStr = localStorage.getItem('status');
|
|
||||||
let symbol = '¤';
|
|
||||||
try {
|
|
||||||
if (statusStr) {
|
|
||||||
const s = JSON.parse(statusStr);
|
|
||||||
symbol = s?.custom_currency_symbol || symbol;
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
return symbol + formattedAmount;
|
|
||||||
}
|
}
|
||||||
return '$' + formattedAmount;
|
return symbol + (numericAmount * rate).toFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user