mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-13 20:03:51 +02:00
31 lines
681 B
Vue
31 lines
681 B
Vue
<template>
|
|
<span>{{ text }}</span>
|
|
</template>
|
|
<script setup>
|
|
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
|
|
|
import { timeToText } from '../shared/utils';
|
|
|
|
const props = defineProps({
|
|
epoch: {
|
|
type: Number,
|
|
required: true
|
|
}
|
|
});
|
|
|
|
const now = ref(Date.now());
|
|
const text = computed(() => {
|
|
return props.epoch ? timeToText(now.value - props.epoch) : '-';
|
|
});
|
|
|
|
let timerId = null;
|
|
onMounted(() => {
|
|
timerId = setInterval(() => {
|
|
now.value = Date.now();
|
|
}, 15000);
|
|
});
|
|
onBeforeUnmount(() => {
|
|
clearInterval(timerId);
|
|
});
|
|
</script>
|