This commit is contained in:
2026-06-25 18:24:29 +08:00
commit a1190d7d9a
90 changed files with 5459 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
// utils/achievements.js — 成就定义(前端展示用副本)
// 解锁判定的"权威"逻辑在云函数侧(防刷);此处仅供前端渲染成就墙/进度。
// 成就基于「连续 / 累计 / 场景」,不基于「最多 / 最快」docs/05 R10
const ACHIEVEMENTS = [
{
key: 'first_walk',
name: '首遛',
desc: '第一次记录遛狗',
icon: 'flag',
progress: (stats) => Math.min(1, stats.totalWalks / 1),
},
{
key: 'week_streak',
name: '一周不断',
desc: '连续遛狗满 7 天',
icon: 'medal',
progress: (stats) => Math.min(1, stats.currentStreak / 7),
},
{
key: 'month_streak',
name: '满月坚持',
desc: '连续遛狗满 30 天',
icon: 'trophy',
progress: (stats) => Math.min(1, stats.currentStreak / 30),
},
{
key: 'rainy_warrior',
name: '雨天战士',
desc: '雨天也坚持遛狗',
icon: 'rain',
progress: () => 0, // 场景类,由事件触发
},
{
key: 'hundred_km',
name: '百里同行',
desc: '累计遛狗满 100 公里',
icon: 'walk',
progress: (stats) => Math.min(1, stats.totalDistance / 100),
},
{
key: 'early_bird',
name: '早起鸟',
desc: '在 7 点前遛狗 10 次',
icon: 'sun',
progress: (stats) => Math.min(1, (stats.earlyWalks || 0) / 10), // 场景类:累计早遛次数
},
];
const TOTAL = ACHIEVEMENTS.length;
function getDef(key) {
return ACHIEVEMENTS.find((a) => a.key === key);
}
module.exports = { ACHIEVEMENTS, TOTAL, getDef };