/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import React from 'react'; import { Button, Modal, Spin } from '@douyinfe/semi-ui'; import { AlertTriangle } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { compareParamSummary } from '../../hooks/creation/creationCompare'; import { formatQuoteAmount } from '../../hooks/creation/useCreationQuote'; import { displayNameOf } from './ModelPicker'; const amountOf = (item) => item && !item.error ? formatQuoteAmount(item.display_amount, item.currency) : ''; /** * 对比生成提交前摘要(WP C-2,方案 §4.2):逐模型"模型 · 实际参数 · 价格"与合计; * 合计超过系统阈值时显示二次确认提示,确认按钮写明合计金额。 */ const CompareSummary = ({ visible, compare, onCancel, onConfirm }) => { const { t } = useTranslation(); const { entries, quote, quoteLoading, quoteFailed, overThreshold, submitting, } = compare; const items = quote?.items || []; const total = quote ? formatQuoteAmount(quote.display_amount, quote.currency) : ''; const approximate = Boolean( quote?.approximate || items.some((item) => item?.approximate), ); const totalText = total ? approximate ? t('约 {{amount}}', { amount: total }) : total : quoteLoading ? t('正在估价...') : t('价格以实际扣费为准'); return ( } >

{t( '将用同一提示词分别提交 {{n}} 个模型,每个模型单独计费,失败自动退还', { n: entries.length, }, )}

    {entries.map((entry, i) => { const amount = amountOf(items[i]); const params = compareParamSummary(entry.payload); return (
  • {displayNameOf(entry.model)} {params || '-'} {amount ? ( items[i]?.approximate ? ( t('约 {{amount}}', { amount }) ) : ( amount ) ) : quoteLoading ? ( ) : ( '-' )} {entry.adjustments?.length ? ( {t('部分参数已按该模型调整')} ) : null}
  • ); })}
{t('合计')} {totalText}
{quoteFailed ? (

{t('估价失败,价格以实际扣费为准')}

) : null} {overThreshold ? (
) : null}
); }; export default CompareSummary;