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