From 19b770c948818e151a29ad485ab8d05bc78165a9 Mon Sep 17 00:00:00 2001 From: Kaxi <1042864399@qq.com> Date: Mon, 29 Jun 2026 23:46:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=94=BE=E5=81=87=E5=80=92=E8=AE=A1=E6=97=B6=EF=BC=8C=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E6=97=8B=E8=BD=AC=E5=8A=A8=E7=94=BB=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- pages/index.vue | 61 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index 005b158..b61d962 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -2,6 +2,42 @@ import { Icon } from '@iconify/vue' import { siteConfig } from '~/config/site' +const now = new Date() +const today = new Date(now.getFullYear(), now.getMonth(), now.getDate()) + +// 下一个周六或周日 +const dayOfWeek = today.getDay() +const daysToSat = dayOfWeek === 6 ? 0 : (6 - dayOfWeek + 7) % 7 +const nextWeekend = new Date(today) +nextWeekend.setDate(today.getDate() + daysToSat) + +const weekendDays = daysUntil(nextWeekend) + +// 从 API 获取法定节假日 +const { data: holidaysData } = await useAsyncData('holidays', () => + $fetch('https://timor.tech/api/holiday/year/' + today.getFullYear()).catch(() => null) +) + +const nextHoliday = computed(() => { + if (!holidaysData.value) return null + const list = holidaysData.value?.holiday + if (!list) return null + const entries = Object.values(list) as any[] + const upcoming = entries + .filter((h: any) => h.date && new Date(h.date + 'T00:00:00') >= today) + .sort((a: any, b: any) => a.date.localeCompare(b.date)) + return upcoming[0] || null +}) + +const holidayDays = computed(() => { + if (!nextHoliday.value) return null + return daysUntil(new Date(nextHoliday.value.date + 'T00:00:00')) +}) + +function daysUntil(d: Date): number { + return Math.ceil((d.getTime() - today.getTime()) / 86400000) +} + useHead({ script: [ { src: '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js', async: true, defer: true }, @@ -80,8 +116,29 @@ onMounted(() => {

+ +
+
+
+
+ + 周末 + {{ weekendDays }} 天 +
+ +
+
+
+ -
+
社交 @@ -107,7 +164,7 @@ onMounted(() => {
-
+
导航