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(tag): InfoPanel 中点击标签可跳转到标签筛选

Timothy Yin7ffc9494ad14
diff --git a/app/components/photo/InfoPanel.vue b/app/components/photo/InfoPanel.vue
index a62f8cb2..c7cbf825 100644
--- a/app/components/photo/InfoPanel.vue
+++ b/app/components/photo/InfoPanel.vue
@@ -12,6 +12,7 @@ interface Props {
}
const dayjs = useDayjs()
+const router = useRouter()
const props = defineProps<Props>()
@@ -411,6 +412,13 @@ const isMobile = useMediaQuery('(max-width: 768px)')
const onMinimapClick = (photoId: string) => {
window.open(`/explore?photoId=${photoId}`)
}
+
+const onTagClick = (tag: string) => {
+ router.push({
+ path: '/',
+ query: { tag },
+ })
+}
</script>
<template>
@@ -503,7 +511,8 @@ const onMinimapClick = (photoId: string) => {
variant="soft"
size="sm"
color="neutral"
- class="bg-white/10 text-white"
+ class="bg-white/10 text-white cursor-pointer select-none hover:bg-white/20 transition-colors"
+ @click="onTagClick(tag)"
/>
</div>
</div>
diff --git a/app/pages/[...slug].vue b/app/pages/[...slug].vue
index 936dcbf0..7ec49b0f 100644
--- a/app/pages/[...slug].vue
+++ b/app/pages/[...slug].vue
@@ -16,6 +16,19 @@ const { photos } = usePhotos()
const slug = computed(() => (route.params.slug as string[]) || [])
const photoId = computed(() => slug.value[0] || null)
+// 处理标签查询参数
+const { clearAllFilters, toggleFilter } = usePhotoFilters()
+
+// 监听路由查询参数中的标签
+watch(() => route.query.tag, (tagParam) => {
+ if (tagParam && typeof tagParam === 'string' && !photoId.value) {
+ clearAllFilters()
+ toggleFilter('tags', tagParam)
+
+ router.replace('/')
+ }
+}, { immediate: true })
+
watch(
[photoId, photos],
([currentPhotoId, currentPhotos]) => {