hookehuyr

refactor(profile): 更新打卡数据字段名以匹配后端返回结构

将打卡数据字段从驼峰式改为下划线式以保持前后端一致
......@@ -39,19 +39,19 @@
<div class="flex justify-between">
<div class="flex flex-col items-center">
<div class="text-2xl font-bold text-gray-800">
{{ profile.checkIns?.totalDays || 0 }}
{{ checkIns?.total_days || 0 }}
</div>
<div class="text-xs text-gray-500 mt-1">累计打卡</div>
</div>
<div class="flex flex-col items-center">
<div class="text-2xl font-bold text-green-600">
{{ profile.checkIns?.currentStreak || 0 }}
{{ checkIns?.consecutive_days || 0 }}
</div>
<div class="text-xs text-gray-500 mt-1">连续打卡</div>
</div>
<div class="flex flex-col items-center">
<div class="text-2xl font-bold text-blue-600">
{{ profile.checkIns?.longestStreak || 0 }}
{{ checkIns?.longest_consecutive_days || 0 }}
</div>
<div class="text-xs text-gray-500 mt-1">最长连续</div>
</div>
......@@ -136,11 +136,13 @@ const $route = useRoute();
useTitle($route.meta.title);
const profile = ref({});
const checkIns = ref({});
onMounted(async () => {
const { code, data } = await getUserInfoAPI();
if (code) {
profile.value = data.user;
checkIns.value = data.checkin;
}
})
......@@ -148,11 +150,11 @@ const showCheckInDialog = ref(false);
// 处理打卡成功
const handleCheckInSuccess = () => {
profile.value.checkIns.totalDays++;
profile.value.checkIns.currentStreak++;
profile.value.checkIns.longestStreak = Math.max(
profile.value.checkIns.longestStreak,
profile.value.checkIns.currentStreak
checkIns.value.total_days++;
checkIns.value.consecutive_days++;
checkIns.value.longest_consecutive_days = Math.max(
checkIns.value.longest_consecutive_days,
checkIns.value.consecutive_days
);
};
......