index.vue
1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<script setup lang="ts">
import { useIntervalFn } from '@vueuse/core'
import { computed, ref } from 'vue'
import { dateUtil } from '@/utils/dateUtil'
import { DateFormatEnum } from '@/enums/timeEnum'
import type { CreateComponentType } from '@/core/Library/types'
import { useTranslation } from '@/hooks/useTranslation'
defineProps<{
config: CreateComponentType
}>()
const getNowDate = () => `${dateUtil().format('YYYY/MM/DD')} ${dateUtil().format(DateFormatEnum.HH_MM_SS)}`
const { t } = useTranslation()
const date = ref<string>(getNowDate())
const weekI18nKey = [
'clockSunday',
'clockMonday',
'clockTuesday',
'clockWednesday',
'clockThursday',
'clockFriday',
'clockSaturday',
]
const getWeek = computed(
() => {
const index = dateUtil().day()
return t(weekI18nKey[index])
},
)
useIntervalFn(() => {
date.value = getNowDate()
}, 1000)
</script>
<template>
<main class="w-full h-full flex flex-col justify-center items-center overflow-hidden">
<div class="text-1em">
{{ date.split(' ')?.[0] }} {{ getWeek }}
</div>
<div class="p-1 text-2em">
{{ date.split(' ')?.[1] }}
</div>
</main>
</template>