微信小程序页面迁移校验之前 P5任务处理之前

This commit is contained in:
Neo
2026-03-09 01:19:21 +08:00
parent 263bf96035
commit 6e20987d2f
1112 changed files with 153824 additions and 219694 deletions

View File

@@ -0,0 +1,21 @@
/**
* 爱心评分映射工具函数
* 纯函数,无 wx.* 依赖
*/
/**
* 将 0-10 分数映射为爱心 Emoji
* >8.5 → 💖, >7 → 🧡, >5 → 💛, ≤5 → 💙
* 超出 [0,10] 范围的值会被 clamp
* @param score 评分 0-10
* @returns 爱心 Emoji
*/
export function getHeartEmoji(score: number): string {
// clamp 到 [0, 10]
const clamped = Math.min(10, Math.max(0, score))
if (clamped > 8.5) return '💖'
if (clamped > 7) return '🧡'
if (clamped > 5) return '💛'
return '💙'
}