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(filter): add shuffle functionality to photo sorting
Timothy Yina067f0776090
diff --git a/app/components/overlay/FilterPanel.vue b/app/components/overlay/FilterPanel.vueindex 6bcb6d6c..57451cc1 100644--- a/app/components/overlay/FilterPanel.vue+++ b/app/components/overlay/FilterPanel.vue@@ -11,6 +11,8 @@ const {activeFilters,} = usePhotoFilters()+const { shufflePhotos } = usePhotoSort()+const currentTab = ref('labels')const isSearchMode = ref(false)@@ -69,6 +71,10 @@ const tabItems = computed<TabsItem[]>(() => [const handleToggleFilter = (type: string, value: string | number) => {toggleFilter(type as any, value)}++const onShuffle = () => {+ shufflePhotos()+}</script><template>@@ -84,16 +90,21 @@ const handleToggleFilter = (type: string, value: string | number) => {variant="ghost"color="neutral"icon="tabler:filter-x"- @click="() => {- clearAllFilters()- isSearchMode = false- searchQuery = ''- }"+ @click="+ () => {+ clearAllFilters()+ isSearchMode = false+ searchQuery = ''+ }+ ">{{ $t('ui.action.filter.clearAll') }}</UButton><!-- 搜索功能 -->- <div v-if="isSearchMode" class="flex items-center gap-1">+ <div+ v-if="isSearchMode"+ class="flex items-center gap-1"+ ><UInputv-model="searchQuery"size="sm"@@ -107,7 +118,12 @@ const handleToggleFilter = (type: string, value: string | number) => {variant="ghost"color="neutral"icon="tabler:x"- @click="isSearchMode = false; searchQuery = ''"+ @click="+ () => {+ isSearchMode = false+ searchQuery = ''+ }+ "/></div><UButton@@ -118,6 +134,15 @@ const handleToggleFilter = (type: string, value: string | number) => {icon="tabler:search"@click="isSearchMode = true"/>+ <UTooltip text="打乱列表">+ <UButton+ size="sm"+ variant="ghost"+ color="neutral"+ icon="tabler:dice-3"+ @click="onShuffle"+ />+ </UTooltip></div></div><!-- 标签页 -->diff --git a/app/composables/usePhotoSort.ts b/app/composables/usePhotoSort.tsindex 11c214dc..7a2cdd2a 100644--- a/app/composables/usePhotoSort.ts+++ b/app/composables/usePhotoSort.ts@@ -151,6 +151,28 @@ export function usePhotoSort() {return globalSortState.value.currentSort === 'dateTaken-desc'})+ // 打乱照片顺序+ const shufflePhotos = () => {+ // 创建一个特殊的排序方式用于打乱+ globalSortState.value.currentSort = 'shuffle'++ // 更新可用排序中的 shuffle 选项+ const shuffleIndex = globalSortState.value.availableSorts.findIndex(+ (sort) => sort.key === 'shuffle',+ )++ if (shuffleIndex === -1) {+ // 如果没有 shuffle 排序选项,则添加它+ globalSortState.value.availableSorts.push({+ key: 'shuffle',+ labelI18n: 'ui.action.sort.options.shuffle',+ icon: 'tabler:dice-3',+ value: () => Math.random(),+ order: 'asc',+ })+ }+ }+return {sortedPhotos,currentSortOption: readonly(currentSortOption),@@ -161,5 +183,6 @@ export function usePhotoSort() {isDateSortDesc,setSortOption,toggleDateSortOrder,+ shufflePhotos,}}diff --git a/i18n/locales/en.json b/i18n/locales/en.jsonindex 15d4693f..b2143ea1 100644--- a/i18n/locales/en.json+++ b/i18n/locales/en.json@@ -35,7 +35,8 @@"fileSizeAsc": "File Size (Ascending)","fileSizeDesc": "File Size (Descending)","titleAsc": "Title (Ascending)",- "titleDesc": "Title (Descending)"+ "titleDesc": "Title (Descending)",+ "shuffle": "Shuffle"}},"theme": {diff --git a/i18n/locales/ja.json b/i18n/locales/ja.jsonindex 46801b2c..cb301dfa 100644--- a/i18n/locales/ja.json+++ b/i18n/locales/ja.json@@ -35,7 +35,8 @@"fileSizeAsc": "ファイルサイズ(昇順)","fileSizeDesc": "ファイルサイズ(降順)","titleAsc": "タイトル(昇順)",- "titleDesc": "タイトル(降順)"+ "titleDesc": "タイトル(降順)",+ "shuffle": "シャッフル"}},"theme": {diff --git a/i18n/locales/zh-Hans.json b/i18n/locales/zh-Hans.jsonindex d63682a9..a34b2b2e 100644--- a/i18n/locales/zh-Hans.json+++ b/i18n/locales/zh-Hans.json@@ -43,7 +43,8 @@"fileSizeAsc": "文件大小(升序)","fileSizeDesc": "文件大小(降序)","titleAsc": "标题(A-Z)",- "titleDesc": "标题(Z-A)"+ "titleDesc": "标题(Z-A)",+ "shuffle": "打乱顺序"},"title": "排序方式","tooltip": "照片排序"diff --git a/i18n/locales/zh-Hant-HK.json b/i18n/locales/zh-Hant-HK.jsonindex 3e950ad2..d9753177 100644--- a/i18n/locales/zh-Hant-HK.json+++ b/i18n/locales/zh-Hant-HK.json@@ -43,7 +43,8 @@"fileSizeAsc": "檔案大小(升冪)","fileSizeDesc": "檔案大小(降冪)","titleAsc": "標題(A-Z)",- "titleDesc": "標題(Z-A)"+ "titleDesc": "標題(Z-A)",+ "shuffle": "打亂順序"},"title": "排序方式","tooltip": "相片排序"diff --git a/i18n/locales/zh-Hant-TW.json b/i18n/locales/zh-Hant-TW.jsonindex 6f3da128..5809e7c1 100644--- a/i18n/locales/zh-Hant-TW.json+++ b/i18n/locales/zh-Hant-TW.json@@ -43,7 +43,8 @@"fileSizeAsc": "檔案大小(升冪)","fileSizeDesc": "檔案大小(降冪)","titleAsc": "標題(A-Z)",- "titleDesc": "標題(Z-A)"+ "titleDesc": "標題(Z-A)",+ "shuffle": "打亂順序"},"title": "排序方式","tooltip": "相片排序"