Fix dist log pricing display

This commit is contained in:
abingyyds committed 2026-04-13 18:26:55 +08:00
1 parent b08dac374e
commit 8a09b68ae7
3 files changed
+23 -13

No files matched your search

+1
View File
@@ -211,6 +211,7 @@
"供应商": "Provider",
"供应商介绍": "Provider introduction",
"供应商定价": "Provider pricing",
"分站定价": "Sub-site pricing",
"按次计费": "Per call",
"按量计费": "Pay as you go",
+1
View File
@@ -211,6 +211,7 @@
"供应商": "供应商",
"供应商介绍": "供应商介绍",
"供应商定价": "供应商定价",
"分站定价": "分站定价",
"按次计费": "按次计费",
"按量计费": "按量计费",
+21 -13
View File
@@ -20,24 +20,33 @@ function getLogOther(otherStr) {
}
}
function formatProviderPriceSnapshot(other, symbol, rate, t) {
if (!other?.provider_billing_mode) return '-';
function formatSitePriceSnapshot(other, symbol, rate, t) {
if (!other?.site_billing_mode) return '-';
const formatUSD = (amount) => `${symbol}${(Number(amount || 0) * rate).toFixed(6)}`;
if (other.provider_billing_mode === 'per_call') {
const fixedPrice = Number(other?.provider_fixed_price || 0);
if (other.site_billing_mode === 'per_call') {
const fixedPrice = Number(other?.site_fixed_price || 0);
if (fixedPrice <= 0) return t('按次计费');
return `${t('按次计费')} · ${formatUSD(fixedPrice)} / ${t('pricing.perCallUnit')}`;
}
const inputPrice = Number(other?.provider_input_price || 0);
const outputPrice = Number(other?.provider_output_price || 0);
const inputPrice = Number(other?.site_input_price || 0);
const outputPrice = Number(other?.site_output_price || 0);
const parts = [t('按量计费')];
if (inputPrice > 0) parts.push(`${t('输入')} ${formatUSD(inputPrice)} / 1M tokens`);
if (outputPrice > 0) parts.push(`${t('输出')} ${formatUSD(outputPrice)} / 1M tokens`);
return parts.join(' · ');
}
function formatProviderSummary(other, t) {
if (!other?.provider_name) return [];
const items = [{ key: t('供应商'), value: other.provider_name }];
if (other.provider_description) {
items.push({ key: t('供应商介绍'), value: other.provider_description });
}
return items;
}
export default function Logs() {
const { t } = useTranslation();
const { symbol, rate } = useCurrency();
@@ -110,15 +119,14 @@ export default function Logs() {
data.push({ key: t('计费方式'), value: t('订阅抵扣') });
}
if (other.provider_name) {
data.push({ key: t('供应商'), value: other.provider_name });
const providerInfo = formatProviderSummary(other, t);
data.push(...providerInfo);
if (other.site_billing_mode) {
data.push({
key: t('供应商定价'),
value: formatProviderPriceSnapshot(other, symbol, rate, t),
key: t('分站定价'),
value: formatSitePriceSnapshot(other, symbol, rate, t),
});
if (other.provider_description) {
data.push({ key: t('供应商介绍'), value: other.provider_description });
}
}
return data;