diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index c217412..1311810 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -204,6 +204,11 @@ "pricing.unknown": "Unknown", "pricing.vendor": "Vendor", "pricing.allVendors": "All", + "供应商": "Provider", + "供应商介绍": "Provider introduction", + "供应商定价": "Provider pricing", + "按次计费": "Per call", + "按量计费": "Pay as you go", "packages.title": "Packages & Plans", "packages.subtitle": "Choose a package that fits your usage. All plans include access to all available models.", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index 0740ca9..1f97a39 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -204,6 +204,11 @@ "pricing.unknown": "未知", "pricing.vendor": "厂商", "pricing.allVendors": "全部", + "供应商": "供应商", + "供应商介绍": "供应商介绍", + "供应商定价": "供应商定价", + "按次计费": "按次计费", + "按量计费": "按量计费", "packages.title": "套餐方案", "packages.subtitle": "选择适合您用量的套餐。所有方案均可访问全部可用模型。", diff --git a/src/pages/Logs.jsx b/src/pages/Logs.jsx index 11f0156..06dcd3e 100644 --- a/src/pages/Logs.jsx +++ b/src/pages/Logs.jsx @@ -20,6 +20,24 @@ function getLogOther(otherStr) { } } +function formatProviderPriceSnapshot(other, symbol, rate, t) { + if (!other?.provider_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 (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 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(' · '); +} + export default function Logs() { const { t } = useTranslation(); const { symbol, rate } = useCurrency(); @@ -55,7 +73,7 @@ export default function Logs() { setExpandedRows(prev => ({ ...prev, [logId]: !prev[logId] })); }; - const getExpandData = (log) => { + const getExpandData = useCallback((log) => { const other = getLogOther(log.other); if (!other) return []; @@ -92,8 +110,19 @@ export default function Logs() { data.push({ key: t('计费方式'), value: t('订阅抵扣') }); } + if (other.provider_name) { + data.push({ key: t('供应商'), value: other.provider_name }); + data.push({ + key: t('供应商定价'), + value: formatProviderPriceSnapshot(other, symbol, rate, t), + }); + if (other.provider_description) { + data.push({ key: t('供应商介绍'), value: other.provider_description }); + } + } + return data; - }; + }, [rate, symbol, t]); return (