Squashed commit of the following: commit 66d0e5e94c0394d83b47b58bd130ba2addce2930 Author: Sun <95302870@qq.com> Date: Thu Jan 25 13:20:34 2024 +0800 更新1.3.0-beta24-01-25 commit 52a81e5f558b3e7b329f828adbd8255960dd750b Author: Sun <95302870@qq.com> Date: Thu Jan 25 13:13:08 2024 +0800 Squashed commit of the following: commit 908d87357c4e22868eff85f377bb8cd22f3785d7 Author: Sun <95302870@qq.com> Date: Thu Jan 25 13:12:14 2024 +0800 增加前端版本号 commit 8ed2b636476c7a14ae4e1761f7712949b7ce60fc Author: Sun <95302870@qq.com> Date: Thu Jan 25 12:29:49 2024 +0800 增加自动获取前端版本号的git tag commit ba7d70f9cabf020ab9ce682be5e593b649aed071 Author: Sun <95302870@qq.com> Date: Thu Jan 25 10:58:15 2024 +0800 优化代码 commit 104543b96fb4d5f9362d29da22390d9a0565c395 Author: Sun <95302870@qq.com> Date: Wed Jan 24 21:28:31 2024 +0800 增加系统状态组件的部分样式 commit 70c87c94c688a14d3bbe53be191c2186ec469a01 Author: Sun <95302870@qq.com> Date: Wed Jan 24 20:55:05 2024 +0800 时间组件和搜索栏组件增加样式类型 commit 6bab5a264fdb1281763d73bf022335667845dc67 Author: Sun <95302870@qq.com> Date: Wed Jan 24 20:41:33 2024 +0800 将项目列表增加样式并优化减少dom嵌套 commit 99d18df7f0a57ec1cead9bce7b2b4b11427cc2e2 Author: Sun <95302870@qq.com> Date: Wed Jan 24 20:11:07 2024 +0800 增加系统状态、logo等类名并简化部分组件dom commit bf1cc0cc0014f751b6453ebfb357b575b0a54615 Author: Sun <95302870@qq.com> Date: Wed Jan 24 17:17:41 2024 +0800 更新关于页面 commit fceacf58b87b988827f0baa6086e8296c843c495 Author: Sun <95302870@qq.com> Date: Wed Jan 24 14:54:37 2024 +0800 增加隐藏网络模式切换开关 commit e0dcc49f5b23618103c5ee15e13758164d2eddf2 Author: Sun <95302870@qq.com> Date: Wed Jan 24 13:55:28 2024 +0800 优化部分错误码 commit 863cdf0fc1fc406304784d4304ba6be31e5133ff Author: Sun <95302870@qq.com> Date: Wed Jan 24 12:54:55 2024 +0800 声明暴露端口 commit 5b25ef9c194dc0112cd10250c04344dd6f57be27 Author: Sun <95302870@qq.com> Date: Wed Jan 24 12:38:48 2024 +0800 修改命令行所有的输出内容为英文
84 lines
1.9 KiB
Vue
84 lines
1.9 KiB
Vue
<script setup lang="ts">
|
||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||
import { t } from '@/locales'
|
||
|
||
const props = defineProps<{
|
||
hideSecond?: boolean
|
||
}>()
|
||
|
||
interface CurrentDate {
|
||
time: string
|
||
date: string
|
||
week: string
|
||
}
|
||
|
||
const currentDate = ref<CurrentDate>({
|
||
time: '--:--',
|
||
date: '------',
|
||
week: '--',
|
||
})
|
||
|
||
function updateCurrentDate() {
|
||
const now = new Date()
|
||
const hours = String(now.getHours()).padStart(2, '0')
|
||
const minutes = String(now.getMinutes()).padStart(2, '0')
|
||
|
||
if (!props.hideSecond) {
|
||
const seconds = String(now.getSeconds()).padStart(2, '0')
|
||
currentDate.value.time = `${hours}:${minutes}:${seconds}`
|
||
}
|
||
else {
|
||
currentDate.value.time = `${hours}:${minutes}`
|
||
}
|
||
|
||
// 获取当前的日期
|
||
const day = now.getDate()
|
||
const month = now.getMonth() + 1 // 月份从0开始,所以要加1
|
||
// const year = now.getFullYear()
|
||
|
||
const daysOfWeek = [
|
||
t('deskModule.clock.sun'),
|
||
t('deskModule.clock.mon'),
|
||
t('deskModule.clock.tue'),
|
||
t('deskModule.clock.wed'),
|
||
t('deskModule.clock.thu'),
|
||
t('deskModule.clock.fri'),
|
||
t('deskModule.clock.sat'),
|
||
]
|
||
// const daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
|
||
currentDate.value.week = daysOfWeek[now.getDay()]
|
||
currentDate.value.date = `${month}-${day}`
|
||
}
|
||
|
||
const updateClock = () => {
|
||
updateCurrentDate()
|
||
}
|
||
|
||
const intervalId = setInterval(updateClock, 1000)
|
||
|
||
onMounted(() => {
|
||
updateClock()
|
||
updateCurrentDate()
|
||
})
|
||
|
||
onBeforeUnmount(() => {
|
||
clearInterval(intervalId)
|
||
})
|
||
</script>
|
||
|
||
<template>
|
||
<div class="clock w-full text-center">
|
||
<span class="clock-time text-2xl sm:text-2xl md:text-3xl font-[600]">
|
||
{{ currentDate.time }}
|
||
</span>
|
||
<div class="hidden sm:hidden md:block">
|
||
<span class="clock-date mr-1">
|
||
{{ currentDate.date }}
|
||
</span>
|
||
<span class="clock-week">
|
||
{{ currentDate.week }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</template>
|