fix: check-in

This commit is contained in:
zzc
2026-02-25 16:34:35 +08:00
parent 8dfd7612b1
commit 5e0da973af

View File

@@ -258,6 +258,7 @@ const weekDays = computed(() => {
const days = []; const days = [];
const labels = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]; const labels = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"];
const signedDays = signInfo.value.signedDays || [];
for (let i = 0; i < 7; i++) { for (let i = 0; i < 7; i++) {
const d = new Date(monday); const d = new Date(monday);
@@ -271,40 +272,8 @@ const weekDays = computed(() => {
const isToday = dateStr === todayStr; const isToday = dateStr === todayStr;
const isFuture = dateStr > todayStr; const isFuture = dateStr > todayStr;
if (signInfo.value.continuousDays > 0) { if (signedDays.includes(i + 1)) {
const continuous = signInfo.value.continuousDays; isSigned = true;
const signedToday = signInfo.value.isSignedToday;
const streakEndDate = new Date(todayStr);
if (!signedToday) {
streakEndDate.setDate(streakEndDate.getDate() - 1);
}
const streakStartDate = new Date(streakEndDate);
streakStartDate.setDate(streakEndDate.getDate() - continuous + 1);
const checkDate = new Date(dateStr);
const checkTime = checkDate.getTime();
// Reset time components to avoid issues
const sTime = new Date(
streakStartDate.getFullYear(),
streakStartDate.getMonth(),
streakStartDate.getDate(),
).getTime();
const eTime = new Date(
streakEndDate.getFullYear(),
streakEndDate.getMonth(),
streakEndDate.getDate(),
).getTime();
const cTime = new Date(
checkDate.getFullYear(),
checkDate.getMonth(),
checkDate.getDate(),
).getTime();
if (cTime >= sTime && cTime <= eTime) {
isSigned = true;
}
} }
days.push({ days.push({
@@ -444,6 +413,16 @@ const onOpenLucky = async () => {
signInfo.value.totalDays = (signInfo.value.totalDays || 0) + 1; signInfo.value.totalDays = (signInfo.value.totalDays || 0) + 1;
} }
// Update signedDays locally
if (!signInfo.value.signedDays) {
signInfo.value.signedDays = [];
}
const today = new Date(signInfo.value.today || new Date());
const dayIndex = today.getDay() || 7;
if (!signInfo.value.signedDays.includes(dayIndex)) {
signInfo.value.signedDays.push(dayIndex);
}
// Update user assets (points) // Update user assets (points)
userStore.fetchUserAssets(); userStore.fetchUserAssets();