diff --git a/src/components/pageHome/ph-daily-note-resin.vue b/src/components/pageHome/ph-daily-note-resin.vue index 7a2b8403..fe3eec7e 100644 --- a/src/components/pageHome/ph-daily-note-resin.vue +++ b/src/components/pageHome/ph-daily-note-resin.vue @@ -29,14 +29,15 @@ type PhDailyNoteResinProps = { const props = defineProps(); const remainedTime = ref(0); -const initialRecoveryTime = ref(0); const initialCurrent = ref(0); const max = computed(() => props.maxResin ?? 200); const current = computed(() => { - const totalSecondsPassed = initialRecoveryTime.value - remainedTime.value; - const resinToRecover = Math.floor(totalSecondsPassed / 540); - return Math.min(initialCurrent.value + resinToRecover, max.value); + const totalToRecover = max.value - initialCurrent.value; + if (totalToRecover <= 0) return max.value; + if (remainedTime.value <= 0) return max.value; + const recovered = Math.floor(totalToRecover - remainedTime.value / 540); + return Math.min(initialCurrent.value + Math.max(recovered, 0), max.value); }); const full = computed(() => current.value === max.value); const formattedTime = computed(() => { @@ -68,7 +69,6 @@ function initTime(): void { initialCurrent.value = props.currentResin || 0; const time = props.recoveryTime; remainedTime.value = typeof time === "string" ? parseInt(time) : time || 0; - initialRecoveryTime.value = remainedTime.value; } function startTimer(): void {