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(albums): view `included albums` in photo info panel
Timothy Yin5e9a14216148
diff --git a/app/components/photo/InfoPanel.vue b/app/components/photo/InfoPanel.vueindex ef1ed563..3ea72a30 100644--- a/app/components/photo/InfoPanel.vue+++ b/app/components/photo/InfoPanel.vue@@ -11,12 +11,31 @@ interface Props {onClose?: () => void}+interface Album {+ id: number+ title: string+ description: string | null+ coverPhotoId: string | null+ createdAt: Date+ updatedAt: Date+}+const dayjs = useDayjs()const router = useRouter()const { localizeExif } = useExifLocalization()const props = defineProps<Props>()+// 获取照片所属的相册+const { data: _albums } = useFetch<Album[]>(+ () => `/api/photos/${props.currentPhoto.id}/albums`,+ {+ watch: [() => props.currentPhoto.id],+ },+)++const albums = computed(() => _albums.value || [])+// 格式化曝光时间const formatExposureTime = (exposureTime: string | number | undefined,@@ -111,7 +130,9 @@ const formatedExifData = computed<Record<string, KVData[]>>(() => {props.currentPhoto.storageKey? {label: $t('exif.filename'),- value: props.currentPhoto.storageKey.split('/').pop() || props.currentPhoto.storageKey,+ value:+ props.currentPhoto.storageKey.split('/').pop() ||+ props.currentPhoto.storageKey,icon: 'tabler:file',}: null,@@ -329,7 +350,10 @@ const formatedExifData = computed<Record<string, KVData[]>>(() => {props.exifData?.ExposureProgram? {label: $t('exif.exposure.program'),- value: localizeExif('exposureProgram', props.exifData.ExposureProgram),+ value: localizeExif(+ 'exposureProgram',+ props.exifData.ExposureProgram,+ ),icon: 'tabler:exposure',}: null,@@ -357,14 +381,20 @@ const formatedExifData = computed<Record<string, KVData[]>>(() => {props.exifData?.FlashMeteringMode? {label: $t('exif.flash.meteringMode'),- value: localizeExif('meteringMode', props.exifData.FlashMeteringMode),+ value: localizeExif(+ 'meteringMode',+ props.exifData.FlashMeteringMode,+ ),icon: 'material-symbols:flash-on-rounded',}: null,props.exifData?.SceneCaptureType? {label: $t('exif.scene.captureType'),- value: localizeExif('sceneCaptureType', props.exifData.SceneCaptureType),+ value: localizeExif(+ 'sceneCaptureType',+ props.exifData.SceneCaptureType,+ ),icon: 'material-symbols:scene',}: null,@@ -387,7 +417,10 @@ const formatedExifData = computed<Record<string, KVData[]>>(() => {props.exifData?.SensingMethod? {label: $t('exif.sensing.method'),- value: localizeExif('sensingMethod', props.exifData.SensingMethod),+ value: localizeExif(+ 'sensingMethod',+ props.exifData.SensingMethod,+ ),icon: 'tabler:photo-sensor',}: null,@@ -418,6 +451,10 @@ const onTagClick = (tag: string) => {query: { tag },})}++const onAlbumClick = (albumId: number) => {+ window.open(`/albums/${albumId}`)+}</script><template>@@ -507,6 +544,36 @@ const onTagClick = (tag: string) => {/></div>+ <!-- 相册 -->+ <div+ v-if="albums && albums.length > 0"+ class="mt-4"+ >+ <h4+ class="text-sm font-medium text-white/90 uppercase tracking-wide mb-2"+ >+ {{ $t('exif.sections.albums') }}+ </h4>+ <div class="space-y-2">+ <div+ v-for="album in albums"+ :key="album.id"+ class="p-3 bg-white/5 border border-white/10 rounded-lg cursor-pointer hover:bg-white/10 transition-colors"+ @click="onAlbumClick(album.id)"+ >+ <p class="text-sm text-white font-medium line-clamp-1">+ {{ album.title }}+ </p>+ <p+ v-if="album.description"+ class="text-xs text-white/60 line-clamp-1"+ >+ {{ album.description }}+ </p>+ </div>+ </div>+ </div>+<!-- 标签 --><divv-if="currentPhoto.tags && currentPhoto.tags.length > 0"diff --git a/i18n/locales/en.json b/i18n/locales/en.jsonindex 40a114c8..4baa6266 100644--- a/i18n/locales/en.json+++ b/i18n/locales/en.json@@ -181,6 +181,7 @@"specification": "Technical parameters","rating": "Rating","tags": "Keywords",+ "albums": "Albums Included","histogram": "Histogram","capture": {},"shooting": {diff --git a/i18n/locales/ja.json b/i18n/locales/ja.jsonindex c62e2cf6..1dd28677 100644--- a/i18n/locales/ja.json+++ b/i18n/locales/ja.json@@ -180,6 +180,7 @@"specification": "技術パラメータ","rating": "評価","tags": "キーワード",+ "albums": "含まれたアルバム","histogram": "ヒストグラム","capture": {},"shooting": {diff --git a/i18n/locales/zh-Hans.json b/i18n/locales/zh-Hans.jsonindex 577e826a..82d7250c 100644--- a/i18n/locales/zh-Hans.json+++ b/i18n/locales/zh-Hans.json@@ -178,6 +178,7 @@"specification": "技术参数","rating": "评分","tags": "标签",+ "albums": "包含的相册","histogram": "直方图","capture": {},"shooting": {diff --git a/i18n/locales/zh-Hant-HK.json b/i18n/locales/zh-Hant-HK.jsonindex 60911b63..e1b31dea 100644--- a/i18n/locales/zh-Hant-HK.json+++ b/i18n/locales/zh-Hant-HK.json@@ -177,6 +177,7 @@"specification": "技術參數","rating": "評分","tags": "標籤",+ "albums": "包含的相簿","histogram": "直方圖","capture": {},"shooting": {diff --git a/i18n/locales/zh-Hant-TW.json b/i18n/locales/zh-Hant-TW.jsonindex 0dbe9f21..1910c867 100644--- a/i18n/locales/zh-Hant-TW.json+++ b/i18n/locales/zh-Hant-TW.json@@ -177,6 +177,7 @@"specification": "技術參數","rating": "評分","tags": "標籤",+ "albums": "包含的相冊","histogram": "直方圖","capture": {},"shooting": {diff --git a/server/api/albums/[albumId].delete.ts b/server/api/albums/[albumId]/index.delete.tssimilarity index 100%rename from server/api/albums/[albumId].delete.tsrename to server/api/albums/[albumId]/index.delete.tsdiff --git a/server/api/albums/[albumId].put.ts b/server/api/albums/[albumId]/index.put.tssimilarity index 100%rename from server/api/albums/[albumId].put.tsrename to server/api/albums/[albumId]/index.put.tsdiff --git a/server/api/photos/[photoId]/albums.get.ts b/server/api/photos/[photoId]/albums.get.tsnew file mode 100644index 00000000..fb6b3448--- /dev/null+++ b/server/api/photos/[photoId]/albums.get.ts@@ -0,0 +1,33 @@+import { eq } from 'drizzle-orm'+import z from 'zod'++export default eventHandler(async (event) => {+ const { photoId } = await getValidatedRouterParams(+ event,+ z.object({+ photoId: z.string(),+ }).parse,+ )++ const db = useDB()++ // 获取包含该照片的所有相册+ const albums = await db+ .select({+ id: tables.albums.id,+ title: tables.albums.title,+ description: tables.albums.description,+ coverPhotoId: tables.albums.coverPhotoId,+ createdAt: tables.albums.createdAt,+ updatedAt: tables.albums.updatedAt,+ })+ .from(tables.albums)+ .innerJoin(+ tables.albumPhotos,+ eq(tables.albums.id, tables.albumPhotos.albumId),+ )+ .where(eq(tables.albumPhotos.photoId, photoId))+ .all()++ return albums+})diff --git a/server/api/photos/[id]/reactions.ts b/server/api/photos/[photoId]/reactions.tssimilarity index 99%rename from server/api/photos/[id]/reactions.tsrename to server/api/photos/[photoId]/reactions.tsindex 797a361c..c0fed731 100644--- a/server/api/photos/[id]/reactions.ts+++ b/server/api/photos/[photoId]/reactions.ts@@ -41,7 +41,7 @@ async function checkRateLimit(fingerprint: string): Promise<boolean> {}export default defineEventHandler(async (event) => {- const photoId = getRouterParam(event, 'id')+ const photoId = getRouterParam(event, 'photoId')if (!photoId) {throw createError({