Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

feat(photos): add Sort By control to dashboard photos table

Ahmet Ömer67f3064ad71e
diff --git a/app/components/masonry/item/Header.vue b/app/components/masonry/item/Header.vue
index e7a6f0bf..2fa553cb 100644
--- a/app/components/masonry/item/Header.vue
+++ b/app/components/masonry/item/Header.vue
@@ -31,13 +31,7 @@ const handleOpenLogin = () => {
const { hasActiveFilters, selectedCounts } = usePhotoFilters()
-const {
- currentSortLabel,
- currentSortIcon,
- currentSortOption,
- availableSorts,
- setSortOption,
-} = usePhotoSort()
+const { currentSortIcon, currentSortOption } = usePhotoSort()
const totalSelectedFilters = computed(() => {
return Object.values(selectedCounts.value).reduce(
@@ -178,36 +172,7 @@ const isRepoLinkHovering = ref(false)
</UTooltip>
<template #content>
- <UCard
- variant="glassmorphism"
- class="w-3xs"
- >
- <template #header>
- <h3 class="font-bold text-sm p-1">
- {{ $t('ui.action.sort.title') }}
- </h3>
- </template>
-
- <div class="space-y-1">
- <UButton
- v-for="sort in availableSorts"
- :key="sort.key"
- :variant="
- currentSortLabel === sort.labelI18n ? 'soft' : 'ghost'
- "
- :color="
- currentSortLabel === sort.labelI18n ? 'info' : 'neutral'
- "
- :icon="sort.icon"
- size="sm"
- block
- class="justify-start"
- @click="setSortOption(sort.key)"
- >
- {{ $t(sort.labelI18n) }}
- </UButton>
- </div>
- </UCard>
+ <OverlaySortPanel />
</template>
</UPopover>
<UTooltip :text="$t('ui.action.theme.tooltip')">
diff --git a/app/components/overlay/SortPanel.vue b/app/components/overlay/SortPanel.vue
new file mode 100644
index 00000000..187e14df
--- /dev/null
+++ b/app/components/overlay/SortPanel.vue
@@ -0,0 +1,34 @@
+<script lang="ts" setup>
+const { currentSortLabel, availableSorts, setSortOption } = usePhotoSort()
+</script>
+
+<template>
+ <UCard
+ variant="glassmorphism"
+ class="w-3xs"
+ >
+ <template #header>
+ <h3 class="font-bold text-sm p-1">
+ {{ $t('ui.action.sort.title') }}
+ </h3>
+ </template>
+
+ <div class="space-y-1">
+ <UButton
+ v-for="sort in availableSorts"
+ :key="sort.key"
+ :variant="currentSortLabel === sort.labelI18n ? 'soft' : 'ghost'"
+ :color="currentSortLabel === sort.labelI18n ? 'info' : 'neutral'"
+ :icon="sort.icon"
+ size="sm"
+ block
+ class="justify-start"
+ @click="setSortOption(sort.key)"
+ >
+ {{ $t(sort.labelI18n) }}
+ </UButton>
+ </div>
+ </UCard>
+</template>
+
+<style scoped></style>
diff --git a/app/pages/dashboard/photos.vue b/app/pages/dashboard/photos.vue
index 468cd9e7..ae8bcc20 100644
--- a/app/pages/dashboard/photos.vue
+++ b/app/pages/dashboard/photos.vue
@@ -47,6 +47,7 @@ const dayjs = useDayjs()
const { status, refresh } = usePhotos()
const { filteredPhotos, selectedCounts, hasActiveFilters } = usePhotoFilters()
+const { currentSortIcon, currentSortOption } = usePhotoSort()
const totalSelectedFilters = computed(() => {
return Object.values(selectedCounts.value).reduce(
@@ -2296,6 +2297,25 @@ onUnmounted(() => {
</UCard>
</template>
</UPopover>
+ <UPopover>
+ <UTooltip :text="$t('ui.action.sort.tooltip')">
+ <UButton
+ variant="soft"
+ :color="
+ currentSortOption?.key === 'dateTaken-desc'
+ ? 'neutral'
+ : 'info'
+ "
+ class="bg-transparent rounded-full cursor-pointer"
+ :icon="currentSortIcon"
+ size="sm"
+ />
+ </UTooltip>
+
+ <template #content>
+ <OverlaySortPanel />
+ </template>
+ </UPopover>
<!-- 过滤器 -->
<USelectMenu
v-model="photoFilter"