mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-23 00:33:50 +02:00
use vueuse
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
<span>{{ text }}</span>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { useNow } from '@vueuse/core';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { timeToText } from '../shared/utils';
|
||||
|
||||
@@ -13,18 +14,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
const now = ref(Date.now());
|
||||
const now = useNow({ interval: 15000 });
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user