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
fix(console): compact photo controls and stabilize layout toggle
HoshinoSuzumi853257523077
diff --git a/apps/cloud/app/components/CloudPhotoLibrary.vue b/apps/cloud/app/components/CloudPhotoLibrary.vueindex 4a9a1bf4..b02082e2 100644--- a/apps/cloud/app/components/CloudPhotoLibrary.vue+++ b/apps/cloud/app/components/CloudPhotoLibrary.vue@@ -318,6 +318,8 @@ watch(<template #right><UButtonv-if="admin"+ size="sm"+ class="min-h-8!"icon="tabler:cloud-upload":disabled="!uploadAdmission.allowed || !!quota.error.value"@click="openUpload"@@ -339,9 +341,14 @@ watch(@retry="quota.refresh()"/><div :class="photoLibraryPresentation.panel">- <div :class="photoLibraryPresentation.toolbar">+ <div+ class="cf-photo-library-toolbar"+ :class="photoLibraryPresentation.toolbar"+ ><ConsolePhotoLibrarySummary :photos="rows" />- <div class="min-w-0 flex flex-wrap items-center gap-2">+ <div+ class="cf-photo-library-tools min-w-0 flex flex-wrap items-center gap-2"+ ><UInputv-model="search"icon="i-lucide-search"@@ -351,25 +358,37 @@ watch(/><OverlayFilterPopover><UButtonsize="sm"+ class="h-7 min-h-7!":variant="'soft'":color="hasActiveFilters ? 'info' : 'neutral'"icon="tabler:filter"- >{{ $t('cloud.messages.filters') }}</UButton+ :aria-label="$t('cloud.messages.filters')"+ ><span class="hidden sm:inline">{{+ $t('cloud.messages.filters')+ }}</span></UButton></OverlayFilterPopover><OverlaySortPopover><UButton- variant="outline"+ size="sm"+ color="neutral"+ variant="soft"icon="tabler:arrows-sort"- >{{ $t('cloud.messages.sort') }}</UButton+ class="h-7 min-h-7!"+ :aria-label="$t('cloud.messages.sort')"+ ><span class="hidden sm:inline">{{+ $t('cloud.messages.sort')+ }}</span></UButton></OverlaySortPopover><UButtonvariant="ghost"+ size="sm"+ class="h-7 min-h-7! w-7 min-w-7!"+ squareicon="tabler:refresh":aria-label="$t('cloud.messages.refreshPhotographs')":loading="loading"@click="refreshMedia"/>- <ConsolePhotoLayoutSwitch v-model="layout" /><UDropdownMenuv-if="layout !== 'masonry'":items="@@ -402,13 +421,20 @@ watch("><UButton- variant="outline"+ size="sm"+ color="neutral"+ variant="soft"icon="tabler:columns-3"- >{{+ class="h-7 min-h-7!"+ :aria-label="+ $t('dashboard.photos.table.columnVisibility.button')+ "+ ><span class="hidden sm:inline">{{$t('dashboard.photos.table.columnVisibility.button')- }}</UButton+ }}</span></UButton></UDropdownMenu>+ <ConsolePhotoLayoutSwitch v-model="layout" /></div></div><div :class="photoLibraryPresentation.content">@@ -754,3 +780,38 @@ watch(></UModal></template>++<style scoped>+@media (max-width: 639px) {+ .cf-photo-library-toolbar {+ display: grid;+ grid-template-columns: minmax(0, 1fr) repeat(5, auto);+ align-items: center;+ gap: 8px 4px;+ }+ .cf-photo-library-tools {+ display: contents;+ }+ .cf-photo-library-tools :deep(button) {+ width: 28px;+ min-width: 28px;+ height: 28px;+ min-height: 28px;+ padding: 0;+ justify-content: center;+ }+ .cf-photo-library-tools :deep(.cf-photo-layout-switch) {+ grid-column: -2 / -1;+ grid-row: 1;+ }+ .cf-library-search {+ grid-column: 1 / -1;+ grid-row: 2;+ width: 100%;+ }+ .cf-library-search :deep(input) {+ min-height: 34px;+ font-size: 14px;+ }+}+</style>diff --git a/packages/console/app/components/ConsolePhotoLayoutSwitch.vue b/packages/console/app/components/ConsolePhotoLayoutSwitch.vueindex 9ab1e7c0..39e23edd 100644--- a/packages/console/app/components/ConsolePhotoLayoutSwitch.vue+++ b/packages/console/app/components/ConsolePhotoLayoutSwitch.vue@@ -1,31 +1,22 @@<script setup lang="ts">const layout = defineModel<'list' | 'masonry'>({ required: true })+const { t } = useI18n()+const targetLabel = computed(() =>+ t(+ `dashboard.photos.layouts.${layout.value === 'masonry' ? 'list' : 'masonry'}`,+ ),+)</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>+ <UButton+ size="sm"+ class="cf-photo-layout-switch h-7 min-h-7! w-7 min-w-7!"+ color="neutral"+ variant="soft"+ square+ :icon="layout === 'masonry' ? 'tabler:layout-grid' : 'tabler:list'"+ :aria-label="targetLabel"+ :title="targetLabel"+ @click="layout = layout === 'masonry' ? 'list' : 'masonry'"+ /></template>diff --git a/packages/console/app/components/ConsolePhotoMasonry.vue b/packages/console/app/components/ConsolePhotoMasonry.vueindex c55a34fc..e7ac79ba 100644--- a/packages/console/app/components/ConsolePhotoMasonry.vue+++ b/packages/console/app/components/ConsolePhotoMasonry.vue@@ -55,21 +55,22 @@ function selectAll(value: boolean | 'indeterminate') {:index="index"@open-viewer="emit('preview', photo)"/>- <label+ <input+ :id="`${selectionId}-${photo.id}`"+ type="checkbox"class="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('dashboard.photos.table.selectRowAria')} ${photo.title ?? photo.id}`"- @update:model-value="selection[photo.id] = $event === true"- />- </label>+ :checked="!!selection[photo.id]"+ :aria-label="`${$t('dashboard.photos.table.selectRowAria')} ${photo.title ?? photo.id}`"+ @change="+ selection[photo.id] = ($event.target as HTMLInputElement).checked+ "+ /><UDropdownMenu :items="actions(photo)"><UButtonclass="cf-masonry-actions"+ size="xs"+ squarevariant="outline"color="neutral"icon="tabler:dots-vertical"@@ -92,12 +93,12 @@ function selectAll(value: boolean | 'indeterminate') {position: absolute;top: 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;+ color: #262626;+ background: rgb(255 255 255 / 50%);+ border: 1px solid rgb(245 245 245 / 80%);+ border-radius: 0.375rem;box-shadow: 0 2px 10px rgb(0 0 0 / 15%);- backdrop-filter: blur(14px) saturate(140%);+ backdrop-filter: blur(12px);opacity: 0;pointer-events: none;transition:@@ -106,12 +107,31 @@ function selectAll(value: boolean | 'indeterminate') {}.cf-masonry-select {left: 0.5rem;- display: flex;- padding: 0.375rem;+ appearance: none;+ width: 24px;+ height: 24px;+ margin: 0;+ padding: 0;cursor: pointer;+ background-repeat: no-repeat;+ background-position: center;+ background-size: 18px;+}+.cf-masonry-select:checked {+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23262626' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 4 4 10-10'/%3E%3C/svg%3E");+}+.cf-masonry-select:focus-visible {+ outline: 2px solid var(--ui-primary);+ outline-offset: 2px;}.cf-masonry-actions {right: 0.5rem;+ width: 24px;+ height: 24px;+ min-width: 24px;+ min-height: 24px;+ padding: 0;+ justify-content: center;}.cf-masonry-photo:hover .cf-masonry-select,.cf-masonry-photo:hover .cf-masonry-actions,@@ -124,15 +144,26 @@ function selectAll(value: boolean | 'indeterminate') {}.cf-masonry-actions:hover,.cf-masonry-select:hover {- background: rgb(20 20 24 / 55%);+ background-color: rgb(255 255 255 / 70%);+}+:global(.dark .cf-masonry-select),+:global(.dark .cf-masonry-actions) {+ color: white;+ background-color: rgb(0 0 0 / 50%);+ border-color: rgb(64 64 64 / 80%);+}+:global(.dark .cf-masonry-select:checked) {+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 4 4 10-10'/%3E%3C/svg%3E");+}+:global(.dark .cf-masonry-select:hover),+:global(.dark .cf-masonry-actions:hover) {+ background-color: rgb(0 0 0 / 70%);}@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;}diff --git a/packages/console/app/composables/usePhotoTableColumns.ts b/packages/console/app/composables/usePhotoTableColumns.tsindex b4758b0d..49ff70f6 100644--- a/packages/console/app/composables/usePhotoTableColumns.ts+++ b/packages/console/app/composables/usePhotoTableColumns.ts@@ -1,8 +1,8 @@-import { h, resolveComponent, computed } from 'vue'+import { h, 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 { Icon, UBadge, Rating } from '#components'import ThumbImage from '#gallery/components/ui/ThumbImage.vue'export function usePhotoTableColumns(options: {@@ -12,7 +12,6 @@ export function usePhotoTableColumns(options: {const { t: $t } = useI18n()const dayjs = useDayjs()const locationLabel = useLocationLabel()- const Rating = resolveComponent('Rating')const openImagePreview = options.previewconst reactionsData = options.reactionsreturn computed<TableColumn<Photo>[]>(() => [diff --git a/packages/console/app/pages/dashboard/photos.vue b/packages/console/app/pages/dashboard/photos.vueindex 89742c10..6072249c 100644--- a/packages/console/app/pages/dashboard/photos.vue+++ b/packages/console/app/pages/dashboard/photos.vue@@ -2419,7 +2419,6 @@ onUnmounted(() => {}}</span></UButton>- <ConsolePhotoLayoutSwitch v-model="layout" /><!-- 列可见性按钮 --><UDropdownMenuv-if="layout !== 'masonry'"@@ -2463,6 +2462,7 @@ onUnmounted(() => {}}</span></UButton></UDropdownMenu>+ <ConsolePhotoLayoutSwitch v-model="layout" /></div></div>diff --git a/tests/photo-table-presentation.test.ts b/tests/photo-table-presentation.test.tsindex a60ba419..3fed8c07 100644--- a/tests/photo-table-presentation.test.ts+++ b/tests/photo-table-presentation.test.ts@@ -28,7 +28,7 @@ test('shared photo columns render empty metadata and reaction breakdowns consistid === 'vue'? { h, computed, resolveComponent: (name: string) => name }: id === '#components'- ? { Icon: 'icon', UBadge: 'badge' }+ ? { Icon: 'icon', UBadge: 'badge', Rating: 'rating' }: { default: 'thumbnail' },useI18n: () => ({ t: (key: string) => key }),useDayjs: () => () => ({ format: () => 'formatted date' }),@@ -67,6 +67,10 @@ test('shared photo columns render empty metadata and reaction breakdowns consistrender('reactions').children,'dashboard.photos.table.cells.noReactions',)+ photo.exif = { Rating: 0 }+ const rating = childrenOf(render('rating'))[0]+ assert.equal(rating.type, 'rating')+ assert.equal(rating.props?.modelValue, 0)reactions.value = { p: { like: 3, love: 1 } }const reactionCells = childrenOf(render('reactions'))assert.equal(reactionCells.length, 2)