mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-09 09:34:46 +08:00
fix(review): address Copilot PR feedback
- Add compile-time interface assertion for sessionWindowMockRepo - Fix flaky fallback test by capturing time.Now() before calling UpdateSessionWindow - Replace stale hardcoded timestamps with dynamic future values - Add millisecond detection and bounds validation for reset header timestamp - Use pause/resume pattern for interval in UsageProgressBar to avoid idle timers on large lists - Fix gofmt comment alignment Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useIntervalFn } from '@vueuse/core'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { WindowStats } from '@/types'
|
||||
@@ -72,11 +72,28 @@ const props = defineProps<{
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
// Reactive clock for countdown (updates every 60s)
|
||||
// Reactive clock for countdown — only runs when a reset time is shown,
|
||||
// to avoid creating many idle timers across large account lists.
|
||||
const now = ref(new Date())
|
||||
useIntervalFn(() => {
|
||||
now.value = new Date()
|
||||
}, 60_000)
|
||||
const { pause: pauseClock, resume: resumeClock } = useIntervalFn(
|
||||
() => {
|
||||
now.value = new Date()
|
||||
},
|
||||
60_000,
|
||||
{ immediate: false },
|
||||
)
|
||||
if (props.resetsAt) resumeClock()
|
||||
watch(
|
||||
() => props.resetsAt,
|
||||
(val) => {
|
||||
if (val) {
|
||||
now.value = new Date()
|
||||
resumeClock()
|
||||
} else {
|
||||
pauseClock()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
// Label background colors
|
||||
const labelClass = computed(() => {
|
||||
|
||||
Reference in New Issue
Block a user