日程卡片基本完成

This commit is contained in:
2026-04-14 17:03:40 +08:00
parent 087cda650c
commit 6eb6e76bfd
3 changed files with 36 additions and 8 deletions
+1 -1
View File
@@ -13,5 +13,5 @@
}
]
},
"lastUpdated": 1776156362292
"lastUpdated": 1776157357538
}
@@ -122,7 +122,7 @@ const navItems = computed(() => [
alt="avatar"
/>
<span class="max-w-24 truncate">{{
userStore.userInfo?userStore.userInfo.Username:userStore.user.Name
userStore.userInfo?.Username || userStore.user?.Name || ''
}}</span>
</button>
<Transition
+34 -6
View File
@@ -71,9 +71,33 @@ function formatTime(dateStr) {
// 格式化日期
function formatDate(dateStr) {
if (!dateStr) return ''
return dateStr
}
// 格式化开始结束日期
function formatDateRange(startDate, endDate) {
if (!startDate) return ''
if (startDate === endDate) {
return startDate
}
// 返回数组用于分行显示
return [startDate, endDate]
}
// 获取星期几
function getWeekday(dateStr) {
if (!dateStr) return ''
const date = new Date(dateStr)
const day = date.getDay()
if (locale.value === 'en') {
const weekdaysEn = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
return weekdaysEn[day]
}
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
return weekdays[day]
}
onMounted(() => {
fetchTodaySchedules()
})
@@ -103,21 +127,25 @@ onMounted(() => {
<ul class="space-y-2">
<li
v-for="schedule in todaySchedules"
:key="schedule.ID"
:key="schedule?.ID"
class="flex items-start gap-3 rounded-lg bg-gray-50 px-3 py-2 dark:bg-dk-base"
>
<span
class="whitespace-nowrap rounded px-2 py-0.5 text-sm font-medium text-white"
:style="{ backgroundColor: schedule.BgColor }"
class="flex flex-col whitespace-nowrap rounded px-2 py-0.5 text-sm font-medium text-white"
:style="{ backgroundColor: schedule?.BgColor || '#999' }"
>
{{ formatDate(schedule.StartDate) }}
<span v-if="schedule?.StartDate !== schedule?.EndDate">
<div>{{ schedule?.StartDate }} {{ getWeekday(schedule?.StartDate) }}</div>
<div>{{ schedule?.EndDate }} {{ getWeekday(schedule?.EndDate) }}</div>
</span>
<span v-else>{{ schedule?.StartDate }} {{ getWeekday(schedule?.StartDate) }}</span>
</span>
<div class="min-w-0 flex-1">
<p class="truncate text-sm font-medium text-gray-800 dark:text-gray-200">
{{ schedule.Title }}
{{ schedule?.Title || '' }}
</p>
<p class="text-xs text-gray-500 dark:text-gray-400">
{{ getUsername(schedule.UserID) }}
{{ getUsername(schedule?.UserID) }}
</p>
</div>
</li>