debug: 添加权重指示器调试信息

- 在 SegmentWeightIndicator 中添加控制台日志
- 调试匹配规则识别和权重过滤逻辑
- 帮助定位分类数量显示错误的根本原因
This commit is contained in:
imeepos 2025-07-25 17:40:33 +08:00
parent 7fdd95bbb4
commit 6c44d31666
1 changed files with 17 additions and 0 deletions

View File

@ -59,18 +59,35 @@ export const SegmentWeightIndicator: React.FC<SegmentWeightIndicatorProps> = ({
// 计算权重摘要 - 只统计实际选择的分类
let relevantWeights: Record<string, number> = {};
console.log('SegmentWeightIndicator Debug:', {
segmentMatchingRule,
isPriorityOrder: segmentMatchingRule ? SegmentMatchingRuleHelper.isPriorityOrder(segmentMatchingRule) : false,
allWeights: weights,
allWeightsCount: Object.keys(weights).length
});
if (segmentMatchingRule && SegmentMatchingRuleHelper.isPriorityOrder(segmentMatchingRule)) {
// 对于按顺序匹配规则,只统计选择的分类
const selectedCategoryIds = typeof segmentMatchingRule === 'object' && 'PriorityOrder' in segmentMatchingRule
? segmentMatchingRule.PriorityOrder.category_ids
: [];
console.log('PriorityOrder Debug:', {
selectedCategoryIds,
selectedCount: selectedCategoryIds.length
});
// 只包含选择的分类的权重
relevantWeights = Object.fromEntries(
Object.entries(weights).filter(([classificationId]) =>
selectedCategoryIds.includes(classificationId)
)
);
console.log('Filtered weights:', {
relevantWeights,
relevantCount: Object.keys(relevantWeights).length
});
} else {
// 对于其他规则类型,使用所有权重
relevantWeights = weights;