diff --git a/frontend/src/components/account/UsageProgressBar.vue b/frontend/src/components/account/UsageProgressBar.vue index 1f7cde1645..c8dc46fa87 100644 --- a/frontend/src/components/account/UsageProgressBar.vue +++ b/frontend/src/components/account/UsageProgressBar.vue @@ -188,13 +188,11 @@ const shouldShowResetTime = computed(() => { // Format reset time const formatResetTime = computed(() => { - // For rolling windows, when utilization is 0%, treat as immediately available. - if (props.showNowWhenIdle && props.utilization <= 0) { - return t('usage.resetNow') + if (!props.resetsAt) { + // Idle rolling window without a known reset time: treat as immediately available. + return props.showNowWhenIdle && props.utilization <= 0 ? t('usage.resetNow') : '-' } - if (!props.resetsAt) return '-' - const date = new Date(props.resetsAt) const diffMs = date.getTime() - now.value.getTime() diff --git a/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts b/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts index e92268e597..7c5016ecba 100644 --- a/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts +++ b/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts @@ -22,7 +22,7 @@ describe('UsageProgressBar', () => { vi.useRealTimers() }) - it('showNowWhenIdle=true 且利用率为 0 时显示“现在”', () => { + it('showNowWhenIdle=true 且利用率为 0 但有未来 resetsAt 时显示倒计时', () => { const wrapper = mount(UsageProgressBar, { props: { label: '5h', @@ -33,8 +33,8 @@ describe('UsageProgressBar', () => { } }) - expect(wrapper.text()).toContain('usage.resetNow') - expect(wrapper.text()).not.toContain('2h 30m') + expect(wrapper.text()).toContain('2h 30m') + expect(wrapper.text()).not.toContain('usage.resetNow') }) it('showNowWhenIdle=true 但利用率大于 0 时显示倒计时', () => {