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(console): share photo library layouts across editions
HoshinoSuzumi8850d34ae2b5
diff --git a/apps/cloud/app/components/CloudPhotoLibrary.vue b/apps/cloud/app/components/CloudPhotoLibrary.vueindex cecdee8f..4a9a1bf4 100644--- a/apps/cloud/app/components/CloudPhotoLibrary.vue+++ b/apps/cloud/app/components/CloudPhotoLibrary.vue@@ -1,24 +1,14 @@<script setup lang="ts">import {- ArrowUpDown as ButtonIconArrowUpDown,- Columns3,- LayoutList,- LayoutGrid,- Ellipsis as ButtonIconEllipsis,- Filter as ButtonIconFilter,FolderPlus as ButtonIconFolderPlus,- RefreshCw as ButtonIconRefreshCw,Trash2 as ButtonIconTrash2,- Upload as ButtonIconUpload,} from 'lucide-vue-next'import { useLocalStorage } from '@vueuse/core'import { uploadQuotaGate } from '../utils/quota-gate'-import { DASHBOARD_PHOTO_COLUMN_IDS } from '#console/composables/useDashboardPhotoColumnVisibility'+import { photoLibraryPresentation } from '#console/utils/photoLibraryPresentation'const { t, locale } = useI18n()const processingText = (en: string, zh: string) =>locale.value === 'zh-Hans' ? zh : en-const dayjs = useDayjs()-const locationLabel = useLocationLabel()import type { Photo } from '@chronoframe/contracts/resources'import type { TableColumn } from '@nuxt/ui'@@ -27,7 +17,6 @@ const {message,failed,albums,- jobs,loading,ready,admin,@@ -93,10 +82,9 @@ const rows = computed(() => {const columnVisibility = useDashboardPhotoColumnVisibility({storageKey: 'cloud-photos-column-visibility',legacyStorageKey: 'dashboard-photos-column-visibility',- hidden: ['id'],- locked: ['thumbnailUrl', 'actions'],+ locked: ['thumbnailUrl', 'id', 'actions'],})-const reactions = ref<Record<string, number> | null>(null)+const reactions = ref<Record<string, Record<string, number>>>({})watch(photos,async (_, __, onCleanup) => {@@ -105,12 +93,12 @@ watch(active = false})try {- const counts = await api<Record<string, number>>(- base.value + '/photos/reactions',+ const counts = await api<Record<string, Record<string, number>>>(+ base.value + '/photos/reactions?detailed=1',)if (active) reactions.value = counts} catch {- if (active) reactions.value = null+ if (active) reactions.value = {}}},{ immediate: true },@@ -122,29 +110,16 @@ function openPreviewOriginal() {if (url) window.open(url, '_blank', 'noopener,noreferrer')}const chosen = computed(() => rows.value.filter((p) => selection.value[p.id]))+const photoColumns = usePhotoTableColumns({+ preview: (photo) => {+ preview.value = photo+ },+ reactions,+})const columns = computed<TableColumn<Photo>[]>(() => [{ id: 'select', header: '', size: 32, enableHiding: false },- ...DASHBOARD_PHOTO_COLUMN_IDS.filter(- (key) => key !== 'actions' && key !== 'lastModified',- ).map((key) => ({- id: key,- enableHiding: key !== 'thumbnailUrl',- accessorFn: (photo: Photo) =>- key === 'colorSpace' ? photo.exif?.ColorSpace : photo[key as keyof Photo],- header: t(- 'dashboard.photos.table.columns.' +- (key === 'thumbnailUrl' ? 'thumbnail.title' : key),- ),- })),- {- id: 'actions',- enableHiding: false,- header: () => h('span', { class: 'sr-only' }, t('cloud.dashboard.actions')),- },+ ...photoColumns.value,])-const pendingJobs = computed(() =>- jobs.value.filter((j) => j.state !== 'succeeded'),-)async function edit(photo: Photo) {editPhoto.id = photo.ideditor.value = true@@ -333,312 +308,234 @@ watch(</script><template><section- aria-labelledby="library-heading"- class="cf-library"+ :aria-label="$t('cloud.messages.photoLibrary')"+ class="min-w-0 font-sans flex h-full min-h-0 flex-col">- <div class="cf-library-heading">- <div>- <h2 id="library-heading">{{ $t('cloud.messages.photoLibrary') }}</h2>- <p>- {{- $t('cloud.ui.photoQueue', {- count: photos.length,- processing: pendingJobs.length,- })- }}- </p>- </div>- <CfButton- v-if="admin"- :icon="ButtonIconUpload"- :disabled="!uploadAdmission.allowed || !!quota.error.value"- @click="openUpload"- >{{ $t('cloud.messages.upload') }}</CfButton- >- </div>- <CloudQuotaNotice- v-if="- admin &&- (quota.error.value ||- (uploadAdmission.reason && uploadAdmission.reason !== 'checking'))- "- :reason="uploadAdmission.reason"- :error="!!quota.error.value"- @retry="quota.refresh()"- />- <div class="cf-library-toolbar">- <UInput- v-model="search"- icon="i-lucide-search"- :placeholder="$t('cloud.messages.searchPhotographs')"- :aria-label="$t('cloud.messages.searchPhotographs2')"- class="cf-library-search"- /><OverlayFilterPopover- ><CfButton- :variant="hasActiveFilters ? 'soft' : 'secondary'"- :icon="ButtonIconFilter"- >{{ $t('cloud.messages.filters') }}</CfButton- ></OverlayFilterPopover- ><OverlaySortPopover- ><CfButton- variant="secondary"- :icon="ButtonIconArrowUpDown"- >{{ $t('cloud.messages.sort') }}</CfButton- ></OverlaySortPopover- ><CfButton- variant="ghost"- :icon="ButtonIconRefreshCw"- :aria-label="$t('cloud.messages.refreshPhotographs')"- :loading="loading"- @click="refreshMedia"- />- <div- role="group"- :aria-label="$t('cloud.ui.libraryLayout')"- class="flex gap-1"- >- <CfButton- :variant="layout === 'list' ? 'soft' : 'secondary'"- :icon="LayoutList"- :aria-pressed="layout !== 'masonry'"- @click="layout = 'list'"- >{{ $t('cloud.ui.listLayout') }}</CfButton- >- <CfButton- :variant="layout === 'masonry' ? 'soft' : 'secondary'"- :icon="LayoutGrid"- :aria-pressed="layout === 'masonry'"- @click="layout = 'masonry'"- >{{ $t('cloud.ui.masonryLayout') }}</CfButton- >- </div>- <UDropdownMenu- v-if="layout !== 'masonry'"- :items="- columns- .filter(- (c) =>- c.id && !['select', 'thumbnailUrl', 'actions'].includes(c.id),- )- .map((c) => ({- label: String(c.header),- type: 'checkbox' as const,- checked: columnVisibility[c.id as keyof typeof columnVisibility],- onUpdateChecked: (checked: boolean) => {- columnVisibility[c.id as keyof typeof columnVisibility] =- checked- },- onSelect: (event: Event) => event.preventDefault(),- }))- "- >- <CfButton- variant="secondary"- :icon="Columns3"- >{{ $t('dashboard.photos.table.columnVisibility.button') }}</CfButton- >- </UDropdownMenu>- </div>- <ConsoleSelectionToolbar- :count="chosen.length"- :total="rows.length"- teleport+ <UDashboardNavbar+ :toggle="false"+ :title="$t('dashboard.photos.toolbar.title')">- <CfButton- v-if="admin"- size="sm"- variant="ghost"- :icon="ButtonIconFolderPlus"- @click="albumOpen = true"- >{{ $t('cloud.messages.addToAlbum') }}</CfButton- ><CfButton- variant="ghost"- class="cf-bulk-delete"- v-if="admin"- size="sm"- :icon="ButtonIconTrash2"- @click="deleteOpen = true"- >{{ $t('cloud.messages.delete') }}</CfButton- ><CfButton- size="sm"- variant="ghost"- @click="selection = {}"- >{{ $t('cloud.messages.clear') }}</CfButton- >- <CfButton- v-if="admin"- size="sm"- variant="ghost"- @click="openProcessing(chosen)"- >{{ processingText('Process selected', '处理所选照片') }}</CfButton- >- </ConsoleSelectionToolbar>- <CloudPhotoMasonry- v-if="layout === 'masonry' && rows.length"- v-model:selection="selection"- :photos="rows"- :actions="actions"- @preview="preview = $event"- />- <CfTable- v-else- class="cf-library-table"- v-model:column-visibility="columnVisibility"- :data="rows"- :columns="columns"- :loading="loading && !photos.length"- :get-row-id="(row: Photo) => row.id"- ><template #select-header- ><UCheckbox- :model-value="- chosen.length && chosen.length < rows.length- ? 'indeterminate'- : rows.length > 0 && chosen.length === rows.length- "- :aria-label="$t('cloud.messages.selectAllPhotographs')"- @update:model-value="- (v) => {- selection =- v === true- ? Object.fromEntries(rows.map((p) => [p.id, true]))- : {}- }- " /></template- ><template #select-cell="{ row }"- ><UCheckbox- :model-value="!!selection[row.original.id]"- :aria-label="- $t('cloud.ui.selectNamed', { title: row.original.title })- "- @update:model-value="- (v) => (selection[row.original.id] = !!v)- " /></template- ><template #thumbnailUrl-cell="{ row }"- ><UButton- variant="ghost"- color="neutral"- class="cf-library-thumb"- :aria-label="- $t('cloud.ui.previewNamed', { title: row.original.title })- "- @click="preview = row.original"+ <template #right>+ <UButton+ v-if="admin"+ icon="tabler:cloud-upload"+ :disabled="!uploadAdmission.allowed || !!quota.error.value"+ @click="openUpload">- <ThumbImage- :src="row.original.thumbnailUrl || row.original.originalUrl || ''"- :thumbhash="row.original.thumbnailHash || ''"- :alt="row.original.title"- /><span- v-if="row.original.isLivePhoto"- class="cf-live-label"- >{{ $t('cloud.messages.live') }}</span- >- </UButton></template- ><template #title-cell="{ row }"- ><UButton- variant="ghost"- color="neutral"- class="cf-photo-title"- @click="preview = row.original"- >- {{ row.original.title }}</UButton- ><span class="cf-photo-dimensions"- >{{ row.original.width }} × {{ row.original.height }}</span- ></template- ><template #tags-cell="{ row }"- ><div class="cf-tag-list">- <UBadge- v-for="tag in (row.original.tags ?? []).slice(0, 3)"- :key="tag"- color="neutral"- variant="soft"- size="sm"- >{{ tag }}</UBadge- ><span- v-if="!row.original.tags?.length"- class="text-muted"- >—</span- >- </div></template- ><template #rating-cell="{ row }">- <Rating- v-if="row.original.exif?.Rating != null"- :model-value="row.original.exif.Rating"- readonly- size="xs"- />- <span v-else>—</span> </template- ><template #isLivePhoto-cell="{ row }">- <span>{{- row.original.isLivePhoto- ? $t('ui.livePhoto')- : $t('dashboard.photos.table.cells.staticPhoto')- }}</span> </template- ><template #location-cell="{ row }">- <span>{{- row.original.exif?.GPSLongitude != null &&- row.original.exif?.GPSLatitude != null- ? locationLabel(row.original) ||- $t('dashboard.photos.table.cells.unknown')- : $t('dashboard.photos.table.cells.noGps')- }}</span> </template- ><template #dateTaken-cell="{ row }">- <span class="cf-library-date">{{- row.original.dateTaken- ? dayjs(row.original.dateTaken).format('YYYY-MM-DD HH:mm:ss')- : '—'- }}</span> </template- ><template #colorSpace-cell="{ row }">- <span>{{ row.original.exif?.ColorSpace ?? '—' }}</span> </template- ><template #reactions-cell="{ row }"- ><span>{{- reactions ? reactions[row.original.id] || 0 : '—'- }}</span></template- >- <template #fileSize-cell="{ row }">- <span>{{- row.original.fileSize != null- ? formatBytes(row.original.fileSize)- : '—'- }}</span>+ {{ $t('dashboard.photos.buttons.upload') }}+ </UButton></template>- <template #actions-cell="{ row }"- ><UDropdownMenu :items="actions(row.original)"- ><CfButton- variant="ghost"- :icon="ButtonIconEllipsis"- :aria-label="- $t('cloud.ui.actionsNamed', { title: row.original.title })- " /></UDropdownMenu></template- ><template #empty- ><div class="cf-library-empty">- <UIcon- name="i-lucide-images"- class="size-8"- />- <h3>- {{- search- ? $t('cloud.messages.noMatchingPhotographs')- : $t('cloud.messages.yourLibraryStartsHere')- }}- </h3>- <p>- {{- search- ? $t('cloud.messages.tryAnotherSearchOrClearYourFilters')- : $t('cloud.messages.uploadPhotographsToStartTellingYourStory')- }}- </p>- <CfButton- v-if="admin && !photos.length"- variant="soft"- :disabled="!uploadAdmission.allowed || !!quota.error.value"- @click="openUpload"- >{{ $t('cloud.messages.upload') }}</CfButton- >- </div></template- ></CfTable- >+ </UDashboardNavbar>+ <div class="flex flex-1 min-w-0 min-h-0 p-4 sm:p-6">+ <div :class="photoLibraryPresentation.body">+ <CloudQuotaNotice+ v-if="+ admin &&+ (quota.error.value ||+ (uploadAdmission.reason && uploadAdmission.reason !== 'checking'))+ "+ :reason="uploadAdmission.reason"+ :error="!!quota.error.value"+ @retry="quota.refresh()"+ />+ <div :class="photoLibraryPresentation.panel">+ <div :class="photoLibraryPresentation.toolbar">+ <ConsolePhotoLibrarySummary :photos="rows" />+ <div class="min-w-0 flex flex-wrap items-center gap-2">+ <UInput+ v-model="search"+ icon="i-lucide-search"+ :placeholder="$t('cloud.messages.searchPhotographs')"+ :aria-label="$t('cloud.messages.searchPhotographs2')"+ class="cf-library-search"+ /><OverlayFilterPopover+ ><UButton+ size="sm"+ :variant="'soft'"+ :color="hasActiveFilters ? 'info' : 'neutral'"+ icon="tabler:filter"+ >{{ $t('cloud.messages.filters') }}</UButton+ ></OverlayFilterPopover+ ><OverlaySortPopover+ ><UButton+ variant="outline"+ icon="tabler:arrows-sort"+ >{{ $t('cloud.messages.sort') }}</UButton+ ></OverlaySortPopover+ ><UButton+ variant="ghost"+ icon="tabler:refresh"+ :aria-label="$t('cloud.messages.refreshPhotographs')"+ :loading="loading"+ @click="refreshMedia"+ />+ <ConsolePhotoLayoutSwitch v-model="layout" />+ <UDropdownMenu+ v-if="layout !== 'masonry'"+ :items="+ columns+ .filter(+ (c) =>+ !['select', 'thumbnailUrl', 'id', 'actions'].includes(+ String(+ c.id ?? ('accessorKey' in c ? c.accessorKey : ''),+ ),+ ),+ )+ .map((c) => {+ const id = String(+ c.id ?? ('accessorKey' in c ? c.accessorKey : ''),+ )+ return {+ label: String(c.header),+ type: 'checkbox' as const,+ checked:+ columnVisibility[id as keyof typeof columnVisibility],+ onUpdateChecked: (checked: boolean) => {+ columnVisibility[+ id as keyof typeof columnVisibility+ ] = checked+ },+ onSelect: (event: Event) => event.preventDefault(),+ }+ })+ "+ >+ <UButton+ variant="outline"+ icon="tabler:columns-3"+ >{{+ $t('dashboard.photos.table.columnVisibility.button')+ }}</UButton+ >+ </UDropdownMenu>+ </div>+ </div>+ <div :class="photoLibraryPresentation.content">+ <ConsoleSelectionToolbar+ :count="chosen.length"+ :total="rows.length"+ teleport+ >+ <CfButton+ v-if="admin"+ size="sm"+ variant="ghost"+ :icon="ButtonIconFolderPlus"+ @click="albumOpen = true"+ >{{ $t('cloud.messages.addToAlbum') }}</CfButton+ ><CfButton+ variant="ghost"+ class="cf-bulk-delete"+ v-if="admin"+ size="sm"+ :icon="ButtonIconTrash2"+ @click="deleteOpen = true"+ >{{ $t('cloud.messages.delete') }}</CfButton+ ><CfButton+ size="sm"+ variant="ghost"+ @click="selection = {}"+ >{{ $t('cloud.messages.clear') }}</CfButton+ >+ <CfButton+ v-if="admin"+ size="sm"+ variant="ghost"+ @click="openProcessing(chosen)"+ >{{+ processingText('Process selected', '处理所选照片')+ }}</CfButton+ >+ </ConsoleSelectionToolbar>+ <ConsolePhotoMasonry+ class="overflow-auto p-3"+ v-if="layout === 'masonry' && rows.length"+ v-model:selection="selection"+ :photos="rows"+ :actions="actions"+ @preview="preview = $event"+ />+ <ConsolePhotoTable+ v-else+ v-model:row-selection="selection"+ v-model:column-visibility="columnVisibility"+ :data="rows"+ :columns="columns"+ :loading="loading && !photos.length"+ :get-row-id="(row: Photo) => row.id"+ ><template #select-header+ ><UCheckbox+ :model-value="+ chosen.length && chosen.length < rows.length+ ? 'indeterminate'+ : rows.length > 0 && chosen.length === rows.length+ "+ :aria-label="$t('cloud.messages.selectAllPhotographs')"+ @update:model-value="+ (v) => {+ selection =+ v === true+ ? Object.fromEntries(rows.map((p) => [p.id, true]))+ : {}+ }+ " /></template+ ><template #select-cell="{ row }"+ ><UCheckbox+ :model-value="!!selection[row.original.id]"+ :aria-label="+ $t('cloud.ui.selectNamed', { title: row.original.title })+ "+ @update:model-value="+ (v) => (selection[row.original.id] = !!v)+ "+ /></template>+ <template #actions-cell="{ row }">+ <ConsolePhotoTableActions+ :items="actions(row.original)"+ :label="+ $t('cloud.ui.actionsNamed', { title: row.original.title })+ "+ />+ </template>+ <template #empty+ ><div class="cf-library-empty">+ <UIcon+ name="i-lucide-images"+ class="size-8"+ />+ <h3>+ {{+ search+ ? $t('cloud.messages.noMatchingPhotographs')+ : $t('cloud.messages.yourLibraryStartsHere')+ }}+ </h3>+ <p>+ {{+ search+ ? $t(+ 'cloud.messages.tryAnotherSearchOrClearYourFilters',+ )+ : $t(+ 'cloud.messages.uploadPhotographsToStartTellingYourStory',+ )+ }}+ </p>+ <CfButton+ v-if="admin && !photos.length"+ variant="soft"+ :disabled="!uploadAdmission.allowed || !!quota.error.value"+ @click="openUpload"+ >{{ $t('cloud.messages.upload') }}</CfButton+ >+ </div></template+ ></ConsolePhotoTable+ >+ </div>+ </div>+ </div>+ </div><USlideoverv-model:open="editor":title="$t('cloud.messages.editPhotograph')"diff --git a/apps/cloud/app/components/CloudPortalShell.vue b/apps/cloud/app/components/CloudPortalShell.vueindex d11814d0..8d36adce 100644--- a/apps/cloud/app/components/CloudPortalShell.vue+++ b/apps/cloud/app/components/CloudPortalShell.vue@@ -32,6 +32,9 @@ useCloudSiteSubscription()</script><template><CfAppShell+ :class="{+ 'cf-photo-library-shell': /^\/sites\/\d+\/photos\/?$/.test(route.path),+ }":navigation-label="$t('cloud.messages.navigation')":navigation-description="$t('cloud.messages.yourWorkspaceAndSiteNavigation')@@ -60,3 +63,22 @@ useCloudSiteSubscription()<slot /></CfAppShell></template>++<style scoped>+.cf-photo-library-shell {+ height: 100dvh;+ overflow: hidden;+}+.cf-photo-library-shell :deep(.cf-portal-main) {+ min-height: 0;+ padding: 0;+ overflow: hidden;+}+.cf-photo-library-shell :deep(.cf-portal-content) {+ max-width: none;+ display: flex;+ flex-direction: column;+ height: 100%;+ min-height: 0;+}+</style>diff --git a/apps/cloud/server/api/sites/[siteId]/media/[...operation].ts b/apps/cloud/server/api/sites/[siteId]/media/[...operation].tsindex 98d5a4f7..ccd6faf9 100644--- a/apps/cloud/server/api/sites/[siteId]/media/[...operation].ts+++ b/apps/cloud/server/api/sites/[siteId]/media/[...operation].ts@@ -622,11 +622,24 @@ export default definePlatformHandler(async (event) => {!action &&event.method === 'GET') {- const counts = await sql<{ photo_id: string; total: number }>(- 'SELECT r.photo_id, COUNT(*) AS total FROM platform_photo_reactions r JOIN cloud_photos p ON p.site_id=r.site_id AND p.id=r.photo_id WHERE r.site_id=? AND p.deleted=0 GROUP BY r.photo_id',+ const counts = await sql<{+ photo_id: string+ reaction_type: string+ total: number+ }>(+ 'SELECT r.photo_id, r.reaction_type, COUNT(*) AS total FROM platform_photo_reactions r JOIN cloud_photos p ON p.site_id=r.site_id AND p.id=r.photo_id WHERE r.site_id=? AND p.deleted=0 GROUP BY r.photo_id,r.reaction_type',siteId,)- return Object.fromEntries(counts.map((row) => [row.photo_id, row.total]))+ if (getQuery(event).detailed === '1') {+ const breakdown: Record<string, Record<string, number>> = {}+ for (const row of counts)+ (breakdown[row.photo_id] ??= {})[row.reaction_type] = row.total+ return breakdown+ }+ const totals: Record<string, number> = {}+ for (const row of counts)+ totals[row.photo_id] = (totals[row.photo_id] ?? 0) + row.total+ return totals}if (kind === 'photos' && !id && event.method === 'GET')return {diff --git a/packages/console/app/components/ConsolePhotoLayoutSwitch.vue b/packages/console/app/components/ConsolePhotoLayoutSwitch.vuenew file mode 100644index 00000000..9ab1e7c0--- /dev/null+++ b/packages/console/app/components/ConsolePhotoLayoutSwitch.vue@@ -0,0 +1,31 @@+<script setup lang="ts">+const layout = defineModel<'list' | 'masonry'>({ required: true })+</script>+<template>+ <div+ role="group"+ :aria-label="$t('dashboard.photos.layouts.label')"+ class="flex gap-1"+ >+ <UButton+ size="sm"+ class="pointer-coarse:min-h-11"+ color="neutral"+ :variant="layout === 'masonry' ? 'outline' : 'soft'"+ icon="tabler:list"+ :aria-pressed="layout !== 'masonry'"+ @click="layout = 'list'"+ >{{ $t('dashboard.photos.layouts.list') }}</UButton+ >+ <UButton+ size="sm"+ class="pointer-coarse:min-h-11"+ color="neutral"+ :variant="layout === 'masonry' ? 'soft' : 'outline'"+ icon="tabler:layout-grid"+ :aria-pressed="layout === 'masonry'"+ @click="layout = 'masonry'"+ >{{ $t('dashboard.photos.layouts.masonry') }}</UButton+ >+ </div>+</template>diff --git a/packages/console/app/components/ConsolePhotoLibrarySummary.vue b/packages/console/app/components/ConsolePhotoLibrarySummary.vuenew file mode 100644index 00000000..9b48e22f--- /dev/null+++ b/packages/console/app/components/ConsolePhotoLibrarySummary.vue@@ -0,0 +1,51 @@+<script setup lang="ts">+import type { Photo } from '@chronoframe/contracts/resources'+const props = defineProps<{ photos: Photo[] }>()+const livePhotoStats = computed(() => ({+ livePhotos: props.photos.filter((photo) => photo.isLivePhoto).length,+ staticPhotos: props.photos.filter((photo) => !photo.isLivePhoto).length,+}))+</script>+<template>+ <div class="flex items-center gap-3">+ <div+ class="flex size-8 items-center justify-center rounded-[10px] bg-neutral-200/50 dark:bg-neutral-800/50 border border-neutral-200/50 dark:border-neutral-700/50"+ >+ <UIcon+ name="tabler:photo"+ class="size-4.5 text-neutral-600 dark:text-neutral-400"+ />+ </div>+ <span+ class="font-semibold text-sm text-neutral-700 dark:text-neutral-300 hidden sm:inline"+ >+ {{ $t('dashboard.photos.toolbar.title') }}+ </span>+ <div class="flex items-center gap-1 sm:gap-2 sm:ml-1">+ <UBadge+ v-if="livePhotoStats.staticPhotos > 0"+ variant="soft"+ color="neutral"+ size="sm"+ >+ <span class="hidden sm:inline"+ >{{ livePhotoStats.staticPhotos }}+ {{ $t('dashboard.photos.stats.photos') }}</span+ >+ <span class="sm:hidden">{{ livePhotoStats.staticPhotos }}P</span>+ </UBadge>+ <UBadge+ v-if="livePhotoStats.livePhotos > 0"+ variant="soft"+ color="warning"+ size="sm"+ >+ <span class="hidden sm:inline"+ >{{ livePhotoStats.livePhotos }}+ {{ $t('dashboard.photos.stats.livePhotos') }}</span+ >+ <span class="sm:hidden">{{ livePhotoStats.livePhotos }}LP</span>+ </UBadge>+ </div>+ </div>+</template>diff --git a/apps/cloud/app/components/CloudPhotoMasonry.vue b/packages/console/app/components/ConsolePhotoMasonry.vuesimilarity index 61%rename from apps/cloud/app/components/CloudPhotoMasonry.vuerename to packages/console/app/components/ConsolePhotoMasonry.vueindex 1c221c5f..a75a60d1 100644--- a/apps/cloud/app/components/CloudPhotoMasonry.vue+++ b/packages/console/app/components/ConsolePhotoMasonry.vue@@ -1,5 +1,4 @@<script setup lang="ts">-import { Ellipsis } from 'lucide-vue-next'import type { Photo } from '@chronoframe/contracts/resources'import type { DropdownMenuItem } from '@nuxt/ui'@@ -34,7 +33,7 @@ function selectAll(value: boolean | 'indeterminate') {? 'indeterminate': selectedCount > 0"- :label="$t('cloud.messages.selectAllPhotographs')"+ :label="$t('dashboard.photos.table.selectAllAria')"@update:model-value="selectAll"/><MasonryWall@@ -48,7 +47,7 @@ function selectAll(value: boolean | 'indeterminate') {><template #default="{ item: photo, index }"><div- class="relative"+ class="relative cf-masonry-photo":class="{ 'cf-masonry-selected': selection[photo.id] }"><MasonryItemPhoto@@ -58,21 +57,23 @@ function selectAll(value: boolean | 'indeterminate') {/><labelclass="cf-masonry-select"+ :class="{ 'cf-masonry-control-selected': selection[photo.id] }":for="`${selectionId}-${photo.id}`"><UCheckbox:id="`${selectionId}-${photo.id}`":model-value="!!selection[photo.id]"- :aria-label="$t('cloud.ui.selectNamed', { title: photo.title })"+ :aria-label="`${$t('dashboard.photos.table.selectRowAria')} ${photo.title}`"@update:model-value="selection[photo.id] = $event === true"/></label><UDropdownMenu :items="actions(photo)">- <CfButton+ <UButtonclass="cf-masonry-actions"- variant="secondary"- :icon="Ellipsis"- :aria-label="$t('cloud.ui.actionsNamed', { title: photo.title })"+ variant="outline"+ color="neutral"+ icon="tabler:dots-vertical"+ :aria-label="`${$t('dashboard.photos.table.columns.actions')} ${photo.title}`"/></UDropdownMenu></div>@@ -86,29 +87,60 @@ function selectAll(value: boolean | 'indeterminate') {outline: 3px solid var(--ui-primary);outline-offset: -3px;}-.cf-masonry-select {+.cf-masonry-select,+.cf-masonry-actions {position: absolute;top: 0.5rem;- left: 0.5rem;z-index: 1;+ color: white;+ background: rgb(20 20 24 / 35%);+ border: 1px solid rgb(255 255 255 / 25%);+ border-radius: 0.625rem;+ box-shadow: 0 2px 10px rgb(0 0 0 / 15%);+ backdrop-filter: blur(14px) saturate(140%);+ opacity: 0;+ pointer-events: none;+ transition:+ opacity 150ms ease,+ background-color 150ms ease;+}+.cf-masonry-select {+ left: 0.5rem;display: flex;padding: 0.375rem;- border-radius: 0.5rem;- background: var(--ui-bg);- box-shadow: 0 1px 4px rgb(0 0 0 / 20%);+ cursor: pointer;}.cf-masonry-actions {- position: absolute;- top: 0.5rem;right: 0.5rem;- z-index: 1;}-@media (pointer: coarse) {- .cf-masonry-select {+.cf-masonry-photo:hover .cf-masonry-select,+.cf-masonry-photo:hover .cf-masonry-actions,+.cf-masonry-photo:focus-within .cf-masonry-select,+.cf-masonry-photo:focus-within .cf-masonry-actions,+.cf-masonry-actions[data-state='open'],+.cf-masonry-control-selected {+ opacity: 1;+ pointer-events: auto;+}+.cf-masonry-actions:hover,+.cf-masonry-select:hover {+ background: rgb(20 20 24 / 55%);+}+@media (hover: none), (pointer: coarse) {+ .cf-masonry-select,+ .cf-masonry-actions {+ opacity: 1;+ pointer-events: auto;min-width: 44px;min-height: 44px;align-items: center;justify-content: center;}}+@media (prefers-reduced-motion: reduce) {+ .cf-masonry-select,+ .cf-masonry-actions {+ transition: none;+ }+}</style>diff --git a/packages/console/app/components/ConsolePhotoTable.vue b/packages/console/app/components/ConsolePhotoTable.vuenew file mode 100644index 00000000..286914ca--- /dev/null+++ b/packages/console/app/components/ConsolePhotoTable.vue@@ -0,0 +1,44 @@+<script setup lang="ts" generic="T">+import type { TableColumn } from '@nuxt/ui'+defineOptions({ inheritAttrs: false })+defineProps<{ data: T[]; columns: TableColumn<T>[] }>()+const table = ref()+defineExpose({+ get tableApi() {+ return table.value?.tableApi+ },+})+</script>+<template>+ <ConsoleMediaTable+ ref="table"+ v-bind="$attrs"+ :data="data"+ :columns="columns"+ sticky+ :column-pinning="{ right: ['actions'] }"+ class="h-full flex-1"+ :ui="{+ root: 'font-sans relative scroll-smooth h-full overflow-auto min-w-0',+ base: 'min-w-full table-fixed',+ thead:+ 'bg-neutral-50/80 dark:bg-neutral-900/80 backdrop-blur-md sticky top-0 z-10 whitespace-nowrap',+ tbody:+ 'divide-y divide-neutral-200/80 dark:divide-neutral-800/80 bg-white dark:bg-neutral-900',+ tr: 'hover:bg-neutral-50/50 dark:hover:bg-neutral-800/50 transition-colors data-[selected=true]:bg-primary-50/50 dark:data-[selected=true]:bg-primary-900/20',+ th: 'px-4 py-3.5 text-left rtl:text-right text-neutral-500 dark:text-neutral-400 font-medium text-sm whitespace-nowrap',+ td: 'px-4 py-4 text-neutral-700 dark:text-neutral-300 text-sm whitespace-nowrap',+ separator: 'bg-neutral-200/80 dark:bg-neutral-800/80',+ }"+ >+ <template+ v-for="(_, name) in $slots"+ #[name]="slotData"+ >+ <slot+ :name="name"+ v-bind="slotData"+ />+ </template>+ </ConsoleMediaTable>+</template>diff --git a/packages/console/app/components/ConsolePhotoTableActions.vue b/packages/console/app/components/ConsolePhotoTableActions.vuenew file mode 100644index 00000000..4cf1f909--- /dev/null+++ b/packages/console/app/components/ConsolePhotoTableActions.vue@@ -0,0 +1,21 @@+<script setup lang="ts">+import type { DropdownMenuItem } from '@nuxt/ui'+defineProps<{ items: DropdownMenuItem[][]; label?: string }>()+</script>+<template>+ <div class="flex justify-end">+ <UDropdownMenu+ size="sm"+ :content="{ align: 'end' }"+ :items="items"+ >+ <UButton+ variant="outline"+ color="neutral"+ size="sm"+ icon="tabler:dots-vertical"+ :aria-label="label ?? $t('dashboard.photos.table.columns.actions')"+ />+ </UDropdownMenu>+ </div>+</template>diff --git a/packages/console/app/composables/usePhotoTableColumns.ts b/packages/console/app/composables/usePhotoTableColumns.tsnew file mode 100644index 00000000..d18c677a--- /dev/null+++ b/packages/console/app/composables/usePhotoTableColumns.ts@@ -0,0 +1,270 @@+import { h, resolveComponent, computed } from 'vue'+import type { Ref } from 'vue'+import type { TableColumn } from '@nuxt/ui'+import type { Photo } from '@chronoframe/contracts/resources'+import { Icon, UBadge } from '#components'+import ThumbImage from '#gallery/components/ui/ThumbImage.vue'++export function usePhotoTableColumns(options: {+ preview: (photo: Photo) => void+ reactions: Ref<Record<string, Record<string, number>>>+}) {+ const { t: $t } = useI18n()+ const dayjs = useDayjs()+ const locationLabel = useLocationLabel()+ const Rating = resolveComponent('Rating')+ const openImagePreview = options.preview+ const reactionsData = options.reactions+ return computed<TableColumn<Photo>[]>(() => [+ {+ id: 'thumbnailUrl',+ accessorKey: 'thumbnailUrl',+ header: $t('dashboard.photos.table.columns.thumbnail.title'),+ cell: ({ row }) => {+ const url = row.original.thumbnailUrl+ return h(ThumbImage, {+ src: url || row.original.originalUrl || '',+ alt: row.original.title || $t('dashboard.photos.table.thumbnailAlt'),+ key: row.original.id,+ thumbhash: row.original.thumbnailHash || '',+ class: 'size-16 min-w-[100px] object-cover rounded-md shadow',+ onClick: () => openImagePreview(row.original),+ style: { cursor: url ? 'pointer' : 'default' },+ })+ },+ enableHiding: false,+ },+ {+ id: 'id',+ accessorKey: 'id',+ header: $t('dashboard.photos.table.columns.id'),+ enableHiding: false,+ },+ {+ accessorKey: 'title',+ header: $t('dashboard.photos.table.columns.title'),+ },+ {+ accessorKey: 'tags',+ header: $t('dashboard.photos.table.columns.tags'),+ cell: ({ row }) => {+ const tags = row.original.tags+ return h('div', { class: 'flex items-center gap-1' }, [+ tags && tags.length+ ? tags.map((tag) =>+ h(+ UBadge,+ {+ size: 'sm',+ variant: 'soft',+ color: 'neutral',+ },+ () => tag,+ ),+ )+ : h(+ 'span',+ { class: 'text-neutral-400 text-xs' },+ $t('dashboard.photos.table.cells.noTags'),+ ),+ ])+ },+ },+ {+ accessorKey: 'rating',+ header: $t('dashboard.photos.table.columns.rating'),+ cell: ({ row }) => {+ const rating = row.original.exif?.Rating+ return h('div', { class: 'flex items-center' }, [+ rating !== undefined && rating !== null+ ? h(Rating, {+ modelValue: rating,+ readonly: true,+ size: 'xs',+ })+ : h(+ 'span',+ { class: 'text-neutral-400 text-xs' },+ $t('dashboard.photos.table.cells.noRating'),+ ),+ ])+ },+ },+ {+ accessorKey: 'isLivePhoto',+ header: $t('dashboard.photos.table.columns.isLivePhoto'),+ cell: ({ row }) => {+ const isLivePhoto = row.original.isLivePhoto+ return h('div', { class: 'flex items-center gap-2' }, [+ isLivePhoto+ ? h('div', { class: 'flex items-center gap-1' }, [+ h(Icon, {+ name: 'tabler:live-photo',+ class: 'size-4 text-yellow-600 dark:text-yellow-400',+ }),+ h(+ 'span',+ {+ class:+ 'text-yellow-600 dark:text-yellow-400 text-xs font-medium',+ },+ $t('ui.livePhoto'),+ ),+ ])+ : h(+ 'span',+ {+ class: 'text-neutral-400 text-xs',+ },+ $t('dashboard.photos.table.cells.staticPhoto'),+ ),+ ])+ },+ sortingFn: (rowA, rowB) => {+ const valueA = rowA.original.isLivePhoto ? 1 : 0+ const valueB = rowB.original.isLivePhoto ? 1 : 0+ return valueB - valueA // LivePhoto 优先排序+ },+ },+ {+ accessorKey: 'location',+ header: $t('dashboard.photos.table.columns.location'),+ cell: ({ row }) => {+ const { exif, country } = row.original++ if (!exif?.GPSLongitude && !exif?.GPSLatitude) {+ return h(+ 'span',+ { class: 'text-neutral-400 text-xs' },+ $t('dashboard.photos.table.cells.noGps'),+ )+ }++ const location = [+ ...new Set([locationLabel(row.original), country].filter(Boolean)),+ ].join(', ')+ return h(+ 'span',+ {+ class: location ? 'text-xs' : 'text-neutral-400 text-xs',+ },+ location || $t('dashboard.photos.table.cells.unknown'),+ )+ },+ },+ {+ accessorKey: 'dateTaken',+ header: $t('dashboard.photos.table.columns.dateTaken'),+ cell: (info) => {+ const date = info.getValue() as string+ return h(+ 'span',+ { class: 'font-mono text-xs' },+ date+ ? dayjs(date).format('YYYY-MM-DD HH:mm:ss')+ : $t('dashboard.photos.table.cells.unknown'),+ )+ },+ },+ {+ accessorKey: 'lastModified',+ header: $t('dashboard.photos.table.columns.lastModified'),+ cell: (info) => {+ const date = info.getValue() as string+ return h(+ 'span',+ { class: 'font-mono text-xs' },+ date+ ? dayjs(date).format('YYYY-MM-DD HH:mm:ss')+ : $t('dashboard.photos.table.cells.unknown'),+ )+ },+ },+ {+ accessorKey: 'fileSize',+ header: $t('dashboard.photos.table.columns.fileSize'),+ cell: (info) => formatBytes(info.getValue() as number),+ },+ {+ id: 'colorSpace',+ accessorFn: (row) => row.exif?.ColorSpace,+ header: $t('dashboard.photos.table.columns.colorSpace'),+ },+ {+ accessorKey: 'reactions',+ header: $t('dashboard.photos.table.columns.reactions'),+ cell: ({ row }) => {+ const photoId = row.original.id+ const reactions = reactionsData.value[photoId] || {}+ const totalReactions = Object.values(reactions).reduce(+ (sum: number, count) => sum + (count as number),+ 0,+ )++ if (totalReactions === 0) {+ return h(+ 'span',+ { class: 'text-neutral-400 text-xs' },+ $t('dashboard.photos.table.cells.noReactions'),+ )+ }++ const reactionIcons: Record<string, string> = {+ like: 'fluent-emoji-flat:thumbs-up',+ love: 'fluent-emoji-flat:red-heart',+ amazing: 'fluent-emoji-flat:smiling-face-with-heart-eyes',+ funny: 'fluent-emoji-flat:face-with-tears-of-joy',+ wow: 'fluent-emoji-flat:face-with-open-mouth',+ sad: 'fluent-emoji-flat:crying-face',+ fire: 'fluent-emoji-flat:fire',+ sparkle: 'fluent-emoji-flat:sparkles',+ }++ // 显示前3个有数据的表态+ const topReactions = Object.entries(reactions)+ .filter(([, count]) => (count as number) > 0)+ .sort((a, b) => (b[1] as number) - (a[1] as number))+ .slice(0, 3)++ return h(+ 'div',+ { class: 'flex items-center gap-2' },+ [+ ...topReactions.map(([type, count]) =>+ h('div', { class: 'flex items-center gap-0.5' }, [+ h(Icon, {+ name:+ reactionIcons[type] ||+ 'fluent-emoji-flat:face-with-tears-of-joy',+ class: 'size-4',+ mode: 'svg',+ }),+ h(+ 'span',+ {+ class:+ 'text-xs font-medium text-neutral-700 dark:text-neutral-300',+ },+ count,+ ),+ ]),+ ),+ totalReactions > topReactions.length+ ? h(+ 'span',+ { class: 'text-xs text-neutral-400' },+ `+${totalReactions - topReactions.reduce((sum, [, count]) => sum + (count as number), 0)}`,+ )+ : null,+ ].filter(Boolean),+ )+ },+ },+ {+ id: 'actions',+ accessorKey: 'actions',+ header: $t('dashboard.photos.table.columns.actions'),+ enableHiding: false,+ },+ ])+}diff --git a/packages/console/app/pages/dashboard/photos.vue b/packages/console/app/pages/dashboard/photos.vueindex a2086f6c..89742c10 100644--- a/packages/console/app/pages/dashboard/photos.vue+++ b/packages/console/app/pages/dashboard/photos.vue@@ -1,7 +1,8 @@<script lang="ts" setup>+import { photoLibraryPresentation } from '../../utils/photoLibraryPresentation'const consoleApi = useConsoleApi()-import type { FormSubmitEvent, TableColumn } from '@nuxt/ui'+import type { FormSubmitEvent, TableColumn, DropdownMenuItem } from '@nuxt/ui'import type { UploadPreparationResponse } from '@chronoframe/contracts/upload'import type { Album, Photo } from '@chronoframe/contracts/resources'import type { UploadingFile } from '@chronoframe/gallery/shared/types/uploading-file'@@ -18,11 +19,9 @@ import {isInFlightTransportStatus,} from '@chronoframe/gallery/shared/utils/upload-status'import { h, resolveComponent } from 'vue'-import { Icon, UBadge } from '#components'-import ThumbImage from '#gallery/components/ui/ThumbImage.vue'+import { Icon } from '#components'const UCheckbox = resolveComponent('UCheckbox')-const Rating = resolveComponent('Rating')const route = useRoute()const router = useRouter()@@ -61,10 +60,7 @@ const systemUploadEraseLocationDefault = computed(() => {return typeof val === 'boolean' ? val : false})-const dayjs = useDayjs()-const locationLabel = useLocationLabel()--const { status, refresh } = usePhotos()+const { photos, status, refresh } = usePhotos()const { filteredPhotos, selectedCounts, hasActiveFilters } = usePhotoFilters()const { currentSortIcon, currentSortOption } = usePhotoSort()@@ -702,7 +698,12 @@ watch(isEditModalOpen, (open) => {})// 表格多选状态-const rowSelection = ref({})+const rowSelection = ref<Record<string, boolean>>({})+const layout = useLocalStorage<'list' | 'masonry'>(+ 'dashboard-photos-layout',+ 'list',+ { initOnMounted: true },+)const table: any = useTemplateRef('table')const getPhotoRowId = (photo: Photo) => photo.idconst rowRangeSelection = useShiftRangeSelection()@@ -736,8 +737,7 @@ const formatAddToAlbumResult = (const openAddToAlbum = () => {if (isAddingToAlbum.value) return- const selectedRows =- table.value?.tableApi?.getFilteredSelectedRowModel().rows || []+ const selectedRows = selectedPhotoRows.valueselectedBulkPhotoIds.value = selectedRows.map((row: { original: Photo }) => row.original.id,)@@ -835,23 +835,11 @@ watch(const columnVisibility = useDashboardPhotoColumnVisibility()const selectedRowsCount = computed((): number => {- return table.value?.tableApi?.getFilteredSelectedRowModel().rows.length || 0+ return selectedPhotoRows.value.length})const totalRowsCount = computed((): number => {- return table.value?.tableApi?.getFilteredRowModel().rows.length || 0-})--const livePhotoStats = computed(() => {- if (!filteredPhotos.value) return { total: 0, livePhotos: 0, staticPhotos: 0 }-- const total = filteredPhotos.value.length- const livePhotos = filteredPhotos.value.filter(- (photo: Photo) => photo.isLivePhoto,- ).length- const staticPhotos = total - livePhotos-- return { total, livePhotos, staticPhotos }+ return filteredData.value.length})const photoFilter = ref<'all' | 'livephoto' | 'static'>('all')@@ -869,6 +857,21 @@ const filteredData = computed(() => {}})+const selectedPhotoRows = computed(() =>+ filteredData.value+ .filter((photo: Photo) => rowSelection.value[photo.id])+ .map((photo: Photo) => ({ original: photo })),+)+watch(+ () => photos.value?.map((photo: Photo) => photo.id),+ (ids) => {+ const available = new Set(ids ?? [])+ rowSelection.value = Object.fromEntries(+ Object.entries(rowSelection.value).filter(([id]) => available.has(id)),+ )+ },+)+// 监听过滤后的照片变化,自动获取表态数据watch(() => filteredData.value,@@ -1061,6 +1064,11 @@ const clearAllUploads = () => {}}+const photoColumns = usePhotoTableColumns({+ preview: (photo) => openImagePreview(photo),+ reactions: reactionsData,+})+const columns = computed<TableColumn<Photo>[]>(() => [{id: 'select',@@ -1090,256 +1098,7 @@ const columns = computed<TableColumn<Photo>[]>(() => [),enableHiding: false,},- {- id: 'thumbnailUrl',- accessorKey: 'thumbnailUrl',- header: $t('dashboard.photos.table.columns.thumbnail.title'),- cell: ({ row }) => {- const url = row.original.thumbnailUrl- return h(ThumbImage, {- src: url || row.original.originalUrl || '',- alt: row.original.title || $t('dashboard.photos.table.thumbnailAlt'),- key: row.original.id,- thumbhash: row.original.thumbnailHash || '',- class: 'size-16 min-w-[100px] object-cover rounded-md shadow',- onClick: () => openImagePreview(row.original),- style: { cursor: url ? 'pointer' : 'default' },- })- },- enableHiding: false,- },- {- id: 'id',- accessorKey: 'id',- header: $t('dashboard.photos.table.columns.id'),- enableHiding: false,- },- {- accessorKey: 'title',- header: $t('dashboard.photos.table.columns.title'),- },- {- accessorKey: 'tags',- header: $t('dashboard.photos.table.columns.tags'),- cell: ({ row }) => {- const tags = row.original.tags- return h('div', { class: 'flex items-center gap-1' }, [- tags && tags.length- ? tags.map((tag) =>- h(- UBadge,- {- size: 'sm',- variant: 'soft',- color: 'neutral',- },- () => tag,- ),- )- : h(- 'span',- { class: 'text-neutral-400 text-xs' },- $t('dashboard.photos.table.cells.noTags'),- ),- ])- },- },- {- accessorKey: 'rating',- header: $t('dashboard.photos.table.columns.rating'),- cell: ({ row }) => {- const rating = row.original.exif?.Rating- return h('div', { class: 'flex items-center' }, [- rating !== undefined && rating !== null- ? h(Rating, {- modelValue: rating,- readonly: true,- size: 'xs',- })- : h(- 'span',- { class: 'text-neutral-400 text-xs' },- $t('dashboard.photos.table.cells.noRating'),- ),- ])- },- },- {- accessorKey: 'isLivePhoto',- header: $t('dashboard.photos.table.columns.isLivePhoto'),- cell: ({ row }) => {- const isLivePhoto = row.original.isLivePhoto- return h('div', { class: 'flex items-center gap-2' }, [- isLivePhoto- ? h('div', { class: 'flex items-center gap-1' }, [- h(Icon, {- name: 'tabler:live-photo',- class: 'size-4 text-yellow-600 dark:text-yellow-400',- }),- h(- 'span',- {- class:- 'text-yellow-600 dark:text-yellow-400 text-xs font-medium',- },- $t('ui.livePhoto'),- ),- ])- : h(- 'span',- {- class: 'text-neutral-400 text-xs',- },- $t('dashboard.photos.table.cells.staticPhoto'),- ),- ])- },- sortingFn: (rowA, rowB) => {- const valueA = rowA.original.isLivePhoto ? 1 : 0- const valueB = rowB.original.isLivePhoto ? 1 : 0- return valueB - valueA // LivePhoto 优先排序- },- },- {- accessorKey: 'location',- header: $t('dashboard.photos.table.columns.location'),- cell: ({ row }) => {- const { exif, country } = row.original-- if (!exif?.GPSLongitude && !exif?.GPSLatitude) {- return h(- 'span',- { class: 'text-neutral-400 text-xs' },- $t('dashboard.photos.table.cells.noGps'),- )- }-- const location = [- ...new Set([locationLabel(row.original), country].filter(Boolean)),- ].join(', ')- return h(- 'span',- {- class: location ? 'text-xs' : 'text-neutral-400 text-xs',- },- location || $t('dashboard.photos.table.cells.unknown'),- )- },- },- {- accessorKey: 'dateTaken',- header: $t('dashboard.photos.table.columns.dateTaken'),- cell: (info) => {- const date = info.getValue() as string- return h(- 'span',- { class: 'font-mono text-xs' },- date- ? dayjs(date).format('YYYY-MM-DD HH:mm:ss')- : $t('dashboard.photos.table.cells.unknown'),- )- },- },- {- accessorKey: 'lastModified',- header: $t('dashboard.photos.table.columns.lastModified'),- cell: (info) => {- const date = info.getValue() as string- return h(- 'span',- { class: 'font-mono text-xs' },- date- ? dayjs(date).format('YYYY-MM-DD HH:mm:ss')- : $t('dashboard.photos.table.cells.unknown'),- )- },- },- {- accessorKey: 'fileSize',- header: $t('dashboard.photos.table.columns.fileSize'),- cell: (info) => formatBytes(info.getValue() as number),- },- {- id: 'colorSpace',- accessorFn: (row) => row.exif?.ColorSpace,- header: $t('dashboard.photos.table.columns.colorSpace'),- },- {- accessorKey: 'reactions',- header: $t('dashboard.photos.table.columns.reactions'),- cell: ({ row }) => {- const photoId = row.original.id- const reactions = reactionsData.value[photoId] || {}- const totalReactions = Object.values(reactions).reduce(- (sum: number, count) => sum + (count as number),- 0,- )-- if (totalReactions === 0) {- return h(- 'span',- { class: 'text-neutral-400 text-xs' },- $t('dashboard.photos.table.cells.noReactions'),- )- }-- const reactionIcons: Record<string, string> = {- like: 'fluent-emoji-flat:thumbs-up',- love: 'fluent-emoji-flat:red-heart',- amazing: 'fluent-emoji-flat:smiling-face-with-heart-eyes',- funny: 'fluent-emoji-flat:face-with-tears-of-joy',- wow: 'fluent-emoji-flat:face-with-open-mouth',- sad: 'fluent-emoji-flat:crying-face',- fire: 'fluent-emoji-flat:fire',- sparkle: 'fluent-emoji-flat:sparkles',- }-- // 显示前3个有数据的表态- const topReactions = Object.entries(reactions)- .filter(([_, count]) => (count as number) > 0)- .sort((a, b) => (b[1] as number) - (a[1] as number))- .slice(0, 3)-- return h(- 'div',- { class: 'flex items-center gap-2' },- [- ...topReactions.map(([type, count]) =>- h('div', { class: 'flex items-center gap-0.5' }, [- h(Icon, {- name:- reactionIcons[type] ||- 'fluent-emoji-flat:face-with-tears-of-joy',- class: 'size-4',- mode: 'svg',- }),- h(- 'span',- {- class:- 'text-xs font-medium text-neutral-700 dark:text-neutral-300',- },- count,- ),- ]),- ),- totalReactions > topReactions.length- ? h(- 'span',- { class: 'text-xs text-neutral-400' },- `+${totalReactions - topReactions.reduce((sum, [_, count]) => sum + (count as number), 0)}`,- )- : null,- ].filter(Boolean),- )- },- },- {- id: 'actions',- accessorKey: 'actions',- header: $t('dashboard.photos.table.columns.actions'),- enableHiding: false,- },+ ...photoColumns.value,])// 文件验证函数@@ -1863,7 +1622,7 @@ const handleReprocessSingle = async (photo: Photo) => {}}-const getRowActions = (photo: Photo) => {+const getRowActions = (photo: Photo): DropdownMenuItem[][] => {const isReverseLoading = !!reverseGeocodeLoading.value[photo.id]const isEraseLocationLoading = !!eraseLocationLoading.value[photo.id]@@ -1952,7 +1711,7 @@ const handleSingleDeleteRequest = (photo: Photo) => {// 批量删除功能const handleBatchDelete = () => {- const selectedRowModel = table.value?.tableApi?.getFilteredSelectedRowModel()+ const selectedRowModel = { rows: selectedPhotoRows.value }const selectedPhotos =selectedRowModel?.rows.map((row: any) => row.original) || []@@ -2049,7 +1808,7 @@ const confirmDelete = async () => {// 批量重新处理照片功能const handleBatchReprocess = async () => {- const selectedRowModel = table.value?.tableApi?.getFilteredSelectedRowModel()+ const selectedRowModel = { rows: selectedPhotoRows.value }const selectedPhotos =selectedRowModel?.rows.map((row: any) => row.original) || []@@ -2128,7 +1887,7 @@ const handleBatchReprocess = async () => {// 批量抹除位置信息const handleBatchEraseLocation = async () => {- const selectedRowModel = table.value?.tableApi?.getFilteredSelectedRowModel()+ const selectedRowModel = { rows: selectedPhotoRows.value }const selectedPhotos =selectedRowModel?.rows.map((row: any) => row.original) || []@@ -2213,7 +1972,7 @@ const handleBatchEraseLocation = async () => {// 批量下载照片const handleBatchDownload = async () => {- const selectedRowModel = table.value?.tableApi?.getFilteredSelectedRowModel()+ const selectedRowModel = { rows: selectedPhotoRows.value }const selectedPhotos =selectedRowModel?.rows.map((row: any) => row.original) || []@@ -2375,7 +2134,7 @@ onUnmounted(() => {</template><template #body>- <div class="flex flex-col gap-4 h-full flex-1 min-h-0">+ <div :class="photoLibraryPresentation.body"><!-- 上传队列容器 --><UploadQueuePanel:uploading-files="uploadingFiles"@@ -2572,58 +2331,10 @@ onUnmounted(() => {</USlideover><!-- 统合容器:工具栏 + 照片列表 -->- <div- class="relative flex-1 min-h-0 flex flex-col bg-white dark:bg-neutral-900 border border-neutral-200/80 dark:border-neutral-800/80 rounded-2xl shadow-sm overflow-hidden"- >+ <div :class="photoLibraryPresentation.panel"><!-- 工具栏 -->- <div- class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 p-3 sm:px-4 sm:py-3 bg-neutral-50/50 dark:bg-neutral-900/50 backdrop-blur-sm border-b border-neutral-200/80 dark:border-neutral-800/80 z-20"- >- <div class="flex items-center gap-3">- <div- class="flex size-8 items-center justify-center rounded-[10px] bg-neutral-200/50 dark:bg-neutral-800/50 border border-neutral-200/50 dark:border-neutral-700/50"- >- <UIcon- name="tabler:photo"- class="size-4.5 text-neutral-600 dark:text-neutral-400"- />- </div>- <span- class="font-semibold text-sm text-neutral-700 dark:text-neutral-300 hidden sm:inline"- >- {{ $t('dashboard.photos.toolbar.title') }}- </span>- <div class="flex items-center gap-1 sm:gap-2 sm:ml-1">- <UBadge- v-if="livePhotoStats.staticPhotos > 0"- variant="soft"- color="neutral"- size="sm"- >- <span class="hidden sm:inline"- >{{ livePhotoStats.staticPhotos }}- {{ $t('dashboard.photos.stats.photos') }}</span- >- <span class="sm:hidden"- >{{ livePhotoStats.staticPhotos }}P</span- >- </UBadge>- <UBadge- v-if="livePhotoStats.livePhotos > 0"- variant="soft"- color="warning"- size="sm"- >- <span class="hidden sm:inline"- >{{ livePhotoStats.livePhotos }}- {{ $t('dashboard.photos.stats.livePhotos') }}</span- >- <span class="sm:hidden"- >{{ livePhotoStats.livePhotos }}LP</span- >- </UBadge>- </div>- </div>+ <div :class="photoLibraryPresentation.toolbar">+ <ConsolePhotoLibrarySummary :photos="filteredPhotos ?? []" /><div class="flex items-center gap-2"><OverlayFilterPopover>@@ -2708,8 +2419,10 @@ onUnmounted(() => {}}</span></UButton>+ <ConsolePhotoLayoutSwitch v-model="layout" /><!-- 列可见性按钮 --><UDropdownMenu+ v-if="layout !== 'masonry'":items="table?.tableApi?.getAllColumns()@@ -2754,8 +2467,17 @@ onUnmounted(() => {</div><!-- 照片列表 -->- <div class="relative flex-1 min-h-0 flex flex-col">- <ConsoleMediaTable+ <div :class="photoLibraryPresentation.content">+ <ConsolePhotoMasonry+ v-if="layout === 'masonry' && filteredData.length"+ class="overflow-auto p-3"+ v-model:selection="rowSelection"+ :photos="filteredData as Photo[]"+ :actions="getRowActions"+ @preview="openImagePreview"+ />+ <ConsolePhotoTable+ v-elseref="table"v-model:row-selection="rowSelection"v-model:column-visibility="columnVisibility"@@ -2768,51 +2490,13 @@ onUnmounted(() => {:loading="status === 'pending'"stickyclass="h-full flex-1"- :ui="{- wrapper: 'relative scroll-smooth h-full overflow-auto',- base: 'min-w-full table-fixed',- divide:- 'divide-y divide-neutral-200/80 dark:divide-neutral-800/80',- thead:- 'bg-neutral-50/80 dark:bg-neutral-900/80 backdrop-blur-md sticky top-0 z-10 whitespace-nowrap',- tbody:- 'divide-y divide-neutral-200/80 dark:divide-neutral-800/80 bg-white dark:bg-neutral-900',- tr: {- base: 'hover:bg-neutral-50/50 dark:hover:bg-neutral-800/50 transition-colors',- selected: 'bg-primary-50/50 dark:bg-primary-900/20',- },- th: {- base: 'text-left rtl:text-right ',- padding: 'px-4 py-3.5',- color: 'text-neutral-500 dark:text-neutral-400',- font: 'font-medium text-sm',- },- td: {- padding: 'px-4 py-3',- color: 'text-neutral-700 dark:text-neutral-300 text-sm',- },- separator: 'bg-neutral-200/80 dark:bg-neutral-800/80',- }"><template #actions-cell="{ row }">- <div class="flex justify-end">- <UDropdownMenu- size="sm"- :content="{- align: 'end',- }"- :items="getRowActions(row.original)"- >- <UButton- variant="outline"- color="neutral"- size="sm"- icon="tabler:dots-vertical"- />- </UDropdownMenu>- </div>+ <ConsolePhotoTableActions+ :items="getRowActions(row.original)"+ /></template>- </ConsoleMediaTable>+ </ConsolePhotoTable><ConsoleSelectionToolbar:count="selectedRowsCount"diff --git a/packages/console/app/utils/photoLibraryPresentation.ts b/packages/console/app/utils/photoLibraryPresentation.tsnew file mode 100644index 00000000..40d7f958--- /dev/null+++ b/packages/console/app/utils/photoLibraryPresentation.ts@@ -0,0 +1,8 @@+export const photoLibraryPresentation = {+ body: 'min-w-0 w-full flex flex-col gap-4 h-full flex-1 min-h-0',+ panel:+ 'relative min-w-0 flex-1 min-h-0 flex flex-col bg-white dark:bg-neutral-900 border border-neutral-200/80 dark:border-neutral-800/80 rounded-2xl shadow-sm overflow-hidden',+ toolbar:+ 'min-w-0 flex flex-col sm:flex-row sm:items-center justify-between gap-3 p-3 sm:px-4 sm:py-3 bg-neutral-50/50 dark:bg-neutral-900/50 backdrop-blur-sm border-b border-neutral-200/80 dark:border-neutral-800/80 z-20',+ content: 'relative min-w-0 flex-1 min-h-0 flex flex-col',+} as constdiff --git a/packages/gallery/i18n/locales/en.json b/packages/gallery/i18n/locales/en.jsonindex 83b89fab..40882b4c 100644--- a/packages/gallery/i18n/locales/en.json+++ b/packages/gallery/i18n/locales/en.json@@ -603,6 +603,11 @@},"dashboard": {"photos": {+ "layouts": {+ "label": "Photo library layout",+ "list": "List",+ "masonry": "Masonry"+ },"title": "Photo Upload","subtitle": "Photos will be automatically processed and added to your library. You can organize your photos in the {0} section afterwards.","supportedFormats": "JPEG / PNG / HEIC / Live Photo / Motion Photo",diff --git a/packages/gallery/i18n/locales/ja.json b/packages/gallery/i18n/locales/ja.jsonindex f30fda79..6c116b1a 100644--- a/packages/gallery/i18n/locales/ja.json+++ b/packages/gallery/i18n/locales/ja.json@@ -525,6 +525,11 @@},"dashboard": {"photos": {+ "layouts": {+ "label": "写真ライブラリのレイアウト",+ "list": "リスト",+ "masonry": "メイソンリー"+ },"title": "写真をアップロード","subtitle": "アップロードされた写真は自動的に処理され、ライブラリに追加されます。その後、{0}セクションで写真を整理できます。","supportedFormats": "JPEG / PNG / HEIC / ライブフォト / モーションフォト",diff --git a/packages/gallery/i18n/locales/ru.json b/packages/gallery/i18n/locales/ru.jsonindex 43ec6860..1f4f8787 100644--- a/packages/gallery/i18n/locales/ru.json+++ b/packages/gallery/i18n/locales/ru.json@@ -603,6 +603,11 @@},"dashboard": {"photos": {+ "layouts": {+ "label": "Вид фототеки",+ "list": "Список",+ "masonry": "Мозаика"+ },"title": "Загрузка фотографий","subtitle": "Фотографии будут автоматически обработаны и добавлены в вашу библиотеку. После этого их можно упорядочить в разделе {0}.","supportedFormats": "JPEG / PNG / HEIC / Live Photo / Motion Photo",diff --git a/packages/gallery/i18n/locales/zh-Hans.json b/packages/gallery/i18n/locales/zh-Hans.jsonindex c6a242b8..a026543d 100644--- a/packages/gallery/i18n/locales/zh-Hans.json+++ b/packages/gallery/i18n/locales/zh-Hans.json@@ -603,6 +603,7 @@},"dashboard": {"photos": {+ "layouts": { "label": "照片库布局", "list": "列表", "masonry": "瀑布流" },"title": "照片上传","subtitle": "上传后照片会自动处理并添加到库中。您可以随后在 {0} 中组织您的照片。","supportedFormats": "JPEG / PNG / HEIC / 实况视频 / Motion Photo",diff --git a/packages/gallery/i18n/locales/zh-Hant-HK.json b/packages/gallery/i18n/locales/zh-Hant-HK.jsonindex e7fe6f7c..f65b88ab 100644--- a/packages/gallery/i18n/locales/zh-Hant-HK.json+++ b/packages/gallery/i18n/locales/zh-Hant-HK.json@@ -525,6 +525,7 @@},"dashboard": {"photos": {+ "layouts": { "label": "相片庫版面", "list": "列表", "masonry": "瀑布流" },"title": "上傳相片","subtitle": "上傳後相片會自動處理並新增到您的圖庫。您稍後可以在 {0} 中組織您的相片。","supportedFormats": "JPEG / PNG / HEIC / 實況相片 / 動態相片",diff --git a/packages/gallery/i18n/locales/zh-Hant-TW.json b/packages/gallery/i18n/locales/zh-Hant-TW.jsonindex ea2dc88d..2ad665e1 100644--- a/packages/gallery/i18n/locales/zh-Hant-TW.json+++ b/packages/gallery/i18n/locales/zh-Hant-TW.json@@ -525,6 +525,7 @@},"dashboard": {"photos": {+ "layouts": { "label": "相片庫版面", "list": "列表", "masonry": "瀑布流" },"title": "上傳照片","subtitle": "上傳後照片會自動處理並新增到您的圖庫。您稍後可以在 {0} 中組織您的照片。","supportedFormats": "JPEG / PNG / HEIC / 原況照片 / 動態照片",diff --git a/tests/cloud-photo-masonry.test.ts b/tests/cloud-photo-masonry.test.tsindex 38589caa..aa23e340 100644--- a/tests/cloud-photo-masonry.test.ts+++ b/tests/cloud-photo-masonry.test.ts@@ -8,7 +8,10 @@ import { computed, ref } from 'vue'test('masonry select-all replaces hidden selections and deselect-all clears them like the list view', () => {const { descriptor } = parse(- readFileSync('apps/cloud/app/components/CloudPhotoMasonry.vue', 'utf8'),+ readFileSync(+ 'packages/console/app/components/ConsolePhotoMasonry.vue',+ 'utf8',+ ),)const selection = ref<Record<string, boolean>>({ hidden: true })const props = { photos: [{ id: 'visible' }], actions: () => [] }diff --git a/tests/photo-table-presentation.test.ts b/tests/photo-table-presentation.test.tsnew file mode 100644index 00000000..69ec2a1e--- /dev/null+++ b/tests/photo-table-presentation.test.ts@@ -0,0 +1,67 @@+import assert from 'node:assert/strict'+import { readFileSync } from 'node:fs'+import test from 'node:test'+import vm from 'node:vm'+import ts from 'typescript'+import { computed, h, ref } from 'vue'++test('shared photo columns render empty metadata and reaction breakdowns consistently', () => {+ const exports: Record<string, any> = {}+ vm.runInNewContext(+ ts.transpileModule(+ readFileSync(+ 'packages/console/app/composables/usePhotoTableColumns.ts',+ 'utf8',+ ),+ { compilerOptions: { module: ts.ModuleKind.CommonJS } },+ ).outputText,+ {+ exports,+ require: (id: string) =>+ id === 'vue'+ ? { h, computed, resolveComponent: (name: string) => name }+ : id === '#components'+ ? { Icon: 'icon', UBadge: 'badge' }+ : { default: 'thumbnail' },+ useI18n: () => ({ t: (key: string) => key }),+ useDayjs: () => () => ({ format: () => 'formatted date' }),+ useLocationLabel: () => () => 'City',+ formatBytes: (value: number) => `${value} bytes`,+ },+ )+ let previewed: unknown+ const reactions = ref<Record<string, Record<string, number>>>({})+ const columns = exports.usePhotoTableColumns({+ preview: (photo: unknown) => {+ previewed = photo+ },+ reactions,+ }).value+ const photo = { id: 'p', title: 'Photo', tags: [], exif: {} }+ const render = (id: string) =>+ columns+ .find((c: any) => (c.id ?? c.accessorKey) === id)+ .cell({+ row: { original: photo },+ getValue: () => null,+ })+ for (const [column, key] of [+ ['tags', 'noTags'],+ ['rating', 'noRating'],+ ['isLivePhoto', 'staticPhoto'],+ ]) {+ const child = render(column).children[0]+ assert.equal(child.children, `dashboard.photos.table.cells.${key}`)+ assert.match(child.props.class, /text-neutral-400 text-xs/)+ }+ assert.equal(+ render('reactions').children,+ 'dashboard.photos.table.cells.noReactions',+ )+ reactions.value = { p: { like: 3, love: 1 } }+ const reactionCells = render('reactions').children+ assert.equal(reactionCells[0].children[1].children, '3')+ assert.equal(reactionCells[1].children[1].children, '1')+ render('thumbnailUrl').props.onClick()+ assert.equal(previewed, photo)+})