feat: 评分统计放在每个条目后面
This commit is contained in:
@@ -413,6 +413,57 @@
|
||||
}
|
||||
}
|
||||
|
||||
function renderItemRatingStats(comments) {
|
||||
if (!comments || comments.length === 0) return '';
|
||||
|
||||
const stats = { quality: [], efficiency: [], creativity: [], learning: [] };
|
||||
comments.forEach(c => {
|
||||
if (c.quality) stats.quality.push(c.quality);
|
||||
if (c.efficiency) stats.efficiency.push(c.efficiency);
|
||||
if (c.creativity) stats.creativity.push(c.creativity);
|
||||
if (c.learning) stats.learning.push(c.learning);
|
||||
});
|
||||
|
||||
const hasAnyScore = stats.quality.length > 0 || stats.efficiency.length > 0 ||
|
||||
stats.creativity.length > 0 || stats.learning.length > 0;
|
||||
|
||||
if (!hasAnyScore) return '';
|
||||
|
||||
const avg = (arr) => arr.length > 0 ? (arr.reduce((a,b) => a+b, 0) / arr.length).toFixed(1) : '-';
|
||||
|
||||
return `
|
||||
<div class="rating-stats" style="margin-top: 20px; padding: 12px;">
|
||||
<h3 style="font-size: 0.95em; margin-bottom: 10px;">📊 本项评分统计</h3>
|
||||
<div class="rating-grid" style="grid-template-columns: repeat(4, 1fr); gap: 10px;">
|
||||
${stats.quality.length > 0 ? `
|
||||
<div class="rating-item" style="padding: 8px;">
|
||||
<div class="label" style="font-size: 0.75em;">📐 质量</div>
|
||||
<div class="value quality" style="font-size: 1.2em;">${avg(stats.quality)}</div>
|
||||
</div>
|
||||
` : ''}
|
||||
${stats.efficiency.length > 0 ? `
|
||||
<div class="rating-item" style="padding: 8px;">
|
||||
<div class="label" style="font-size: 0.75em;">⚡ 效率</div>
|
||||
<div class="value efficiency" style="font-size: 1.2em;">${avg(stats.efficiency)}</div>
|
||||
</div>
|
||||
` : ''}
|
||||
${stats.creativity.length > 0 ? `
|
||||
<div class="rating-item" style="padding: 8px;">
|
||||
<div class="label" style="font-size: 0.75em;">💡 创新</div>
|
||||
<div class="value creativity" style="font-size: 1.2em;">${avg(stats.creativity)}</div>
|
||||
</div>
|
||||
` : ''}
|
||||
${stats.learning.length > 0 ? `
|
||||
<div class="rating-item" style="padding: 8px;">
|
||||
<div class="label" style="font-size: 0.75em;">📚 学习</div>
|
||||
<div class="value learning" style="font-size: 1.2em;">${avg(stats.learning)}</div>
|
||||
</div>
|
||||
` : ''}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderEmbeddedComments(contentType, objectId, comments) {
|
||||
if (!comments || comments.length === 0) return '';
|
||||
|
||||
@@ -438,6 +489,7 @@
|
||||
</div>
|
||||
`;
|
||||
}).join('')}
|
||||
${renderItemRatingStats(comments)}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@@ -612,7 +664,6 @@
|
||||
<div class="stat-card"><h3>${state.taskStats.completion_rate || 0}%</h3><p>完成率</p></div>
|
||||
<div class="stat-card"><h3>${state.expStats.total_experiences || 0}</h3><p>经验</p></div>
|
||||
</div>
|
||||
${renderRatingStats()}
|
||||
${content}
|
||||
`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user