🔧 refactor(pricing): render “auto” routing chain only when relevant & remove unused prop

Changes
1. ModelPricingTable.jsx
   • Compute `autoChain` as the intersection of `autoGroups` and the model’s `enable_groups` (order preserved).
   • Display the chain banner only when `autoChain.length > 0`; banner shows the reduced path (e.g. `a → c → e`).
   • Dropped obsolete `selectedGroup` prop; all callers updated.

2. ModelDetailSideSheet.jsx / PricingPage.jsx
   • Removed forwarding of deleted `selectedGroup` prop.

Outcome
– “Auto group routing” appears only for models that actually participate in the chain, avoiding empty or irrelevant banners.
– Codebase simplified by eliminating an unused prop.
This commit is contained in:
t0ng7u
2025-08-08 15:11:31 +08:00
parent 7d869c9af1
commit c6bb1dcc0e

View File

@@ -35,11 +35,11 @@ const ModelPricingTable = ({
autoGroups = [],
t,
}) => {
const modelEnableGroups = Array.isArray(modelData?.enable_groups) ? modelData.enable_groups : [];
const autoChain = autoGroups.filter(g => modelEnableGroups.includes(g));
const renderGroupPriceTable = () => {
// 仅展示模型可用的分组:模型 enable_groups 与用户可用分组的交集
const modelEnableGroups = Array.isArray(modelData?.enable_groups)
? modelData.enable_groups
: [];
const availableGroups = Object.keys(usableGroup || {})
.filter(g => g !== '')
.filter(g => g !== 'auto')
@@ -169,14 +169,14 @@ const ModelPricingTable = ({
<div className="text-xs text-gray-600">{t('不同用户分组的价格信息')}</div>
</div>
</div>
{autoGroups && autoGroups.length > 0 && (
{autoChain.length > 0 && (
<div className="flex flex-wrap items-center gap-1 mb-4">
<span className="text-sm text-gray-600">{t('auto分组调用链路')}</span>
<span className="text-sm"></span>
{autoGroups.map((g, idx) => (
{autoChain.map((g, idx) => (
<React.Fragment key={g}>
<Tag color="white" size="small" shape="circle">{g}{t('分组')}</Tag>
{idx < autoGroups.length - 1 && <span className="text-sm"></span>}
{idx < autoChain.length - 1 && <span className="text-sm"></span>}
</React.Fragment>
))}
</div>