Update MkTime.vue

This commit is contained in:
syuilo 2023-01-06 16:58:43 +09:00
parent 513cef50a2
commit 457670e730

View file

@ -36,23 +36,21 @@ const relative = $computed(() => {
i18n.ts._ago.future);
});
let tickId: number;
function tick() {
now = new Date();
const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/;
const next = ago < 60 ? 10000 : ago < 3600 ? 60000 : 180000;
tickId = window.setTimeout(() => {
window.requestAnimationFrame(tick);
}, next);
tickId = window.setTimeout(tick, next);
}
let tickId: number;
if (props.mode === 'relative' || props.mode === 'detail') {
tickId = window.requestAnimationFrame(tick);
tick();
onUnmounted(() => {
window.cancelAnimationFrame(tickId);
window.clearTimeout(tickId);
});
}
</script>