mirror of
https://github.com/fmhy/edit.git
synced 2025-07-31 00:02:17 +10:00
feat: startpage
This commit is contained in:
parent
6418da63ba
commit
8d6c3ace0b
19 changed files with 7804 additions and 6133 deletions
29
docs/.vitepress/theme/components/startpage/Clock.vue
Normal file
29
docs/.vitepress/theme/components/startpage/Clock.vue
Normal file
|
@ -0,0 +1,29 @@
|
|||
<template>
|
||||
<div class="text-6xl font-bold text-text">
|
||||
{{ timeString }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref } from 'vue'
|
||||
|
||||
const time = ref<Date | null>(null)
|
||||
|
||||
function updateTime() {
|
||||
time.value = new Date()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
updateTime()
|
||||
const interval = setInterval(updateTime, 1000)
|
||||
onUnmounted(() => clearInterval(interval))
|
||||
})
|
||||
|
||||
const timeString = computed(() => {
|
||||
if (!time.value) return '--:--:--'
|
||||
const h = String(time.value.getHours()).padStart(2, '0')
|
||||
const m = String(time.value.getMinutes()).padStart(2, '0')
|
||||
const s = String(time.value.getSeconds()).padStart(2, '0')
|
||||
return `${h}:${m}:${s}`
|
||||
})
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue