mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-08 17:14:45 +08:00
fix(usage): use real reset header for session window instead of prediction
The 5h window reset time displayed for Setup Token accounts was inaccurate because UpdateSessionWindow predicted the window end as "current hour + 5h" instead of reading the actual `anthropic-ratelimit-unified-5h-reset` response header. This caused the countdown to differ from the official Claude page. Backend: parse the reset header (Unix timestamp) and use it as the real window end, falling back to the hour-truncated prediction only when the header is absent. Also correct stale predictions when a subsequent request provides the real reset time. Frontend: add a reactive 60s timer so the reset countdown in UsageProgressBar ticks down in real-time instead of freezing at the initial value. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,7 +56,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useIntervalFn } from '@vueuse/core'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { WindowStats } from '@/types'
|
||||
import { formatCompactNumber } from '@/utils/format'
|
||||
@@ -71,6 +72,12 @@ const props = defineProps<{
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
// Reactive clock for countdown (updates every 60s)
|
||||
const now = ref(new Date())
|
||||
useIntervalFn(() => {
|
||||
now.value = new Date()
|
||||
}, 60_000)
|
||||
|
||||
// Label background colors
|
||||
const labelClass = computed(() => {
|
||||
const colors = {
|
||||
@@ -119,8 +126,7 @@ const displayPercent = computed(() => {
|
||||
const formatResetTime = computed(() => {
|
||||
if (!props.resetsAt) return '-'
|
||||
const date = new Date(props.resetsAt)
|
||||
const now = new Date()
|
||||
const diffMs = date.getTime() - now.getTime()
|
||||
const diffMs = date.getTime() - now.value.getTime()
|
||||
|
||||
if (diffMs <= 0) return '现在'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user