feat: show function start time

This commit is contained in:
Anthony Fu committed 2021-11-05 12:41:46 +08:00
1 parent c338533e34
commit 6c3ed25a43
2 files changed
+9 -3

No files matched your search

+4 -2
View File
@@ -1,9 +1,11 @@
<script setup lang="ts"> <script setup lang="ts">
const { data } = await useFetch('/api/pageview') const { data } = await useFetch('/api/pageview')
const time = useTimeAgo(computed(() => data.value.startAt))
</script> </script>
<template> <template>
<div op50> <div text-gray>
Pageview: {{ data.pageview }} <span font-500>{{ data.pageview }}</span> page views since <span font-500>{{ time }}</span>
</div> </div>
</template> </template>
+5 -1
View File
@@ -1,3 +1,7 @@
const startAt = Date.now()
let count = 0 let count = 0
export default () => ({ pageview: count++ }) export default () => ({
pageview: count++,
startAt,
})