Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
feat(dashboard): add calendar heatmap
Timothy Yinbe7b2336020a
diff --git a/app/layouts/dashboard.vue b/app/layouts/dashboard.vueindex d1a1ff91..fef43825 100644--- a/app/layouts/dashboard.vue+++ b/app/layouts/dashboard.vue@@ -27,7 +27,8 @@ const { loggedIn, user } = useUserSession()useHead({title: $t('title.dashboard'),- titleTemplate: (title) => `${title ? title + ' | ' : ''}${config.public.APP_TITLE}`,+ titleTemplate: (title) =>+ `${title ? title + ' | ' : ''}${config.public.APP_TITLE}`,})const isMobileMenuOpen = ref(false)@@ -56,7 +57,7 @@ const closeMobileMenu = () => {</script><template>- <div>+ <div class="container mx-auto"><headerv-if="loggedIn"class="w-full px-4 border-b border-default"diff --git a/app/pages/dashboard/index.vue b/app/pages/dashboard/index.vueindex 92433540..dbf9ad11 100644--- a/app/pages/dashboard/index.vue+++ b/app/pages/dashboard/index.vue@@ -1,4 +1,7 @@<script lang="ts" setup>+import { CalendarHeatmap, type CalendarItem } from 'vue3-calendar-heatmap'+import 'vue3-calendar-heatmap/dist/style.css'+definePageMeta({layout: 'dashboard',})@@ -8,6 +11,7 @@ useHead({})const dayjs = useDayjs()+const { photos } = usePhotos()const { data: dashboardStats, refresh: refreshStats } =await useFetch('/api/system/stats')@@ -42,17 +46,28 @@ const systemStatus = computed(() => {return 'healthy'})-// 趋势图表-const chartData = computed(() => {- if (!dashboardStats.value?.trends) return { labels: [], data: [] }+const heatmapData = computed(() => {+ if (!photos.value || photos.value.length === 0) return []++ // 按日期分组统计照片数量+ const dateCountMap = new Map<string, number>()++ photos.value.forEach((photo) => {+ if (photo.dateTaken) {+ const date = dayjs(photo.dateTaken).format('YYYY-M-D')+ const currentCount = dateCountMap.get(date) || 0+ dateCountMap.set(date, currentCount + 1)+ }+ })- return {- labels: dashboardStats.value.trends.map((item) => {- const date = new Date(item.date || '')- return dayjs(date).format('MM-DD')+ const heatmapData = Array.from(dateCountMap.entries()).map(+ ([date, count]) => ({+ date,+ count,}),- data: dashboardStats.value.trends.map((item) => item.count),- }+ )++ return heatmapData})</script>@@ -62,7 +77,6 @@ const chartData = computed(() => {<h1 class="text-2xl font-bold">仪表板概览</h1></div>- <!-- 核心指标条 - 横向布局 --><div class="grid grid-cols-2 lg:grid-cols-4 gap-4"><DashboardIndicatortitle="照片总数"@@ -141,64 +155,42 @@ const chartData = computed(() => {</UCard><!-- 详细统计区域 -->- <div class="grid grid-cols-1 lg:grid-cols-3 gap-4">- <!-- 左侧:照片统计图表 -->- <div class="lg:col-span-2">+ <div class="grid grid-cols-1 lg:grid-cols-3 space-y-4 lg:gap-4">+ <!-- 左侧 -->+ <div class="col-span-2"><UCard>- <template #header>- <div class="flex items-center justify-between pb-1.5">- <h2 class="text-lg font-semibold">新增照片趋势</h2>- <div class="flex gap-2">- <UBadge- color="info"- variant="soft"- >- 本周 {{ dashboardStats?.photos?.thisWeek || 0 }}- </UBadge>- <UBadge- color="success"- variant="soft"- >- 本月 {{ dashboardStats?.photos?.thisMonth || 0 }}- </UBadge>- </div>- </div>- </template>-- <!-- 简单的趋势展示 -->- <div class="space-y-2">- <div- v-for="(trend, index) in dashboardStats?.trends || []"- :key="trend.date"- class="flex items-center gap-3"- >- <div class="text-sm text-neutral-500 dark:text-neutral-400 w-12">- {{ chartData.labels[index] }}- </div>- <UProgress- :model-value="- chartData.data[index] &&- chartData.data.length &&- chartData.data.length > 0- ? Math.max(...chartData.data) > 0- ? (chartData.data[index] / Math.max(...chartData.data)) *- 100- : 0- : 1- "- color="info"- class="flex-1"- />- <div class="text-sm font-medium w-8 text-right">- {{ trend.count }}+ <ClientOnly>+ <CalendarHeatmap+ :values="heatmapData"+ :end-date="new Date()"+ :round="3"+ :no-data-text="'这天没有照片'"+ :tooltip-formatter="+ (item: CalendarItem) => {+ return `${$dayjs(item.date).format('LL')}拍摄了 ${item.count || 0} 张照片`+ }+ "+ :locale="{+ less: '更少',+ more: '更多',+ }"+ :dark-mode="$colorMode.value === 'dark'"+ />+ <template #placeholder>+ <div class="flex items-center justify-center h-[164.5px]">+ <Icon+ name="svg-spinners:180-ring-with-bg"+ class="size-8 opacity-50"+ mode="svg"+ /></div>- </div>- </div>+ </template>+ </ClientOnly></UCard></div><!-- 右侧:系统资源监控 -->- <div class="space-y-4">+ <div class="w-full space-y-4"><!-- 内存使用 --><UCard><template #header>@@ -307,4 +299,17 @@ const chartData = computed(() => {</div></template>-<style scoped></style>+<style>+.vch__day__label,+.vch__month__label,+.vch__legend {+ font-size: var(--text-xs);+ font-weight: var(--font-weight-medium);+ color: var(--color-neutral-500);+}++.vch__day__label,+.vch__month__label {+ font-size: var(--text-xs);+}+</style>diff --git a/package.json b/package.jsonindex 7b246ea2..8430f953 100644--- a/package.json+++ b/package.json@@ -62,9 +62,11 @@"tailwind-merge": "^3.3.1","tailwindcss": "^4.1.12","thumbhash": "^0.1.1",+ "tippy.js": "^6.3.7","unstorage": "^1.15.0","vue": "^3.5.18","vue-router": "^4.5.1",+ "vue3-calendar-heatmap": "^2.0.5","wait-on": "^8.0.4","zod": "^4.1.11"},diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex eca3f8b5..6949af8e 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -125,6 +125,9 @@ importers:thumbhash:specifier: ^0.1.1version: 0.1.1+ tippy.js:+ specifier: ^6.3.7+ version: 6.3.7unstorage:specifier: ^1.15.0version: 1.17.1([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])@@ -134,6 +137,9 @@ importers:vue-router:specifier: ^4.5.1version: 4.5.1([email protected]([email protected]))+ vue3-calendar-heatmap:+ specifier: ^2.0.5wait-on:specifier: ^8.0.4version: 8.0.5@@ -2063,6 +2069,9 @@ packages:'@polka/[email protected]':resolution: {integrity: sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==}+ '@popperjs/[email protected]':+ resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==}+'@poppinss/[email protected]':resolution: {integrity: sha512-FvdDqtcRCtz6hThExcFOgW0cWX+xwSMWcRuQe5ZEb2m7cVQOAVZOIMt+/v9RxGiD9/OY16qJBXK4CVKWAPalBw==}@@ -6601,6 +6610,9 @@ packages:resolution: {integrity: sha512-gRa9gwYU3ECmQYv3lslts5hxuIa90veaEcxDYuu3QGOIAEM2mOZkVHp48ANJuu1CURtRdHKUBY5Lm1tHV+sD4g==}+ resolution: {integrity: sha512-E1d3oP2emgJ9dRQZdf3Kkn0qJgI6ZLpyS5z6ZkY1DF3kaQaBsGZsndEpHwx+eC+tYM41HaSNvNtLx8tU57FzTQ==}+resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}engines: {node: '>=8.0'}@@ -7059,6 +7071,13 @@ packages:peerDependencies:typescript: '>=5.0.0'+ resolution: {integrity: sha512-qvveNQlTS5Aw7AvRLs0zOyu3uP5iGJlXJAnkrkG2ElDdyQ8H1TJhQ8rL702CROjAg16ezIveUY10nCO7lqZ25w==}+ engines: {node: '>=16'}+ peerDependencies:+ tippy.js: ^6.3.7+ vue: ^3.2.29+resolution: {integrity: sha512-xxf9rum9KtOdwdRkiApWL+9hZEMWE90FHh8yS1+KJAiWYh+iGWV1FquPjoO9VUHQ+VIhsCXNNyZ5Sf4++RVZBA==}peerDependencies:@@ -9614,6 +9633,8 @@ snapshots:'@polka/[email protected]': {}+ '@popperjs/[email protected]': {}+'@poppinss/[email protected]':dependencies:kleur: 4.1.5@@ -14638,6 +14659,10 @@ snapshots:+ dependencies:+ '@popperjs/core': 2.11.8+dependencies:is-number: 7.0.0@@ -15131,6 +15156,11 @@ snapshots:'@vue/language-core': 2.2.12([email protected])typescript: 5.9.2+ dependencies:+ tippy.js: 6.3.7+ vue: 3.5.21([email protected])+dependencies:'@vue/compiler-dom': 3.5.21