Skip to content

Commit 6596178

Browse files
committed
fix: align difficulty statistics on homepage with challenge list filters
1 parent 174233c commit 6596178

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/components/HomePage/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import { useMediaQuery } from 'react-responsive';
1111
const getDifficultyCounts = () => {
1212
const counts = { easy: 0, medium: 0, hard: 0 };
1313
challenges.forEach(challenge => {
14-
if (challenge.difficulty === 1) counts.easy++;
15-
else if (challenge.difficulty === 2) counts.medium++;
16-
else if (challenge.difficulty === 3) counts.hard++;
14+
// 匹配挑战列表页面的难度分类:
15+
// easy: 1-2星, medium: 3-4星, hard: 5星
16+
if (challenge.difficulty <= 2) counts.easy++;
17+
else if (challenge.difficulty <= 4) counts.medium++;
18+
else if (challenge.difficulty === 5) counts.hard++;
1719
});
1820
return counts;
1921
};

0 commit comments

Comments
 (0)