feat(badges): 添加勋章系统和展示功能

实现完整的勋章系统,包括勋章列表展示、自动弹窗展示和分享功能。

- 新增勋章列表页面,支持已获得和待解锁勋章的分类展示
- 在个人中心添加勋章预览模块,显示前3个勋章和总数统计
- 实现勋章展示弹窗,支持动画效果和玻璃态UI
- 添加勋章分享功能,可生成分享卡片
- 新增 badgesSlice 管理勋章状态,包括获取、排序和计数逻辑
- 添加勋章服务 API 封装,支持获取勋章列表和标记已展示
- 完善中英文国际化文案
This commit is contained in:
richarjiang
2025-11-14 17:17:17 +08:00
parent 8cffbb990a
commit 705d921c14
10 changed files with 1125 additions and 0 deletions

View File

@@ -17,6 +17,14 @@ const personalScreenResources = {
aiUsage: '免费AI次数: {{value}}',
aiUsageUnlimited: '无限',
fishRecord: '能量记录',
badgesPreview: {
title: '我的勋章',
subtitle: '记录你的荣耀时刻',
cta: '查看全部',
loading: '正在同步勋章...',
empty: '完成睡眠或挑战任务即可解锁首枚勋章',
lockedHint: '坚持训练即可点亮更多勋章',
},
stats: {
height: '身高',
weight: '体重',
@@ -71,6 +79,84 @@ const personalScreenResources = {
},
};
const badgesScreenResources = {
title: '勋章馆',
subtitle: '点亮每一次坚持',
hero: {
highlight: '保持连续打卡即可解锁更多稀有勋章',
earnedLabel: '已获得',
totalLabel: '总数',
progressLabel: '解锁进度',
},
categories: {
all: '全部',
sleep: '睡眠',
exercise: '运动',
diet: '饮食',
challenge: '挑战',
social: '社交',
special: '特别',
},
rarities: {
common: '普通',
uncommon: '少见',
rare: '稀有',
epic: '史诗',
legendary: '传说',
},
status: {
earned: '已获得',
locked: '待解锁',
earnedAt: '{{date}} 获得',
},
legend: '稀有度说明',
filterLabel: '勋章分类',
empty: {
title: '还没有勋章',
description: '完成睡眠、运动、挑战等任务即可点亮你的第一枚勋章。',
action: '去探索计划',
},
};
const badgesScreenResourcesEn = {
title: 'Badge Gallery',
subtitle: 'Celebrate every effort',
hero: {
highlight: 'Keep checking in to unlock rarer badges.',
earnedLabel: 'Earned',
totalLabel: 'Total',
progressLabel: 'Progress',
},
categories: {
all: 'All',
sleep: 'Sleep',
exercise: 'Exercise',
diet: 'Nutrition',
challenge: 'Challenge',
social: 'Social',
special: 'Special',
},
rarities: {
common: 'Common',
uncommon: 'Uncommon',
rare: 'Rare',
epic: 'Epic',
legendary: 'Legendary',
},
status: {
earned: 'Unlocked',
locked: 'Locked',
earnedAt: 'Unlocked on {{date}}',
},
legend: 'Rarity legend',
filterLabel: 'Badge categories',
empty: {
title: 'No badges yet',
description: 'Complete sleep, workout, or challenge tasks to earn your first badge.',
action: 'Explore plans',
},
};
const editProfileResources = {
title: '编辑资料',
fields: {
@@ -748,6 +834,7 @@ const resources = {
zh: {
translation: {
personal: personalScreenResources,
badges: badgesScreenResources,
editProfile: editProfileResources,
healthPermissions: healthPermissionsResources,
statistics: statisticsResources,
@@ -764,6 +851,14 @@ const resources = {
aiUsage: 'Free AI credits: {{value}}',
aiUsageUnlimited: 'Unlimited',
fishRecord: 'Energy log',
badgesPreview: {
title: 'My badges',
subtitle: 'Celebrate every milestone',
cta: 'View all',
loading: 'Syncing your badges…',
empty: 'Complete sleep or challenge tasks to unlock your first badge.',
lockedHint: 'Keep building the habit to unlock more.',
},
stats: {
height: 'Height',
weight: 'Weight',
@@ -817,6 +912,7 @@ const resources = {
},
},
},
badges: badgesScreenResourcesEn,
editProfile: {
title: 'Edit Profile',
fields: {