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(dashboard): 添加页面标题设置 feat(photos): 添加页面标题设置 fix(api): 修复删除照片时的存储键处理 fix(api): 修复生成预签名 URL 时的文件名处理 refactor(s3): 优化对象存储键的生成逻辑
Timothy Yin98957c8a215e
diff --git a/app/layouts/dashboard.vue b/app/layouts/dashboard.vueindex 5a39a7e5..c1588915 100644--- a/app/layouts/dashboard.vue+++ b/app/layouts/dashboard.vue@@ -14,6 +14,11 @@ const items = ref<NavigationMenuItem[]>([},])+useHead({+ title: "Dashboard",+ titleTemplate: (title) => `${title} - TimoYin's mems`,+})+const { loggedIn, user } = useUserSession()const handleLogin = () => {diff --git a/app/pages/dashboard/index.vue b/app/pages/dashboard/index.vueindex 2cbdb37c..230f7621 100644--- a/app/pages/dashboard/index.vue+++ b/app/pages/dashboard/index.vue@@ -3,6 +3,10 @@ definePageMeta({layout: 'dashboard',})+useHead({+ title: 'Dashboard',+})+interface SystemHealth {uptime: numbermemory: {diff --git a/app/pages/dashboard/photos.vue b/app/pages/dashboard/photos.vueindex 25af51a2..09c6c668 100644--- a/app/pages/dashboard/photos.vue+++ b/app/pages/dashboard/photos.vue@@ -6,6 +6,10 @@ definePageMeta({layout: 'dashboard',})+useHead({+ title: 'Photos',+})+const dayjs = useDayjs()const { data, status, refresh } = useFetch('/api/photos')diff --git a/server/api/photos/[photoId].delete.ts b/server/api/photos/[photoId].delete.tsindex 103cc91b..85aa219c 100644--- a/server/api/photos/[photoId].delete.ts+++ b/server/api/photos/[photoId].delete.ts@@ -27,11 +27,15 @@ export default eventHandler(async (event) => {if (photo.storageKey) {logger.image.info(`Deleting photo files for ${photoId} from storage`)- await storageProvider.delete(photo.storageKey)- await storageProvider.delete(`/thumbnails/${photo.storageKey}`)+ try {+ await storageProvider.delete(photo.storageKey)+ await storageProvider.delete(+ photo.thumbnailUrl?.replace(storageProvider.getPublicUrl(''), '') || '',+ )+ } catch (_) {}}- await useDB().delete(tables.photos).where(eq(tables.photos.id, photoId)).run()+ useDB().delete(tables.photos).where(eq(tables.photos.id, photoId)).run()logger.image.success(`Photo ${photoId} deleted`)diff --git a/server/api/photos/index.post.ts b/server/api/photos/index.post.tsindex 20e76770..57cf1d41 100644--- a/server/api/photos/index.post.ts+++ b/server/api/photos/index.post.ts@@ -24,12 +24,11 @@ export default eventHandler(async (event) => {}try {- // 生成唯一的文件名,使用时间戳前缀避免冲突- const uniqueFileName = `${fileName}`-+ const objectKey = `${(storageProvider.config?.prefix || '').replace(/\/+$/, '')}/${fileName}`+// 获取预签名 URL,设置1小时过期时间const signedUrl = await storageProvider.getSignedUrl(- uniqueFileName,+ objectKey,3600, // 1小时过期{contentType: contentType || 'application/octet-stream',@@ -38,7 +37,7 @@ export default eventHandler(async (event) => {return {signedUrl,- fileKey: uniqueFileName,+ fileKey: objectKey,expiresIn: 3600,}} catch (error) {diff --git a/server/services/photo/pipeline-async.ts b/server/services/photo/pipeline-async.tsindex 99b5af66..71622f37 100644--- a/server/services/photo/pipeline-async.ts+++ b/server/services/photo/pipeline-async.ts@@ -114,7 +114,7 @@ async function processPhotoInternal(setImmediate(async () => {try {const result = await storageProvider.create(- `${(storageProvider.config?.prefix || '').replace(/\/+$/, '')}/thumbnails/${photoId}.webp`,+ `thumbnails/${photoId}.webp`,thumbnailBuffer,'image/webp')diff --git a/server/services/storage/providers/s3.ts b/server/services/storage/providers/s3.tsindex 31f24b5c..1d587b39 100644--- a/server/services/storage/providers/s3.ts+++ b/server/services/storage/providers/s3.ts@@ -65,22 +65,24 @@ export class S3StorageProvider implements StorageProvider {contentType?: string,): Promise<StorageObject> {try {- const cmd = new PutObjectCommand({- Bucket: this.config.bucket,- Key: `${(this.config.prefix || '').replace(/\/+$/, '')}/${key}`.replace(+ const absoluteKey =+ `${(this.config.prefix || '').replace(/\/+$/, '')}/${key}`.replace(/^\/+/,'',- ),+ )+ const cmd = new PutObjectCommand({+ Bucket: this.config.bucket,+ Key: absoluteKey,Body: data,ContentType: contentType || 'application/octet-stream',})const resp = await this.client.send(cmd)- this.logger?.success(`Created object with key: ${key}`)+ this.logger?.success(`Created object with key: ${absoluteKey}`)return {- key,+ key: absoluteKey,size: data.length,lastModified: new Date(),etag: resp.ETag,