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): consolidate system status and refine overview cards
Timothy Yinb788cfc4b09f
diff --git a/app/components/dashboard/Indicator.vue b/app/components/dashboard/Indicator.vueindex 5f36b274..86d12c24 100644--- a/app/components/dashboard/Indicator.vue+++ b/app/components/dashboard/Indicator.vue@@ -8,6 +8,7 @@ const props = withDefaults(icon?: stringcolor?: keyof typeof colorSchemesclickable?: boolean+ variant?: 'soft' | 'subtle'}>(),{title: undefined,@@ -15,6 +16,7 @@ const props = withDefaults(icon: undefined,color: 'blue',clickable: false,+ variant: 'soft',},)@@ -77,29 +79,40 @@ const currentScheme = computed(() => colorSchemes[props.color])</script><template>- <div+ <component+ :is="clickable ? 'button' : 'div'"+ :type="clickable ? 'button' : undefined":class="[- 'flex justify-center border rounded-lg p-4',- currentScheme.background,- currentScheme.border,- currentScheme.text,+ 'min-w-0 rounded-lg border p-4 text-left',+ variant === 'subtle'+ ? 'border-default bg-default text-default'+ : [currentScheme.background, currentScheme.border, currentScheme.text],clickable- ? 'cursor-pointer hover:scale-[1.01] transition-transform duration-200'+ ? 'cursor-pointer transition-colors duration-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary': '',+ clickable && variant === 'subtle' ? 'hover:bg-elevated/50' : '',]"@click="clickable ? emit('click') : undefined">- <div class="flex-1 flex items-center justify-between gap-4 overflow-hidden">+ <div class="flex min-w-0 items-center justify-between gap-3"><div class="flex-1 overflow-hidden"><pv-if="title"- class="text-lg opacity-90 font-medium max-w-48 truncate"+ :class="+ variant === 'subtle'+ ? 'text-xs font-medium text-muted'+ : 'text-lg opacity-90 font-medium max-w-48 truncate'+ ">{{ title }}</p><pv-if="!isNil(value)"- class="text-2xl font-bold max-w-full sm:max-w-1/2 truncate"+ :class="+ variant === 'subtle'+ ? 'mt-1.5 break-words text-xl font-semibold tracking-tight tabular-nums'+ : 'text-2xl font-bold max-w-full sm:max-w-1/2 truncate'+ ">{{ value }}</p>@@ -107,10 +120,14 @@ const currentScheme = computed(() => colorSchemes[props.color])<UIconv-if="icon":name="icon"- class="size-8 opacity-80"+ :class="+ variant === 'subtle'+ ? 'size-5 shrink-0 text-dimmed'+ : 'size-8 shrink-0 opacity-80'+ "/></div>- </div>+ </component></template><style scoped></style>diff --git a/app/pages/dashboard/index.vue b/app/pages/dashboard/index.vueindex 7d819200..d3eb5d95 100644--- a/app/pages/dashboard/index.vue+++ b/app/pages/dashboard/index.vue@@ -34,16 +34,16 @@ const refreshData = async () => {useIntervalFn(refreshData, 5000)-const systemStatus = computed(() => {- if (!dashboardStats.value) return 'unknown'-- const memoryUsage = dashboardStats.value.memory- ? (dashboardStats.value.memory.used / dashboardStats.value.memory.total) *- 100- : 0+const memoryUsage = computed(() => {+ const memory = dashboardStats.value?.memory+ if (!memory || memory.total <= 0) return null+ return Math.min(100, Math.max(0, (memory.used / memory.total) * 100))+})- if (memoryUsage > 90) return 'critical'- if (memoryUsage > 70) return 'warning'+const systemStatus = computed(() => {+ if (memoryUsage.value === null) return 'unknown'+ if (memoryUsage.value > 90) return 'critical'+ if (memoryUsage.value > 70) return 'warning'return 'healthy'})@@ -309,13 +309,13 @@ const onShareSite = () => {</template><template #body>- <div class="flex flex-col gap-6">+ <div class="flex flex-col gap-4"><div class="grid grid-cols-2 lg:grid-cols-4 gap-4"><DashboardIndicatordata-tour="dashboard-photos":title="$t('dashboard.overview.indicator.totalPhotos')"icon="tabler:photo"- color="blue"+ variant="subtle":value="dashboardStats?.photos?.total || 0"clickable@click="$router.push('/dashboard/photos')"@@ -323,14 +323,14 @@ const onShareSite = () => {<DashboardIndicator:title="$t('dashboard.overview.indicator.thisMonth')"icon="tabler:photo-plus"- color="green"+ variant="subtle":value="dashboardStats?.photos?.thisMonth || 0"/><DashboardIndicatordata-tour="dashboard-queue":title="$t('dashboard.overview.indicator.queueStatus.title')"icon="tabler:loader"- color="purple"+ variant="subtle":value="(dashboardStats?.workerPool?.activeWorkers || 0) > 0? $t('dashboard.overview.indicator.queueStatus.processing')@@ -342,97 +342,11 @@ const onShareSite = () => {<DashboardIndicator:title="$t('dashboard.overview.indicator.storageUsage')"icon="tabler:database"- color="blue"+ variant="subtle":value="formatBytes(dashboardStats?.storage?.totalSize || 0)"/></div>- <!-- 运行信息 -->- <UCard>- <template #header>- <DashboardSectionHeader- :title="$t('dashboard.overview.section.runtimeInfo.title')"- icon="tabler:server"- />- </template>-- <div class="grid grid-cols-2 md:grid-cols-4 gap-4">- <div>- <p class="text-sm text-neutral-500 dark:text-neutral-400">- {{ $t('dashboard.overview.section.runtimeInfo.version') }}- </p>- <NuxtLink- class="text-lg font-bold hover:text-primary"- target="_blank"- external- :to="`https://github.com/HoshinoSuzumi/chronoframe/releases/tag/v${$config.public.VERSION}`"- >- v{{ $config.public.VERSION }}- </NuxtLink>- </div>- <div>- <p class="text-sm text-neutral-500 dark:text-neutral-400">- {{ $t('dashboard.overview.section.runtimeInfo.uptime') }}- </p>- <p class="text-lg font-bold">- {{- dashboardStats?.uptime- ? $dayjs- .duration(dashboardStats.uptime, 'seconds')- .humanize()- : '-'- }}- </p>- </div>- <div>- <p class="text-sm text-neutral-500 dark:text-neutral-400">- {{ $t('dashboard.overview.section.runtimeInfo.environment') }}- </p>- <UBadge- :color="- dashboardStats?.runningOn === 'docker' ? 'info' : 'success'- "- variant="soft"- >- {{- $t(- `dashboard.overview.section.runtimeInfo.systems.${dashboardStats?.runningOn || 'unknown'}`,- )- }}- </UBadge>- </div>- <!-- <div>- <p class="text-sm text-neutral-500 dark:text-neutral-400">- {{ $t('dashboard.overview.section.runtimeInfo.lastUpdate') }}- </p>- <p class="text-lg font-bold">- <ClientOnly>- {{ $dayjs().fromNow() }}- <template #placeholder>--</template>- </ClientOnly>- </p>- </div> -->- <div>- <p class="text-sm text-neutral-500 dark:text-neutral-400">- {{ $t('dashboard.overview.shareSite.label') }}- </p>- <p class="text-lg font-bold">- <UButton- external- variant="subtle"- size="xs"- color="info"- trailing-icon="tabler:external-link"- data-tour="dashboard-share"- @click="onShareSite"- >- {{ $t('dashboard.overview.shareSite.button') }}- </UButton>- </p>- </div>- </div>- </UCard>-<!-- 详细统计区域 --><div class="grid grid-cols-1 items-start lg:grid-cols-5 gap-4"><!-- 左侧 -->@@ -519,66 +433,12 @@ const onShareSite = () => {<!-- 右侧:系统资源监控 --><div class="min-w-0 lg:col-span-2 w-full space-y-4">- <!-- 内存使用 -->- <UCard>- <template #header>- <DashboardSectionHeader- :title="$t('dashboard.overview.section.memory.title')"- icon="tabler:cpu"- />- </template>-- <div class="space-y-2">- <UProgress- :model-value="- dashboardStats?.memory- ? Math.round(- (dashboardStats.memory.used /- dashboardStats.memory.total) *- 100,- )- : 0- "- :color="- systemStatus === 'healthy'- ? 'success'- : systemStatus === 'warning'- ? 'warning'- : systemStatus === 'critical'- ? 'error'- : 'neutral'- "- class="w-full"- />- <div class="flex justify-between text-sm">- <div class="text-xs text-neutral-500 dark:text-neutral-400">- {{- dashboardStats?.memory- ? `${Math.round((dashboardStats.memory.used / 1024 / 1024 / 1024) * 100) / 100}GB / ${Math.round((dashboardStats.memory.total / 1024 / 1024 / 1024) * 100) / 100}GB`- : $t('dashboard.overview.memoryUnavailable')- }}- </div>- <span>- {{- dashboardStats?.memory- ? Math.round(- (dashboardStats.memory.used /- dashboardStats.memory.total) *- 100,- )- : 0- }}%- </span>- </div>- </div>- </UCard>-- <!-- 队列详情 -->- <UCard>+ <!-- 系统状态 -->+ <UCard class="@container"><template #header><DashboardSectionHeader:title="$t('dashboard.overview.section.queue.title')"- icon="tabler:list-check"+ icon="tabler:server"><span class="flex items-center gap-1.5 text-xs text-muted"><span@@ -601,10 +461,10 @@ const onShareSite = () => {</template><div- class="grid grid-cols-[100px_minmax(0,1fr)] overflow-hidden rounded-lg border border-default"+ class="grid grid-cols-1 @min-[440px]:grid-cols-[100px_minmax(0,1fr)] overflow-hidden rounded-lg border border-default"><div- class="flex flex-col items-center justify-center gap-1 border-r border-default bg-elevated/50 px-2 py-3"+ class="flex items-center justify-center gap-3 border-b border-default bg-elevated/50 px-3 py-3 @min-[440px]:flex-col @min-[440px]:gap-1 @min-[440px]:border-b-0 @min-[440px]:border-r"><div class="relative h-12 w-20"><svg@@ -652,61 +512,68 @@ const onShareSite = () => {</div><div class="grid min-w-0 grid-cols-2 gap-px bg-border"><div- class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 bg-default px-3 py-2.5"+ class="grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-2 gap-y-1 bg-default px-3 py-2.5 @min-[440px]:grid-cols-[auto_minmax(0,1fr)_auto]"><UIconname="tabler:activity"class="size-4 shrink-0 text-muted"/>- <span class="min-w-0 flex-1 text-xs text-muted">{{+ <span class="min-w-0 break-words text-xs text-muted">{{$t('dashboard.overview.section.queue.workers')}}</span>- <span class="text-base font-semibold tabular-nums">{{- (queueDisplayStats?.workerPool?.activeWorkers || 0) +- '/' +- (queueDisplayStats?.workerPool?.totalWorkers || 0)- }}</span>+ <span+ class="col-span-2 min-w-0 break-all text-base font-semibold tabular-nums @min-[440px]:col-span-1 @min-[440px]:text-right"+ >{{+ (queueDisplayStats?.workerPool?.activeWorkers || 0) ++ '/' ++ (queueDisplayStats?.workerPool?.totalWorkers || 0)+ }}</span+ ></div><div- class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 bg-default px-3 py-2.5"+ class="grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-2 gap-y-1 bg-default px-3 py-2.5 @min-[440px]:grid-cols-[auto_minmax(0,1fr)_auto]"><UIconname="tabler:hourglass"class="size-4 shrink-0 text-muted"/>- <span class="min-w-0 flex-1 text-xs text-muted">{{+ <span class="min-w-0 break-words text-xs text-muted">{{$t('dashboard.overview.section.queue.pending')}}</span>- <span class="text-base font-semibold tabular-nums">{{- queueDisplayStats?.queue?.pending || 0- }}</span>+ <span+ class="col-span-2 min-w-0 break-all text-base font-semibold tabular-nums @min-[440px]:col-span-1 @min-[440px]:text-right"+ >{{ queueDisplayStats?.queue?.pending || 0 }}</span+ ></div><div- class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 bg-default px-3 py-2.5"+ class="grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-2 gap-y-1 bg-default px-3 py-2.5 @min-[440px]:grid-cols-[auto_minmax(0,1fr)_auto]"><UIconname="tabler:circle-check"class="size-4 shrink-0 text-muted"/>- <span class="min-w-0 flex-1 text-xs text-muted">{{+ <span class="min-w-0 break-words text-xs text-muted">{{$t('dashboard.overview.section.queue.totalProcessed')}}</span>- <span class="text-base font-semibold tabular-nums">{{- queueDisplayStats?.workerPool?.totalProcessed || 0- }}</span>+ <span+ class="col-span-2 min-w-0 break-all text-base font-semibold tabular-nums @min-[440px]:col-span-1 @min-[440px]:text-right"+ >{{+ queueDisplayStats?.workerPool?.totalProcessed || 0+ }}</span+ ></div><div- class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 bg-default px-3 py-2.5"+ class="grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-2 gap-y-1 bg-default px-3 py-2.5 @min-[440px]:grid-cols-[auto_minmax(0,1fr)_auto]"><UIconname="tabler:circle-x"class="size-4 shrink-0 text-muted"/>- <span class="min-w-0 flex-1 text-xs text-muted">{{+ <span class="min-w-0 break-words text-xs text-muted">{{$t('dashboard.overview.section.queue.totalFailed')}}</span><span- class="text-base font-semibold tabular-nums"+ class="col-span-2 min-w-0 break-all text-base font-semibold tabular-nums @min-[440px]:col-span-1 @min-[440px]:text-right":class="{'text-error':(queueDisplayStats?.workerPool?.totalErrors || 0) > 0,@@ -733,6 +600,139 @@ const onShareSite = () => {class="ml-auto size-4 shrink-0"/></NuxtLink>++ <div+ class="mt-4 space-y-2 rounded-lg border border-default bg-elevated/50 p-3"+ >+ <div class="flex items-center justify-between gap-3">+ <span class="flex items-center gap-2 text-xs text-muted">+ <UIcon+ name="tabler:cpu"+ class="size-4 shrink-0"+ />+ {{ $t('dashboard.overview.section.memory.title') }}+ </span>+ <span class="text-sm font-semibold tabular-nums">+ {{+ memoryUsage === null ? '—' : `${Math.round(memoryUsage)}%`+ }}+ </span>+ </div>+ <UProgress+ :model-value="memoryUsage ?? 0"+ :color="+ systemStatus === 'healthy'+ ? 'success'+ : systemStatus === 'warning'+ ? 'warning'+ : systemStatus === 'critical'+ ? 'error'+ : 'neutral'+ "+ class="w-full"+ />+ <p class="text-xs text-muted tabular-nums">+ {{+ memoryUsage === null+ ? $t('dashboard.overview.memoryUnavailable')+ : `${formatBytes(dashboardStats?.memory?.used || 0)} / ${formatBytes(dashboardStats?.memory?.total || 0)}`+ }}+ </p>+ </div>++ <dl+ class="mt-4 divide-y divide-default rounded-lg border border-default px-3"+ >+ <div class="flex items-center justify-between gap-3 py-3">+ <dt class="flex items-center gap-2 text-xs text-muted">+ <UIcon+ name="tabler:tag"+ class="size-4 shrink-0"+ />+ {{ $t('dashboard.overview.section.runtimeInfo.version') }}+ </dt>+ <dd class="min-w-0 text-xs">+ <NuxtLink+ class="flex items-center gap-1 hover:text-primary"+ target="_blank"+ external+ :to="`https://github.com/HoshinoSuzumi/chronoframe/releases/tag/v${$config.public.VERSION}`"+ >+ v{{ $config.public.VERSION }}+ <UIcon+ name="tabler:external-link"+ class="size-3.5 shrink-0 text-muted"+ />+ </NuxtLink>+ </dd>+ </div>+ <div class="flex items-center justify-between gap-3 py-3">+ <dt class="flex items-center gap-2 text-xs text-muted">+ <UIcon+ name="tabler:clock"+ class="size-4 shrink-0"+ />+ {{ $t('dashboard.overview.section.runtimeInfo.uptime') }}+ </dt>+ <dd class="text-right text-xs tabular-nums">+ {{+ dashboardStats?.uptime != null+ ? $dayjs+ .duration(dashboardStats.uptime, 'seconds')+ .humanize()+ : '—'+ }}+ </dd>+ </div>+ <div class="flex items-center justify-between gap-3 py-3">+ <dt class="flex items-center gap-2 text-xs text-muted">+ <UIcon+ name="tabler:server"+ class="size-4 shrink-0"+ />+ {{+ $t('dashboard.overview.section.runtimeInfo.environment')+ }}+ </dt>+ <dd class="text-right text-xs">+ {{+ $t(+ `dashboard.overview.section.runtimeInfo.systems.${dashboardStats?.runningOn || 'unknown'}`,+ )+ }}+ </dd>+ </div>+ <div class="flex items-start justify-between gap-3 py-3">+ <dt+ class="flex shrink-0 items-center gap-2 text-xs leading-5 text-muted"+ >+ <UIcon+ name="tabler:database"+ class="size-4 shrink-0"+ />+ {{ $t('settings.storage.form.typeLabel') }}+ </dt>+ <dd class="min-w-0 break-words text-right text-xs">+ {{+ dashboardStats?.storage?.activeProvider+ ? `${$t(`settings.storage.providers.${dashboardStats.storage.activeProvider.provider}`)}(${dashboardStats.storage.activeProvider.name})`+ : '—'+ }}+ </dd>+ </div>+ </dl>+ <div class="mt-4 flex flex-wrap items-center justify-end gap-2">+ <UButton+ variant="subtle"+ size="xs"+ color="neutral"+ trailing-icon="tabler:external-link"+ data-tour="dashboard-share"+ @click="onShareSite"+ >+ {{ $t('dashboard.overview.shareSite.button') }}+ </UButton>+ </div></UCard></div></div>diff --git a/i18n/locales/en.json b/i18n/locales/en.jsonindex f78aa148..906b14d5 100644--- a/i18n/locales/en.json+++ b/i18n/locales/en.json@@ -1001,7 +1001,7 @@"title": "Memory Usage"},"queue": {- "title": "Queue Status",+ "title": "System Status","activeWorkers": "Active Workers","totalWorkers": "Total Workers","totalProcessed": "Processed",@@ -1038,7 +1038,6 @@}},"shareSite": {- "label": "Share Your Site","button": "Share Your Site"},"memoryUnavailable": "memory info not available"diff --git a/i18n/locales/ja.json b/i18n/locales/ja.jsonindex e3d2db5c..de0f5fa9 100644--- a/i18n/locales/ja.json+++ b/i18n/locales/ja.json@@ -926,7 +926,7 @@"title": "メモリの使用"},"queue": {- "title": "キューステータス",+ "title": "システム状態","activeWorkers": "アクティブワーカー","totalWorkers": "総 Workers","totalProcessed": "処理",@@ -963,7 +963,6 @@}},"shareSite": {- "label": "サイトを共有","button": "サイトを共有"},"memoryUnavailable": "メモリ情報を取得できません"diff --git a/i18n/locales/ru.json b/i18n/locales/ru.jsonindex 5522b603..384869d2 100644--- a/i18n/locales/ru.json+++ b/i18n/locales/ru.json@@ -1001,7 +1001,7 @@"title": "Использование памяти"},"queue": {- "title": "Состояние очереди",+ "title": "Состояние системы","activeWorkers": "Активные обработчики","totalWorkers": "Всего обработчиков","totalProcessed": "Обработано",@@ -1038,7 +1038,6 @@}},"shareSite": {- "label": "Поделиться сайтом","button": "Поделиться сайтом"},"memoryUnavailable": "Сведения о памяти недоступны"diff --git a/i18n/locales/zh-Hans.json b/i18n/locales/zh-Hans.jsonindex 819f71b9..5a0b3c44 100644--- a/i18n/locales/zh-Hans.json+++ b/i18n/locales/zh-Hans.json@@ -1001,7 +1001,7 @@"title": "内存使用率"},"queue": {- "title": "队列状态",+ "title": "系统状态","activeWorkers": "活跃 Workers","totalWorkers": "总 Workers","totalProcessed": "已处理",@@ -1038,7 +1038,6 @@}},"shareSite": {- "label": "分享你的站点","button": "分享你的站点"},"memoryUnavailable": "无法获取内存信息"diff --git a/i18n/locales/zh-Hant-HK.json b/i18n/locales/zh-Hant-HK.jsonindex 3ebb2d6e..864f3bf0 100644--- a/i18n/locales/zh-Hant-HK.json+++ b/i18n/locales/zh-Hant-HK.json@@ -926,7 +926,7 @@"title": "內存使用率"},"queue": {- "title": "隊列狀態",+ "title": "系統狀態","activeWorkers": "活躍 Workers","totalWorkers": "總 Workers","totalProcessed": "已處理",@@ -963,7 +963,6 @@}},"shareSite": {- "label": "分享你的網站","button": "分享你的網站"},"memoryUnavailable": "無法取得記憶體資訊"diff --git a/i18n/locales/zh-Hant-TW.json b/i18n/locales/zh-Hant-TW.jsonindex 0f68c741..3fa74244 100644--- a/i18n/locales/zh-Hant-TW.json+++ b/i18n/locales/zh-Hant-TW.json@@ -926,7 +926,7 @@"title": "內存使用率"},"queue": {- "title": "隊列狀態",+ "title": "系統狀態","activeWorkers": "活躍 Workers","totalWorkers": "總 Workers","totalProcessed": "已處理",@@ -963,7 +963,6 @@}},"shareSite": {- "label": "分享你的網站","button": "分享你的網站"},"memoryUnavailable": "無法取得記憶體資訊"diff --git a/server/api/system/stats.get.ts b/server/api/system/stats.get.tsindex 75b63cee..829fa76d 100644--- a/server/api/system/stats.get.ts+++ b/server/api/system/stats.get.ts@@ -1,3 +1,4 @@+import { settingsManager } from '~~/server/services/settings/settingsManager'import { sql, gte } from 'drizzle-orm'import * as si from 'systeminformation'import { readFileSync } from 'node:fs'@@ -230,6 +231,8 @@ export default eventHandler(async (event) => {}}+ const activeStorage = await settingsManager.storage.getActiveProvider()+return {uptime: process.uptime() || 0,runningOn: systemInfo,@@ -250,6 +253,9 @@ export default eventHandler(async (event) => {: 0,},storage: {+ activeProvider: activeStorage+ ? { provider: activeStorage.provider, name: activeStorage.name }+ : null,totalSize: storageStats?.totalSize || 0,averageSize: storageStats?.avgSize || 0,maxSize: storageStats?.maxSize || 0,