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: 照片处理管线(EXIF,HEIC2JPEG,etc.),异步处理任务,任务状态面板
HoshinoSuzumi3e7cf66f5dfb
diff --git a/app/components/MasonryPhotoItem.vue b/app/components/MasonryPhotoItem.vueindex 99192470..8851a533 100644--- a/app/components/MasonryPhotoItem.vue+++ b/app/components/MasonryPhotoItem.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import { thumbHashToDataURL } from 'thumbhash'+import Thumbhash from './Thumbhash.vue'interface Props {photo: Photo@@ -26,7 +26,6 @@ const isLoading = ref(true)const actualHeight = ref(0)const photoRef = ref<HTMLElement>()const isVisible = ref(false)-const thumbHashDataUrl = ref<string | null>(null)// Computedconst containerHeight = computed(() => {@@ -35,12 +34,12 @@ const containerHeight = computed(() => {const aspectRatio = props.photo.height / props.photo.widthreturn Math.round(DEFAULT_WIDTH * aspectRatio)}-+// Fallback to calculated height if image has loadedif (actualHeight.value > 0) {return actualHeight.value}-+// Default fallback heightreturn 280})@@ -79,11 +78,13 @@ const formatDate = (date: string | Date): string => {})}-const formatExposureTime = (exposureTime: string | number | undefined): string => {+const formatExposureTime = (+ exposureTime: string | number | undefined,+): string => {if (!exposureTime) return ''-+let seconds: number-+// Handle different input formatsif (typeof exposureTime === 'string') {// Try to parse fraction format like "1/60"@@ -110,7 +111,7 @@ const formatExposureTime = (exposureTime: string | number | undefined): string =} else {seconds = exposureTime}-+// Convert to fraction formatif (seconds >= 1) {// For exposures 1 second or longer, show as decimal with "s"@@ -122,30 +123,15 @@ const formatExposureTime = (exposureTime: string | number | undefined): string =}}-// Preload image on mount to get dimensions and generate thumbhash+// Preload image on mount to get dimensionsonMounted(() => {- // Generate thumbhash data URL if available- if (props.photo.thumbnailHash) {- try {- // Convert base64 to Uint8Array- const binaryString = atob(props.photo.thumbnailHash)- const bytes = new Uint8Array(binaryString.length)- for (let i = 0; i < binaryString.length; i++) {- bytes[i] = binaryString.charCodeAt(i)- }- thumbHashDataUrl.value = thumbHashToDataURL(bytes)- } catch (error) {- console.warn('Failed to decode thumbhash:', error)- }- }-// Preload thumbnail imageif (props.photo.thumbnailUrl) {const img = new Image()img.onload = () => {if (img.naturalWidth && img.naturalHeight) {const aspectRatio = img.naturalHeight / img.naturalWidth- actualHeight.value = Math.round(DEFAULT_WIDTH * aspectRatio)+ actualHeight.value = Math.round(DEFAULT_WIDTH * (props.photo.aspectRatio || aspectRatio))}}img.src = props.photo.thumbnailUrl@@ -201,25 +187,24 @@ onMounted(() => {><divclass="relative group overflow-hidden shadow-lg hover:shadow-xl transition-all duration-300"+ :style="{ height: `${containerHeight}px` }">- <!-- Thumbhash placeholder -->+ <!-- Thumbhash 组件占位符 --><div- v-if="isLoading && thumbHashDataUrl"+ v-if="isLoading && photo.thumbnailHash"class="w-full absolute inset-0"- :style="{ height: `${containerHeight}px` }">- <img- :src="thumbHashDataUrl"- :alt="photo.title || 'Photo placeholder'"+ <Thumbhash+ :thumbhash="photo.thumbnailHash"class="w-full h-full object-cover filter blur-sm"+ :alt="photo.title || 'Photo placeholder'"/></div><!-- Loading placeholder (fallback when no thumbhash) --><div- v-if="isLoading && !thumbHashDataUrl"+ v-if="isLoading && !photo.thumbnailHash"class="w-full bg-gray-200 dark:bg-gray-700 animate-pulse"- :style="{ height: `${containerHeight}px` }"/><!-- Main image -->@@ -270,11 +255,16 @@ onMounted(() => {</div><!-- Photo specs from EXIF --><div- v-if="photo.exif && (photo.exif.FNumber || photo.exif.ExposureTime || photo.exif.ISO)"+ v-if="+ photo.exif &&+ (photo.exif.FNumber || photo.exif.ExposureTime || photo.exif.ISO)+ "class="text-xs opacity-70 mt-1 flex gap-2"><span v-if="photo.exif.FNumber">f/{{ photo.exif.FNumber }}</span>- <span v-if="photo.exif.ExposureTime">{{ formatExposureTime(photo.exif.ExposureTime) }}</span>+ <span v-if="photo.exif.ExposureTime">{{+ formatExposureTime(photo.exif.ExposureTime)+ }}</span><span v-if="photo.exif.ISO">ISO {{ photo.exif.ISO }}</span></div></div>diff --git a/app/components/Thumbhash.vue b/app/components/Thumbhash.vuenew file mode 100644index 00000000..b40e1845--- /dev/null+++ b/app/components/Thumbhash.vue@@ -0,0 +1,26 @@+<script lang="ts" setup>+import { twMerge } from 'tailwind-merge'+import { thumbHashToDataURL } from 'thumbhash'++const props = defineProps<{+ thumbhash: ArrayLike<number> | string+ class?: string+}>()++const dataUrl = computed(() => {+ if (typeof props.thumbhash === 'string') {+ return thumbHashToDataURL(decompressUint8Array(props.thumbhash))+ }++ return thumbHashToDataURL(props.thumbhash)+})+</script>++<template>+ <img+ :src="dataUrl"+ :class="twMerge('w-full h-full', props.class)"+ />+</template>++<style scoped></style>diff --git a/app/layouts/dashboard.vue b/app/layouts/dashboard.vueindex 35b033cf..ac4d2f7e 100644--- a/app/layouts/dashboard.vue+++ b/app/layouts/dashboard.vue@@ -12,6 +12,11 @@ const items = ref<NavigationMenuItem[]>([icon: 'tabler:photo-cog',to: '/dashboard/photos',},+ {+ label: 'Workers',+ icon: 'tabler:automatic-gearbox',+ to: '/dashboard/workers',+ }])</script>diff --git a/app/pages/dashboard/photos.vue b/app/pages/dashboard/photos.vueindex 72b44b16..6a227e96 100644--- a/app/pages/dashboard/photos.vue+++ b/app/pages/dashboard/photos.vue@@ -8,9 +8,41 @@ definePageMeta({})const { data, status, refresh } = useFetch('/api/photos')-const uploadImage = useUpload('/api/photos', {- method: 'PUT',-})++// 原生文件上传函数+const uploadImage = async (file: File) => {+ const formData = new FormData()+ formData.append('file', file)++ try {+ const response = await $fetch('/api/photos', {+ method: 'PUT',+ body: formData+ })++ return response+ } catch (error: any) {+ console.error('上传请求失败:', error)++ // 提供更详细的错误信息+ if (error.response?.status === 401) {+ throw new Error('未授权,请重新登录')+ } else if (error.response?.status === 413) {+ throw new Error('文件太大,请选择更小的文件')+ } else if (error.response?.status === 415) {+ throw new Error('不支持的文件格式')+ } else {+ throw new Error(error.message || '上传失败,请重试')+ }+ }+}++// 处理状态+const processingFiles = ref<Set<string>>(new Set())+const toast = useToast()++// 状态检查间隔+let statusInterval: NodeJS.Timeout | null = nullconst columns: TableColumn<Photo>[] = [{@@ -28,23 +60,166 @@ const columns: TableColumn<Photo>[] = [{accessorKey: 'fileSize',header: '文件大小',- }+ },+ {+ accessorKey: 'actions',+ header: '操作',+ },]-const handleFileUpload = async (file: any) => {- await uploadImage(file)+const checkProcessingStatus = async () => {+ if (processingFiles.value.size === 0) {+ // 如果没有文件在处理,停止检查+ if (statusInterval) {+ clearInterval(statusInterval)+ statusInterval = null+ }+ return+ }++ try {+ const response = await $fetch('/api/photos/status')+ const currentPhotoCount = data.value?.length || 0++ // 简单检查:如果照片数量增加了,说明有照片处理完成+ if (response.recentPhotos?.length > currentPhotoCount) {+ // 刷新照片列表+ await refresh()++ // 清空处理中的文件列表+ processingFiles.value.clear()++ // 停止状态检查+ if (statusInterval) {+ clearInterval(statusInterval)+ statusInterval = null+ }++ toast.add({+ title: '照片处理完成',+ description: '您的照片已成功处理并上传',+ color: 'success'+ })+ }+ } catch (error) {+ console.error('检查状态失败:', error)+ // 不显示错误给用户,避免频繁弹窗+ }+}++// 文件验证函数+const validateFile = (file: File): { valid: boolean; error?: string } => {+ // 检查文件类型+ // const allowedTypes = ['image/jpeg', 'image/png', 'image/heic', 'image/heif']+ // if (!allowedTypes.includes(file.type)) {+ // return {+ // valid: false,+ // error: `不支持的文件格式: ${file.type}。请选择 JPEG、PNG 或 HEIC 格式的图片。`+ // }+ // }++ // 检查文件大小 (128MB 限制)+ const maxSize = 128 * 1024 * 1024 // 128MB+ if (file.size > maxSize) {+ return {+ valid: false,+ error: `文件太大: ${(file.size / 1024 / 1024).toFixed(2)}MB。最大支持 128MB。`+ }+ }++ return { valid: true }+}++const handleFileUpload = async (files: unknown) => {+ // 处理 UFileUpload 的输出格式+ let fileList: File[] = []++ if (files && Array.isArray(files)) {+ fileList = files.filter((f): f is File => f instanceof File)+ } else if (files instanceof File) {+ fileList = [files]+ } else {+ console.warn('无效的文件类型:', files)+ return+ }++ for (const file of fileList) {+ // 验证文件+ const validation = validateFile(file)+ if (!validation.valid) {+ toast.add({+ title: '文件验证失败',+ description: validation.error,+ color: 'error'+ })+ continue+ }++ const fileName = file.name+ processingFiles.value.add(fileName)++ toast.add({+ title: '开始处理照片',+ description: `正在后台处理 ${fileName},请稍候...`,+ color: 'info'+ })++ try {+ await uploadImage(file)++ // 开始状态检查+ if (!statusInterval) {+ statusInterval = setInterval(checkProcessingStatus, 2000)+ }+ } catch (error: any) {+ processingFiles.value.delete(fileName)+ toast.add({+ title: '上传失败',+ description: `${fileName}: ${error.message}`,+ color: 'error'+ })+ console.error('上传错误:', error)+ }+ }+}++const handleDelete = async (photoId: string) => {+ await $fetch(`/api/photos/${photoId}`, {+ method: 'DELETE',+ })refresh()}++// 清理定时器+onUnmounted(() => {+ if (statusInterval) {+ clearInterval(statusInterval)+ }+})</script><template><div class="flex flex-col gap-4 h-full p-4">+ <!-- 处理状态指示器 -->+ <div v-if="processingFiles.size > 0" class="bg-blue-50 border border-blue-200 rounded-lg p-4">+ <div class="flex items-center gap-2">+ <UIcon name="i-heroicons-arrow-path" class="animate-spin text-blue-500" />+ <span class="text-blue-700 font-medium">+ 正在后台处理 {{ processingFiles.size }} 个文件...+ </span>+ </div>+ <p class="text-sm text-blue-600 mt-1">+ 处理完成后会自动刷新列表,您可以继续浏览其他页面+ </p>+ </div>+<UFileUploadlabel="上传照片"- description="支持 JPEG, PNG, HEIC 格式"+ description="支持 JPEG、PNG、HEIC 格式,最大 128MB"layout="list"size="xl"- accept="image/jpeg,image/png,image/heic"+ accept="image/jpeg,image/png,image/heic,image/heif"+ multiple@update:model-value="handleFileUpload"/><div class="border border-neutral-300 rounded overflow-hidden">@@ -57,7 +232,18 @@ const handleFileUpload = async (file: any) => {:ui="{separator: 'bg-(--ui-color-neutral-200)',}"- />+ >+ <template #actions-cell="{ row }">+ <UButton+ size="sm"+ variant="soft"+ color="error"+ @click="handleDelete(row.original.id)"+ >+ 删除+ </UButton>+ </template>+ </UTable></div></div></template>diff --git a/app/pages/dashboard/workers.vue b/app/pages/dashboard/workers.vuenew file mode 100644index 00000000..3c0fa244--- /dev/null+++ b/app/pages/dashboard/workers.vue@@ -0,0 +1,251 @@+<script lang="ts" setup>+definePageMeta({+ layout: 'dashboard',+})++interface ProcessingStatus {+ recentPhotos: any[]+ timestamp: string+}++interface SystemHealth {+ uptime: number+ memory: {+ used: number+ total: number+ }+ processing: {+ active: boolean+ queued: number+ }+}++const { data: recentStatus, refresh: refreshRecent } =+ await useFetch<ProcessingStatus>('/api/photos/status', {+ server: false,+ })++const { data: healthStatus, refresh: refreshHealth } =+ await useFetch<SystemHealth>('/api/health/system', {+ server: false,+ })++const isLoading = ref(false)++const refreshData = async () => {+ isLoading.value = true+ try {+ await Promise.all([refreshRecent(), refreshHealth()])+ } finally {+ isLoading.value = false+ }+}++const triggerTestProcessing = async () => {+ isLoading.value = true+ try {+ await $fetch('/api/test/photo-processing', {+ method: 'POST'+ })++ await refreshData()+ useToast().add({+ title: '测试处理启动',+ description: '后台照片处理测试已开始',+ color: 'success',+ })+ } catch (error) {+ useToast().add({+ title: '测试失败',+ description: '无法启动测试处理',+ color: 'error',+ })+ } finally {+ isLoading.value = false+ }+}++// 定期刷新状态+const refreshInterval = setInterval(refreshData, 3000)++onBeforeUnmount(() => {+ clearInterval(refreshInterval)+})+</script>++<template>+ <div class="flex flex-col gap-6 h-full p-4">+ <div class="flex items-center justify-between">+ <h1 class="text-2xl font-bold">后台处理监控</h1>+ <div class="flex gap-2">+ <UButton+ icon="i-tabler-refresh"+ variant="outline"+ :loading="isLoading"+ @click="refreshData"+ >+ 刷新+ </UButton>+ <UButton+ icon="i-tabler-test-pipe"+ variant="outline"+ color="primary"+ :loading="isLoading"+ @click="triggerTestProcessing"+ >+ 测试处理+ </UButton>+ </div>+ </div>++ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">+ <!-- 最近处理的照片数量 -->+ <UCard>+ <div class="flex items-center justify-between">+ <div>+ <p class="text-sm text-gray-500 dark:text-gray-400">+ 最近处理照片+ </p>+ <p class="text-2xl font-bold">{{ recentStatus?.recentPhotos?.length || 0 }}</p>+ </div>+ <UIcon+ name="i-tabler-photo"+ class="w-8 h-8 text-blue-500"+ />+ </div>+ </UCard>++ <!-- 系统内存使用 -->+ <UCard>+ <div class="flex items-center justify-between">+ <div>+ <p class="text-sm text-gray-500 dark:text-gray-400">+ 内存使用率+ </p>+ <p class="text-2xl font-bold">+ {{ healthStatus?.memory ? Math.round((healthStatus.memory.used / healthStatus.memory.total) * 100) : 0 }}%+ </p>+ </div>+ <UIcon+ name="i-tabler-cpu"+ class="w-8 h-8 text-green-500"+ />+ </div>+ </UCard>++ <!-- 处理队列状态 -->+ <UCard>+ <div class="flex items-center justify-between">+ <div>+ <p class="text-sm text-gray-500 dark:text-gray-400">队列任务</p>+ <p class="text-2xl font-bold">{{ healthStatus?.processing?.queued || 0 }}</p>+ </div>+ <UIcon+ name="i-tabler-list"+ class="w-8 h-8 text-yellow-500"+ />+ </div>+ </UCard>++ <!-- 系统运行时间 -->+ <UCard>+ <div class="flex items-center justify-between">+ <div>+ <p class="text-sm text-gray-500 dark:text-gray-400">+ 运行时间+ </p>+ <p class="text-2xl font-bold">+ {{ healthStatus?.uptime ? Math.round(healthStatus.uptime / 3600) : 0 }}h+ </p>+ </div>+ <UIcon+ name="i-tabler-clock"+ class="w-8 h-8 text-purple-500"+ />+ </div>+ </UCard>+ </div>++ <!-- 后台处理配置 -->+ <UCard>+ <template #header>+ <h2 class="text-lg font-semibold">后台处理配置</h2>+ </template>++ <div class="grid grid-cols-2 gap-4">+ <div>+ <p class="text-sm text-gray-500 dark:text-gray-400">处理模式</p>+ <p class="text-lg font-bold">异步后台处理</p>+ </div>+ <div>+ <p class="text-sm text-gray-500 dark:text-gray-400">+ 响应时间+ </p>+ <p class="text-lg font-bold text-green-600">+ < 50ms+ </p>+ </div>+ </div>+ </UCard>++ <!-- 系统状态 -->+ <UCard>+ <template #header>+ <h2 class="text-lg font-semibold">系统状态</h2>+ </template>++ <div class="flex items-center gap-3">+ <UBadge+ :color="healthStatus?.processing?.active !== false ? 'success' : 'warning'"+ variant="solid"+ >+ {{ healthStatus?.processing?.active !== false ? '正常运行' : '待机' }}+ </UBadge>+ <span class="text-sm text-gray-500 dark:text-gray-400">+ 后台处理系统{{ healthStatus?.processing?.active !== false ? '正在运行' : '处于待机状态' }}+ </span>+ </div>++ <div class="mt-4 space-y-2">+ <div class="flex justify-between text-sm">+ <span>最后更新:</span>+ <span class="font-medium">+ {{ recentStatus?.timestamp ? new Date(recentStatus.timestamp).toLocaleString('zh-CN') : '未知' }}+ </span>+ </div>+ <div class="flex justify-between text-sm">+ <span>处理性能:</span>+ <span class="font-medium text-green-600">+ 高效非阻塞+ </span>+ </div>+ </div>+ </UCard>++ <!-- 最近处理的照片 -->+ <UCard v-if="recentStatus?.recentPhotos?.length">+ <template #header>+ <h2 class="text-lg font-semibold">最近处理的照片</h2>+ </template>++ <div class="space-y-2">+ <div+ v-for="photo in recentStatus.recentPhotos.slice(0, 5)"+ :key="photo.id"+ class="flex justify-between items-center p-2 bg-gray-50 dark:bg-gray-800 rounded"+ >+ <div>+ <p class="font-medium">{{ photo.title || photo.id }}</p>+ <p class="text-sm text-gray-500">{{ photo.fileSize ? (photo.fileSize / 1024 / 1024).toFixed(2) + ' MB' : '未知大小' }}</p>+ </div>+ <div class="text-right">+ <p class="text-sm text-gray-500">{{ photo.lastModified ? new Date(photo.lastModified).toLocaleString('zh-CN') : '未知时间' }}</p>+ <UBadge color="success" variant="soft">已完成</UBadge>+ </div>+ </div>+ </div>+ </UCard>+ </div>+</template>++<style scoped></style>diff --git a/drizzle.config.ts b/drizzle.config.tsindex 394b628b..2f8d3abb 100644--- a/drizzle.config.ts+++ b/drizzle.config.ts@@ -4,4 +4,7 @@ export default defineConfig({dialect: 'sqlite',schema: './server/database/schema.ts',out: './server/database/migrations',+ dbCredentials: {+ url: 'file:./.data/chronoframe.sqlite3'+ }})diff --git a/exifr b/exifrdeleted file mode 100644index e69de29b..00000000diff --git a/generate-hash.mjs b/generate-hash.mjsdeleted file mode 100644index 4e587542..00000000--- a/generate-hash.mjs+++ /dev/null@@ -1,11 +0,0 @@-import crypto from 'crypto';--const password = 'admin123';-const salt = crypto.randomBytes(16).toString('hex');--crypto.scrypt(password, salt, 64, (err, derivedKey) => {- if (err) throw err;- const hash = salt + ':' + derivedKey.toString('hex');- console.log('Generated hash for password "' + password + '":');- console.log(hash);-});diff --git a/nuxt.config.ts b/nuxt.config.tsindex 6722b127..5f1303b7 100644--- a/nuxt.config.ts+++ b/nuxt.config.ts@@ -13,7 +13,6 @@ export default defineNuxtConfig({'@nuxt/image','@nuxt/test-utils','motion-v/nuxt',- '@nuxthub/core','nuxt-auth-utils',],@@ -32,13 +31,8 @@ export default defineNuxtConfig({CLOUDFLARE_D1_UUID: '',},- hub: {- database: true,- blob: true,- },-nitro: {- preset: 'cloudflare-module',+ preset: 'node_server',cloudflare: {deployConfig: true,nodeCompat: true,@@ -48,4 +42,4 @@ export default defineNuxtConfig({vite: {plugins: [tailwindcss() as any],},-})\ No newline at end of file+})diff --git a/package.json b/package.jsonindex 87492180..0fcfe03f 100644--- a/package.json+++ b/package.json@@ -8,6 +8,7 @@"type": "module","private": true,"scripts": {+ "db": "drizzle-kit","db:generate": "drizzle-kit generate","build": "nuxt build","build:deps": "pnpm --filter @chronoframe/webgl-image build",@@ -20,6 +21,8 @@"dependencies": {"@aws-sdk/client-s3": "^3.873.0","@chronoframe/webgl-image": "workspace:*",+ "@img/sharp-libvips-dev": "^1.2.1",+ "@img/sharp-wasm32": "^0.34.3","@nuxt/eslint": "1.9.0","@nuxt/fonts": "0.11.4","@nuxt/icon": "2.0.0",@@ -29,8 +32,10 @@"@nuxthub/core": "0.9.0","@tailwindcss/vite": "^4.1.12","@vingle/bmp-js": "^0.2.5",+ "better-sqlite3": "^12.2.0","cloudflare": "^4.5.0","concurrently": "^9.2.0",+ "db0": "^0.3.2","drizzle-orm": "^0.44.4","es-toolkit": "^1.39.10","eslint": "^9.0.0",@@ -42,6 +47,7 @@"nuxt": "^4.0.3","nuxt-auth-utils": "0.5.23","sharp": "^0.34.3",+ "tailwind-merge": "^3.3.1","tailwindcss": "^4.1.12","thumbhash": "^0.1.1","vue": "^3.5.18",@@ -52,11 +58,19 @@"packageManager": "[email protected]+sha512.1f79bc245a66eb0b07c5d4d83131240774642caaa86ef7d0434ab47c0d16f66b04e21e0c086eb61e62c77efc4d7f7ec071afad3796af64892fae66509173893a","devDependencies": {"@iconify-json/tabler": "^1.2.22",+ "@types/better-sqlite3": "^7.6.13","@types/heic-convert": "^2.1.0","consola": "^3.4.2","drizzle-kit": "^0.31.4","eslint-config-prettier": "^10.1.8","eslint-plugin-prettier": "^5.5.4","prettier": "^3.6.2"+ },+ "pnpm": {+ "peerDependencyRules": {+ "ignoreMissing": [+ "@nuxt/kit"+ ]+ }}}\ No newline at end of filediff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ebccc5ec..344d7e0f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -14,42 +14,54 @@ importers:'@chronoframe/webgl-image':specifier: workspace:*version: link:packages/webgl-image+ '@img/sharp-libvips-dev':+ specifier: ^1.2.1+ version: 1.2.1+ '@img/sharp-wasm32':+ specifier: ^0.34.3+ version: 0.34.3'@nuxt/eslint':specifier: 1.9.0version: 1.9.0(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))(@vue/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))'@nuxt/fonts':specifier: 0.11.4- version: 0.11.4(@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 0.11.4(@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))'@nuxt/icon':specifier: 2.0.0version: 2.0.0([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))'@nuxt/image':specifier: 1.11.0- version: 1.11.0(@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])([email protected])+ version: 1.11.0(@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])([email protected])'@nuxt/test-utils':specifier: 3.19.2version: 3.19.2([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))'@nuxt/ui':specifier: ^3.3.2- version: 3.3.2(@babel/[email protected])(@netlify/[email protected])([email protected])([email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]([email protected])))([email protected]([email protected]))([email protected])+ version: 3.3.2(@babel/[email protected])(@netlify/[email protected])([email protected])([email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]([email protected])))([email protected]([email protected]))([email protected])'@nuxthub/core':specifier: 0.9.0- version: 0.9.0(@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 0.9.0(@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))'@tailwindcss/vite':specifier: ^4.1.12version: 4.1.12([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))'@vingle/bmp-js':specifier: ^0.2.5version: 0.2.5+ better-sqlite3:+ specifier: ^12.2.0+ version: 12.2.0cloudflare:specifier: ^4.5.0version: 4.5.0concurrently:specifier: ^9.2.0version: 9.2.0+ db0:+ specifier: ^0.3.2+ version: 0.3.2([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected]))drizzle-orm:specifier: ^0.44.4- version: 0.44.4(@cloudflare/[email protected])es-toolkit:specifier: ^1.39.10version: 1.39.10@@ -73,13 +85,16 @@ importers:version: 1.7.0(@vueuse/[email protected]([email protected]([email protected])))([email protected]([email protected]))nuxt:specifier: ^4.0.3- version: 4.0.3(@netlify/[email protected])(@parcel/[email protected])(@types/[email protected])(@vue/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected](@cloudflare/[email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])+ version: 4.0.3(@netlify/[email protected])(@parcel/[email protected])(@types/[email protected])(@vue/[email protected])([email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])nuxt-auth-utils:specifier: 0.5.23version: 0.5.23([email protected])sharp:specifier: ^0.34.3version: 0.34.3+ tailwind-merge:+ specifier: ^3.3.1+ version: 3.3.1tailwindcss:specifier: ^4.1.12version: 4.1.12@@ -102,6 +117,9 @@ importers:'@iconify-json/tabler':specifier: ^1.2.22version: 1.2.22+ '@types/better-sqlite3':+ specifier: ^7.6.13+ version: 7.6.13'@types/heic-convert':specifier: ^2.1.0version: 2.1.0@@ -1305,6 +1323,9 @@ packages:cpu: [x64]os: [darwin]+ '@img/[email protected]':+ resolution: {integrity: sha512-rKow96nMmQQwM5FkZg9TYkd0f5A31V/fWjEb2BvTO2yOpSO7t93QFqfiSOSH7idncBGVAlURYFfUJMczhIUmUA==}+'@img/[email protected]':resolution: {integrity: sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==}cpu: [arm64]@@ -1456,7 +1477,6 @@ packages:'@img/[email protected]':resolution: {integrity: sha512-+CyRcpagHMGteySaWos8IbnXcHgfDn7pO2fiC2slJxvNq9gDipYBN42/RagzctVRKgxATmfqOSulgZv5e1RdMg==}engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [wasm32]'@img/[email protected]':resolution: {integrity: sha512-MjnHPnbqMXNC2UgeLJtX4XqoVHHlZNd+nPt1kRPmj63wURegwBhZlApELdtxM2OIZDRv/DFtLcNhVbd1z8GYXQ==}@@ -2745,6 +2765,9 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==}+ '@types/[email protected]':+ resolution: {integrity: sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==}+'@types/[email protected]':resolution: {integrity: sha512-VgZkrJckypj85YxEsEavcMmmSOIzkUHqWmM4CCyia5dc54YwsXzJ5uT4fYxBQNEXx+oF1krlhgCbvfubXqZYsQ==}@@ -3423,6 +3446,10 @@ packages:resolution: {integrity: sha512-tymryLKMSho+WAaYiVQCMQ9SNHOrNDKO+J8l89RyICkSwK05XknrILAPUz6ABWa8MZOoTbLpIxFCFfyBTZGrIA==}engines: {node: '>=20'}+ resolution: {integrity: sha512-eGbYq2CT+tos1fBwLQ/tkBt9J5M3JEHjku4hbvQUePCckkvVf14xWj+1m7dGoK81M/fOjFT7yM9UMeKT/+vFLQ==}+ engines: {node: 20.x || 22.x || 23.x || 24.x}+resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}engines: {node: '>=8'}@@ -7918,7 +7945,6 @@ snapshots:'@emnapi/[email protected]':dependencies:tslib: 2.8.1- optional: true'@emnapi/[email protected]':dependencies:@@ -8425,6 +8451,8 @@ snapshots:'@img/[email protected]':optional: true+ '@img/[email protected]': {}+'@img/[email protected]':optional: true@@ -8537,7 +8565,6 @@ snapshots:'@img/[email protected]':dependencies:'@emnapi/runtime': 1.4.5- optional: true'@img/[email protected]':optional: true@@ -8993,7 +9020,7 @@ snapshots:- utf-8-validate- vite- '@nuxt/[email protected](@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))':+ '@nuxt/[email protected](@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))':dependencies:'@nuxt/devtools-kit': 2.6.2([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))'@nuxt/kit': 3.18.1([email protected])@@ -9014,7 +9041,7 @@ snapshots:ufo: 1.6.1unifont: 0.4.1unplugin: 2.3.8- unstorage: 1.16.1(@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])+ unstorage: 1.16.1(@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])transitivePeerDependencies:- '@azure/app-configuration'- '@azure/cosmos'@@ -9082,7 +9109,7 @@ snapshots:- vite- vue- '@nuxt/[email protected](@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])([email protected])':+ '@nuxt/[email protected](@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])([email protected])':dependencies:'@nuxt/kit': 3.18.1([email protected])consola: 3.4.2@@ -9095,7 +9122,7 @@ snapshots:std-env: 3.9.0ufo: 1.6.1optionalDependencies:- ipx: 2.1.1(@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])+ ipx: 2.1.1(@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])transitivePeerDependencies:- '@azure/app-configuration'- '@azure/cosmos'@@ -9229,12 +9256,12 @@ snapshots:- magicast- typescript- '@nuxt/[email protected](@babel/[email protected])(@netlify/[email protected])([email protected])([email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]([email protected])))([email protected]([email protected]))([email protected])':+ '@nuxt/[email protected](@babel/[email protected])(@netlify/[email protected])([email protected])([email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]([email protected])))([email protected]([email protected]))([email protected])':dependencies:'@iconify/vue': 5.0.0([email protected]([email protected]))'@internationalized/date': 3.8.2'@internationalized/number': 3.6.4- '@nuxt/fonts': 0.11.4(@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))+ '@nuxt/fonts': 0.11.4(@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))'@nuxt/icon': 1.15.0([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))'@nuxt/kit': 4.0.3([email protected])'@nuxt/schema': 4.0.3@@ -9374,7 +9401,7 @@ snapshots:- vue-tsc- yaml- '@nuxthub/[email protected](@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))':+ '@nuxthub/[email protected](@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))':dependencies:'@cloudflare/workers-types': 4.20250823.0'@nuxt/devtools-kit': 2.6.2([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))@@ -9393,7 +9420,7 @@ snapshots:std-env: 3.9.0ufo: 1.6.1uncrypto: 0.1.3- unstorage: 1.16.1(@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])+ unstorage: 1.16.1(@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])zod: 3.25.76transitivePeerDependencies:- '@azure/app-configuration'@@ -10309,6 +10336,10 @@ snapshots:'@types/[email protected]': {}+ '@types/[email protected]':+ dependencies:+ '@types/node': 24.3.0+'@types/[email protected]': {}'@types/[email protected]':@@ -10366,7 +10397,7 @@ snapshots:'@types/[email protected]':dependencies:- '@types/node': 22.17.2+ '@types/node': 24.3.0optional: true'@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])':@@ -11077,6 +11108,11 @@ snapshots:+ dependencies:+ bindings: 1.5.0+ prebuild-install: 7.1.3+@@ -11090,7 +11126,6 @@ snapshots:buffer: 5.7.1inherits: 2.0.4readable-stream: 3.6.2- optional: true@@ -11134,7 +11169,6 @@ snapshots:dependencies:base64-js: 1.5.1ieee754: 1.2.1- optional: truedependencies:@@ -11235,8 +11269,7 @@ snapshots:dependencies:readdirp: 4.1.2- optional: true+ [email protected]: {}@@ -11504,9 +11537,10 @@ snapshots:+ [email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])):optionalDependencies:- drizzle-orm: 0.44.4(@cloudflare/[email protected])+ better-sqlite3: 12.2.0@@ -11521,13 +11555,11 @@ snapshots:dependencies:mimic-response: 3.1.0- optional: trueoptional: true- optional: true+ [email protected]: {}@@ -11655,9 +11687,11 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected](@cloudflare/[email protected]):optionalDependencies:'@cloudflare/workers-types': 4.20250823.0+ '@types/better-sqlite3': 7.6.13+ better-sqlite3: 12.2.0dependencies:@@ -12136,8 +12170,7 @@ snapshots:- optional: true+ [email protected]: {}optional: true@@ -12296,8 +12329,7 @@ snapshots:- optional: true+ [email protected]: {}dependencies:@@ -12369,8 +12401,7 @@ snapshots:dependencies:git-up: 8.1.1- optional: true+ [email protected]: {}dependencies:@@ -12526,8 +12557,7 @@ snapshots:- optional: true+ [email protected]: {}@@ -12545,7 +12575,7 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected](@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected]):+ [email protected](@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected]):dependencies:'@fastify/accept-negotiator': 1.1.0citty: 0.1.6@@ -12561,7 +12591,7 @@ snapshots:sharp: 0.32.6svgo: 3.3.2ufo: 1.6.1- unstorage: 1.16.1(@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])+ unstorage: 1.16.1(@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])xss: 1.0.15transitivePeerDependencies:- '@azure/app-configuration'@@ -12967,8 +12997,7 @@ snapshots:- optional: true+ [email protected]: {}@@ -13016,8 +13045,7 @@ snapshots:- optional: true+ [email protected]: {}@@ -13065,8 +13093,7 @@ snapshots:- optional: true+ [email protected]: {}@@ -13087,7 +13114,7 @@ snapshots:mlly: 1.7.4pkg-types: 2.3.0+ [email protected](@netlify/[email protected])([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])):dependencies:'@cloudflare/kv-asset-handler': 0.4.0'@netlify/functions': 3.1.10([email protected])@@ -13109,7 +13136,7 @@ snapshots:cookie-es: 2.0.0croner: 9.1.0crossws: 0.3.5- db0: 0.3.2([email protected](@cloudflare/[email protected]))+ db0: 0.3.2([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected]))defu: 6.1.4destr: 2.0.5dot-prop: 9.0.0@@ -13155,7 +13182,7 @@ snapshots:unenv: 2.0.0-rc.19unimport: 5.2.0unplugin-utils: 0.2.5- unstorage: 1.16.1(@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])+ unstorage: 1.16.1(@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])untyped: 2.0.0unwasm: 0.3.11youch: 4.1.0-beta.8@@ -13190,7 +13217,6 @@ snapshots:dependencies:semver: 7.7.2- optional: trueoptional: true@@ -13272,7 +13298,7 @@ snapshots:- bcrypt- magicast- [email protected](@netlify/[email protected])(@parcel/[email protected])(@types/[email protected])(@vue/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected](@cloudflare/[email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]):+ [email protected](@netlify/[email protected])(@parcel/[email protected])(@types/[email protected])(@vue/[email protected])([email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]):dependencies:'@nuxt/cli': 3.28.0([email protected])'@nuxt/devalue': 2.0.2@@ -13307,7 +13333,7 @@ snapshots:mlly: 1.7.4mocked-exports: 0.1.1nanotar: 0.2.0+ nitropack: 2.12.4(@netlify/[email protected])([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected]))nypm: 0.6.1ofetch: 1.4.1ohash: 2.0.11@@ -13332,7 +13358,7 @@ snapshots:unimport: 5.2.0unplugin: 2.3.8unplugin-vue-router: 0.15.0(@vue/[email protected])([email protected])([email protected]([email protected]([email protected])))([email protected]([email protected]))- unstorage: 1.16.1(@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected])+ unstorage: 1.16.1(@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected])untyped: 2.0.0vue: 3.5.19([email protected])vue-bundle-renderer: 2.1.2@@ -13827,7 +13853,6 @@ snapshots:simple-get: 4.0.1tar-fs: 2.1.3tunnel-agent: 0.6.0- optional: truedependencies:@@ -13908,7 +13933,6 @@ snapshots:ini: 1.3.8minimist: 1.2.8strip-json-comments: 2.0.1- optional: truedependencies:@@ -14244,15 +14268,13 @@ snapshots:- optional: true+ [email protected]: {}dependencies:decompress-response: 6.0.0once: 1.4.0simple-concat: 1.0.1- optional: truedependencies:@@ -14374,8 +14396,7 @@ snapshots:dependencies:min-indent: 1.0.1- optional: true+ [email protected]: {}@@ -14454,7 +14475,6 @@ snapshots:mkdirp-classic: 0.5.3pump: 3.0.3tar-stream: 2.2.0- optional: truedependencies:@@ -14474,7 +14494,6 @@ snapshots:fs-constants: 1.0.0inherits: 2.0.4readable-stream: 3.6.2- optional: truedependencies:@@ -14565,7 +14584,6 @@ snapshots:dependencies:safe-buffer: 5.2.1- optional: truedependencies:@@ -14761,7 +14779,7 @@ snapshots:'@unrs/resolver-binding-win32-ia32-msvc': 1.11.1'@unrs/resolver-binding-win32-x64-msvc': 1.11.1- [email protected](@netlify/[email protected])([email protected]([email protected](@cloudflare/[email protected])))([email protected]):+ [email protected](@netlify/[email protected])([email protected]([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected])))([email protected]):dependencies:anymatch: 3.1.3chokidar: 4.0.3@@ -14773,7 +14791,7 @@ snapshots:ufo: 1.6.1optionalDependencies:'@netlify/blobs': 9.1.2- db0: 0.3.2([email protected](@cloudflare/[email protected]))+ db0: 0.3.2([email protected])([email protected](@cloudflare/[email protected])(@types/[email protected])([email protected]))ioredis: 5.7.0diff --git a/server/api/health/processor.ts b/server/api/health/processor.tsnew file mode 100644index 00000000..f956aac9--- /dev/null+++ b/server/api/health/processor.ts@@ -0,0 +1,15 @@+export default eventHandler(async (event) => {+ // 简单的处理器状态检查+ const status = {+ mode: 'background-processing',+ active: true,+ type: 'async-setImmediate',+ blocking: false+ }++ return {+ processor: status,+ timestamp: new Date().toISOString(),+ message: 'Background photo processing status'+ }+})diff --git a/server/api/health/system.ts b/server/api/health/system.tsnew file mode 100644index 00000000..42c89421--- /dev/null+++ b/server/api/health/system.ts@@ -0,0 +1,26 @@+export default eventHandler(async (event) => {+ const method = getMethod(event)++ if (method === 'GET') {+ const memUsage = process.memoryUsage()+ const uptime = process.uptime()++ return {+ uptime: uptime,+ memory: {+ used: memUsage.heapUsed,+ total: memUsage.heapTotal+ },+ processing: {+ active: true,+ queued: 0 // 后台处理不维护队列+ },+ timestamp: new Date().toISOString()+ }+ }++ throw createError({+ statusCode: 405,+ statusMessage: 'Method not allowed'+ })+})diff --git a/server/api/photos/[photoId].delete.ts b/server/api/photos/[photoId].delete.tsnew file mode 100644index 00000000..103cc91b--- /dev/null+++ b/server/api/photos/[photoId].delete.ts@@ -0,0 +1,42 @@+export default eventHandler(async (event) => {+ await requireUserSession(event)+ const { storageProvider } = useStorageProvider(event)+ const photoId = getRouterParam(event, 'photoId')++ if (!photoId) {+ return createError({+ statusCode: 400,+ statusMessage: 'Photo ID is required',+ })+ }++ const photo = await useDB()+ .select()+ .from(tables.photos)+ .where(eq(tables.photos.id, photoId))+ .get()++ if (!photo) {+ return createError({+ statusCode: 404,+ statusMessage: 'Photo not found',+ })+ }++ logger.image.info(`Deleting photo ${photo.title || photo.id || photoId}`)++ if (photo.storageKey) {+ logger.image.info(`Deleting photo files for ${photoId} from storage`)+ await storageProvider.delete(photo.storageKey)+ await storageProvider.delete(`/thumbnails/${photo.storageKey}`)+ }++ await useDB().delete(tables.photos).where(eq(tables.photos.id, photoId)).run()++ logger.image.success(`Photo ${photoId} deleted`)++ return {+ statusCode: 200,+ statusMessage: 'Photo deleted successfully',+ }+})diff --git a/server/api/photos/index.put.ts b/server/api/photos/index.put.tsindex 5ef06db8..4dbefb3f 100644--- a/server/api/photos/index.put.ts+++ b/server/api/photos/index.put.ts@@ -1,12 +1,15 @@import sharp from 'sharp'-import { execPhotoPipeline } from '~~/server/services/photo/pipeline'+import { execPhotoPipelineAsync } from '~~/server/services/photo/pipeline-async'import { useStorageProvider } from '~~/server/utils/useStorageProvider'export default eventHandler(async (event) => {await requireUserSession(event)const { storageProvider } = useStorageProvider(event)const formData = await readFormData(event)- const file = formData.get('files') as File | null++ // 尝试从两个可能的字段名获取文件+ const file = (formData.get('file') || formData.get('files')) as File | null+if (!file || Array.isArray(file)) {throw createError({statusCode: 400,@@ -19,20 +22,33 @@ export default eventHandler(async (event) => {Buffer.from(await file.arrayBuffer()),)- const photo = await execPhotoPipeline(originalObject.key, originalObject)+ // 立即返回响应,不等待处理完成+ const processingPromise = processPhotoInBackground(originalObject.key, originalObject)- if (!photo) {- throw createError({- statusCode: 500,- statusMessage: 'Photo processing failed',- })+ // 返回处理中的响应+ return {+ message: 'Photo upload successful, processing in background',+ fileKey: originalObject.key,+ fileName: file.name,+ status: 'processing'}+})- await useDB().insert(tables.photos).values(photo).execute()- logger.chrono.success(- 'Photo processing completed.',- photo.title || photo.storageKey,- )+// 后台处理函数+async function processPhotoInBackground(s3key: string, originalObject: any) {+ try {+ logger.chrono.info('Starting background photo processing for', s3key)++ const photo = await execPhotoPipelineAsync(s3key, originalObject)- return [originalObject]-})+ if (!photo) {+ logger.chrono.error('Photo processing failed for', s3key)+ return+ }++ await useDB().insert(tables.photos).values(photo).execute()+ logger.chrono.success('Background photo processing completed for', photo.title || photo.storageKey)+ } catch (error) {+ logger.chrono.error('Background photo processing error for', s3key, error)+ }+}diff --git a/server/api/photos/status.ts b/server/api/photos/status.tsnew file mode 100644index 00000000..f09fae81--- /dev/null+++ b/server/api/photos/status.ts@@ -0,0 +1,27 @@+import { photos } from '~~/server/database/schema'++export default eventHandler(async (event) => {+ await requireUserSession(event)++ const method = getMethod(event)++ if (method === 'GET') {+ // 获取最新处理完成的照片+ const recentPhotos = await useDB()+ .select()+ .from(photos)+ .orderBy(photos.lastModified)+ .limit(10)+ .all()++ return {+ recentPhotos,+ timestamp: new Date().toISOString()+ }+ } else {+ throw createError({+ statusCode: 405,+ statusMessage: 'Method not allowed',+ })+ }+})diff --git a/server/database/migrations/0000_curvy_scarlet_witch.sql b/server/database/migrations/0000_curvy_scarlet_witch.sqlnew file mode 100644index 00000000..5e8a5b9f--- /dev/null+++ b/server/database/migrations/0000_curvy_scarlet_witch.sql@@ -0,0 +1,35 @@+CREATE TABLE `photos` (+ `id` text PRIMARY KEY NOT NULL,+ `title` text,+ `description` text,+ `width` integer,+ `height` integer,+ `aspect_ratio` real,+ `date_taken` text,+ `storage_key` text,+ `file_size` integer,+ `last_modified` text,+ `original_url` text,+ `thumbnail_url` text,+ `thumbnail_hash` text,+ `tags` text,+ `exif` text+);+--> statement-breakpoint+CREATE UNIQUE INDEX `photos_id_unique` ON `photos` (`id`);--> statement-breakpoint+CREATE TABLE `users` (+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,+ `name` text NOT NULL,+ `email` text NOT NULL,+ `password` text,+ `avatar` text,+ `created_at` integer NOT NULL,+ `is_admin` integer DEFAULT 0 NOT NULL+);+--> statement-breakpoint+CREATE UNIQUE INDEX `users_name_unique` ON `users` (`name`);--> statement-breakpoint+CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);++--> statement-breakpoint+INSERT INTO users (name, email, password, avatar, created_at, is_admin) VALUES+ ('HoshinoSuzumi', '[email protected]', '$scrypt$n=16384,r=8,p=1$QaLKQI/LB+Kh7jgyeH4lGw$NuoxPwPvDZGK3F9oTNEgUNMAi24z/Wei6hWnJzNdscwKDHpQQVJfL1BlcNC+gHJtdJn4YsmQ9tWbVOCE4RgL1g', NULL, strftime('%s', 'now'), 1);\ No newline at end of filediff --git a/server/database/migrations/0000_rainy_christian_walker.sql b/server/database/migrations/0000_rainy_christian_walker.sqldeleted file mode 100644index 7f6c5bee..00000000--- a/server/database/migrations/0000_rainy_christian_walker.sql+++ /dev/null@@ -1,11 +0,0 @@-CREATE TABLE `users` (- `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,- `name` text NOT NULL,- `email` text NOT NULL,- `password` text NOT NULL,- `avatar` text,- `created_at` integer NOT NULL-);---> statement-breakpoint-CREATE UNIQUE INDEX `users_name_unique` ON `users` (`name`);--> statement-breakpoint-CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);\ No newline at end of filediff --git a/server/database/migrations/0001_quick_marvel_apes.sql b/server/database/migrations/0001_quick_marvel_apes.sqldeleted file mode 100644index b63284b5..00000000--- a/server/database/migrations/0001_quick_marvel_apes.sql+++ /dev/null@@ -1,17 +0,0 @@-PRAGMA foreign_keys=OFF;--> statement-breakpoint-CREATE TABLE `__new_users` (- `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,- `name` text NOT NULL,- `email` text NOT NULL,- `password` text,- `avatar` text,- `created_at` integer NOT NULL,- `is_admin` integer DEFAULT 0 NOT NULL-);---> statement-breakpoint-INSERT INTO `__new_users`("id", "name", "email", "password", "avatar", "created_at", "is_admin") SELECT "id", "name", "email", "password", "avatar", "created_at", "is_admin" FROM `users`;--> statement-breakpoint-DROP TABLE `users`;--> statement-breakpoint-ALTER TABLE `__new_users` RENAME TO `users`;--> statement-breakpoint-PRAGMA foreign_keys=ON;--> statement-breakpoint-CREATE UNIQUE INDEX `users_name_unique` ON `users` (`name`);--> statement-breakpoint-CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);\ No newline at end of filediff --git a/server/database/migrations/0002_insert-default-user.sql b/server/database/migrations/0002_insert-default-user.sqldeleted file mode 100644index d282d01e..00000000--- a/server/database/migrations/0002_insert-default-user.sql+++ /dev/null@@ -1,3 +0,0 @@--- Migration number: 0001 2025-08-23T16:09:27.764Z-INSERT INTO users (name, email, password, avatar, created_at, is_admin) VALUES- ('HoshinoSuzumi', '[email protected]', '$scrypt$n=16384,r=8,p=1$QaLKQI/LB+Kh7jgyeH4lGw$NuoxPwPvDZGK3F9oTNEgUNMAi24z/Wei6hWnJzNdscwKDHpQQVJfL1BlcNC+gHJtdJn4YsmQ9tWbVOCE4RgL1g', NULL, strftime('%s', 'now'), 1);\ No newline at end of filediff --git a/server/database/migrations/0002_odd_leopardon.sql b/server/database/migrations/0002_odd_leopardon.sqldeleted file mode 100644index d58887de..00000000--- a/server/database/migrations/0002_odd_leopardon.sql+++ /dev/null@@ -1,18 +0,0 @@-CREATE TABLE `photos` (- `id` text PRIMARY KEY NOT NULL,- `title` text,- `description` text,- `width` integer,- `height` integer,- `aspect_ratio` text,- `date_taken` integer,- `storage_key` text,- `file_size` integer,- `last_modified` integer,- `original_url` text,- `thumbnail_url` text,- `thumbnail_hash` text,- `tags` text-);---> statement-breakpoint-CREATE UNIQUE INDEX `photos_id_unique` ON `photos` (`id`);\ No newline at end of filediff --git a/server/database/migrations/0003_bitter_mojo.sql b/server/database/migrations/0003_bitter_mojo.sqldeleted file mode 100644index 338a4131..00000000--- a/server/database/migrations/0003_bitter_mojo.sql+++ /dev/null@@ -1,24 +0,0 @@-PRAGMA foreign_keys=OFF;--> statement-breakpoint-CREATE TABLE `__new_photos` (- `id` text PRIMARY KEY NOT NULL,- `title` text,- `description` text,- `width` integer,- `height` integer,- `aspect_ratio` integer,- `date_taken` integer,- `storage_key` text,- `file_size` integer,- `last_modified` text,- `original_url` text,- `thumbnail_url` text,- `thumbnail_hash` text,- `tags` text,- `exif` text-);---> statement-breakpoint-INSERT INTO `__new_photos`("id", "title", "description", "width", "height", "aspect_ratio", "date_taken", "storage_key", "file_size", "last_modified", "original_url", "thumbnail_url", "thumbnail_hash", "tags", "exif") SELECT "id", "title", "description", "width", "height", "aspect_ratio", "date_taken", "storage_key", "file_size", "last_modified", "original_url", "thumbnail_url", "thumbnail_hash", "tags", "exif" FROM `photos`;--> statement-breakpoint-DROP TABLE `photos`;--> statement-breakpoint-ALTER TABLE `__new_photos` RENAME TO `photos`;--> statement-breakpoint-PRAGMA foreign_keys=ON;--> statement-breakpoint-CREATE UNIQUE INDEX `photos_id_unique` ON `photos` (`id`);\ No newline at end of filediff --git a/server/database/migrations/0004_tense_talisman.sql b/server/database/migrations/0004_tense_talisman.sqldeleted file mode 100644index 8ca0f479..00000000--- a/server/database/migrations/0004_tense_talisman.sql+++ /dev/null@@ -1,24 +0,0 @@-PRAGMA foreign_keys=OFF;--> statement-breakpoint-CREATE TABLE `__new_photos` (- `id` text PRIMARY KEY NOT NULL,- `title` text,- `description` text,- `width` integer,- `height` integer,- `aspect_ratio` integer,- `date_taken` text,- `storage_key` text,- `file_size` integer,- `last_modified` text,- `original_url` text,- `thumbnail_url` text,- `thumbnail_hash` text,- `tags` text,- `exif` text-);---> statement-breakpoint-INSERT INTO `__new_photos`("id", "title", "description", "width", "height", "aspect_ratio", "date_taken", "storage_key", "file_size", "last_modified", "original_url", "thumbnail_url", "thumbnail_hash", "tags", "exif") SELECT "id", "title", "description", "width", "height", "aspect_ratio", "date_taken", "storage_key", "file_size", "last_modified", "original_url", "thumbnail_url", "thumbnail_hash", "tags", "exif" FROM `photos`;--> statement-breakpoint-DROP TABLE `photos`;--> statement-breakpoint-ALTER TABLE `__new_photos` RENAME TO `photos`;--> statement-breakpoint-PRAGMA foreign_keys=ON;--> statement-breakpoint-CREATE UNIQUE INDEX `photos_id_unique` ON `photos` (`id`);\ No newline at end of filediff --git a/server/database/migrations/meta/0000_snapshot.json b/server/database/migrations/meta/0000_snapshot.jsonindex 85b52a7a..59df546d 100644--- a/server/database/migrations/meta/0000_snapshot.json+++ b/server/database/migrations/meta/0000_snapshot.json@@ -1,9 +1,132 @@{"version": "6","dialect": "sqlite",- "id": "f066db51-c83d-45cd-998f-2096d4df8b12",+ "id": "5783985a-a690-46a1-941f-c7174b99bd62","prevId": "00000000-0000-0000-0000-000000000000","tables": {+ "photos": {+ "name": "photos",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "aspect_ratio": {+ "name": "aspect_ratio",+ "type": "real",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "date_taken": {+ "name": "date_taken",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "storage_key": {+ "name": "storage_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "file_size": {+ "name": "file_size",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "last_modified": {+ "name": "last_modified",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "original_url": {+ "name": "original_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "thumbnail_url": {+ "name": "thumbnail_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "thumbnail_hash": {+ "name": "thumbnail_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "tags": {+ "name": "tags",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "exif": {+ "name": "exif",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "photos_id_unique": {+ "name": "photos_id_unique",+ "columns": [+ "id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },"users": {"name": "users","columns": {@@ -32,7 +155,7 @@"name": "password","type": "text","primaryKey": false,- "notNull": true,+ "notNull": false,"autoincrement": false},"avatar": {@@ -48,6 +171,14 @@"primaryKey": false,"notNull": true,"autoincrement": false+ },+ "is_admin": {+ "name": "is_admin",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0}},"indexes": {diff --git a/server/database/migrations/meta/0001_snapshot.json b/server/database/migrations/meta/0001_snapshot.jsondeleted file mode 100644index d40ec7f0..00000000--- a/server/database/migrations/meta/0001_snapshot.json+++ /dev/null@@ -1,93 +0,0 @@-{- "version": "6",- "dialect": "sqlite",- "id": "374841f0-3d8d-4f77-8da2-128bae5c8e7a",- "prevId": "f066db51-c83d-45cd-998f-2096d4df8b12",- "tables": {- "users": {- "name": "users",- "columns": {- "id": {- "name": "id",- "type": "integer",- "primaryKey": true,- "notNull": true,- "autoincrement": true- },- "name": {- "name": "name",- "type": "text",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "email": {- "name": "email",- "type": "text",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "password": {- "name": "password",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "avatar": {- "name": "avatar",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "created_at": {- "name": "created_at",- "type": "integer",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "is_admin": {- "name": "is_admin",- "type": "integer",- "primaryKey": false,- "notNull": true,- "autoincrement": false,- "default": 0- }- },- "indexes": {- "users_name_unique": {- "name": "users_name_unique",- "columns": [- "name"- ],- "isUnique": true- },- "users_email_unique": {- "name": "users_email_unique",- "columns": [- "email"- ],- "isUnique": true- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "checkConstraints": {}- }- },- "views": {},- "enums": {},- "_meta": {- "schemas": {},- "tables": {},- "columns": {}- },- "internal": {- "indexes": {}- }-}\ No newline at end of filediff --git a/server/database/migrations/meta/0002_snapshot.json b/server/database/migrations/meta/0002_snapshot.jsondeleted file mode 100644index da532a46..00000000--- a/server/database/migrations/meta/0002_snapshot.json+++ /dev/null@@ -1,209 +0,0 @@-{- "version": "6",- "dialect": "sqlite",- "id": "ef70286b-d2e3-47df-91a9-b3d0782b23dc",- "prevId": "374841f0-3d8d-4f77-8da2-128bae5c8e7a",- "tables": {- "photos": {- "name": "photos",- "columns": {- "id": {- "name": "id",- "type": "text",- "primaryKey": true,- "notNull": true,- "autoincrement": false- },- "title": {- "name": "title",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "description": {- "name": "description",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "width": {- "name": "width",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "height": {- "name": "height",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "aspect_ratio": {- "name": "aspect_ratio",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "date_taken": {- "name": "date_taken",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "storage_key": {- "name": "storage_key",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "file_size": {- "name": "file_size",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "last_modified": {- "name": "last_modified",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "original_url": {- "name": "original_url",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "thumbnail_url": {- "name": "thumbnail_url",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "thumbnail_hash": {- "name": "thumbnail_hash",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "tags": {- "name": "tags",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- }- },- "indexes": {- "photos_id_unique": {- "name": "photos_id_unique",- "columns": [- "id"- ],- "isUnique": true- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "checkConstraints": {}- },- "users": {- "name": "users",- "columns": {- "id": {- "name": "id",- "type": "integer",- "primaryKey": true,- "notNull": true,- "autoincrement": true- },- "name": {- "name": "name",- "type": "text",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "email": {- "name": "email",- "type": "text",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "password": {- "name": "password",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "avatar": {- "name": "avatar",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "created_at": {- "name": "created_at",- "type": "integer",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "is_admin": {- "name": "is_admin",- "type": "integer",- "primaryKey": false,- "notNull": true,- "autoincrement": false,- "default": 0- }- },- "indexes": {- "users_name_unique": {- "name": "users_name_unique",- "columns": [- "name"- ],- "isUnique": true- },- "users_email_unique": {- "name": "users_email_unique",- "columns": [- "email"- ],- "isUnique": true- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "checkConstraints": {}- }- },- "views": {},- "enums": {},- "_meta": {- "schemas": {},- "tables": {},- "columns": {}- },- "internal": {- "indexes": {}- }-}\ No newline at end of filediff --git a/server/database/migrations/meta/0003_snapshot.json b/server/database/migrations/meta/0003_snapshot.jsondeleted file mode 100644index 98cb78af..00000000--- a/server/database/migrations/meta/0003_snapshot.json+++ /dev/null@@ -1,216 +0,0 @@-{- "version": "6",- "dialect": "sqlite",- "id": "288febb4-b648-40c9-9bc0-a1ba1899cff3",- "prevId": "ef70286b-d2e3-47df-91a9-b3d0782b23dc",- "tables": {- "photos": {- "name": "photos",- "columns": {- "id": {- "name": "id",- "type": "text",- "primaryKey": true,- "notNull": true,- "autoincrement": false- },- "title": {- "name": "title",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "description": {- "name": "description",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "width": {- "name": "width",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "height": {- "name": "height",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "aspect_ratio": {- "name": "aspect_ratio",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "date_taken": {- "name": "date_taken",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "storage_key": {- "name": "storage_key",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "file_size": {- "name": "file_size",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "last_modified": {- "name": "last_modified",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "original_url": {- "name": "original_url",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "thumbnail_url": {- "name": "thumbnail_url",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "thumbnail_hash": {- "name": "thumbnail_hash",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "tags": {- "name": "tags",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "exif": {- "name": "exif",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- }- },- "indexes": {- "photos_id_unique": {- "name": "photos_id_unique",- "columns": [- "id"- ],- "isUnique": true- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "checkConstraints": {}- },- "users": {- "name": "users",- "columns": {- "id": {- "name": "id",- "type": "integer",- "primaryKey": true,- "notNull": true,- "autoincrement": true- },- "name": {- "name": "name",- "type": "text",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "email": {- "name": "email",- "type": "text",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "password": {- "name": "password",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "avatar": {- "name": "avatar",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "created_at": {- "name": "created_at",- "type": "integer",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "is_admin": {- "name": "is_admin",- "type": "integer",- "primaryKey": false,- "notNull": true,- "autoincrement": false,- "default": 0- }- },- "indexes": {- "users_name_unique": {- "name": "users_name_unique",- "columns": [- "name"- ],- "isUnique": true- },- "users_email_unique": {- "name": "users_email_unique",- "columns": [- "email"- ],- "isUnique": true- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "checkConstraints": {}- }- },- "views": {},- "enums": {},- "_meta": {- "schemas": {},- "tables": {},- "columns": {}- },- "internal": {- "indexes": {}- }-}\ No newline at end of filediff --git a/server/database/migrations/meta/0004_snapshot.json b/server/database/migrations/meta/0004_snapshot.jsondeleted file mode 100644index 43fc4b2d..00000000--- a/server/database/migrations/meta/0004_snapshot.json+++ /dev/null@@ -1,216 +0,0 @@-{- "version": "6",- "dialect": "sqlite",- "id": "a12f4189-0459-4b83-8fd1-1b8f48062801",- "prevId": "288febb4-b648-40c9-9bc0-a1ba1899cff3",- "tables": {- "photos": {- "name": "photos",- "columns": {- "id": {- "name": "id",- "type": "text",- "primaryKey": true,- "notNull": true,- "autoincrement": false- },- "title": {- "name": "title",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "description": {- "name": "description",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "width": {- "name": "width",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "height": {- "name": "height",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "aspect_ratio": {- "name": "aspect_ratio",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "date_taken": {- "name": "date_taken",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "storage_key": {- "name": "storage_key",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "file_size": {- "name": "file_size",- "type": "integer",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "last_modified": {- "name": "last_modified",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "original_url": {- "name": "original_url",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "thumbnail_url": {- "name": "thumbnail_url",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "thumbnail_hash": {- "name": "thumbnail_hash",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "tags": {- "name": "tags",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "exif": {- "name": "exif",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- }- },- "indexes": {- "photos_id_unique": {- "name": "photos_id_unique",- "columns": [- "id"- ],- "isUnique": true- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "checkConstraints": {}- },- "users": {- "name": "users",- "columns": {- "id": {- "name": "id",- "type": "integer",- "primaryKey": true,- "notNull": true,- "autoincrement": true- },- "name": {- "name": "name",- "type": "text",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "email": {- "name": "email",- "type": "text",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "password": {- "name": "password",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "avatar": {- "name": "avatar",- "type": "text",- "primaryKey": false,- "notNull": false,- "autoincrement": false- },- "created_at": {- "name": "created_at",- "type": "integer",- "primaryKey": false,- "notNull": true,- "autoincrement": false- },- "is_admin": {- "name": "is_admin",- "type": "integer",- "primaryKey": false,- "notNull": true,- "autoincrement": false,- "default": 0- }- },- "indexes": {- "users_name_unique": {- "name": "users_name_unique",- "columns": [- "name"- ],- "isUnique": true- },- "users_email_unique": {- "name": "users_email_unique",- "columns": [- "email"- ],- "isUnique": true- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "checkConstraints": {}- }- },- "views": {},- "enums": {},- "_meta": {- "schemas": {},- "tables": {},- "columns": {}- },- "internal": {- "indexes": {}- }-}\ No newline at end of filediff --git a/server/database/migrations/meta/_journal.json b/server/database/migrations/meta/_journal.jsonindex 70c682e0..89812612 100644--- a/server/database/migrations/meta/_journal.json+++ b/server/database/migrations/meta/_journal.json@@ -5,36 +5,8 @@{"idx": 0,"version": "6",- "when": 1755964755120,- "tag": "0000_rainy_christian_walker",- "breakpoints": true- },- {- "idx": 1,- "version": "6",- "when": 1755965654193,- "tag": "0001_quick_marvel_apes",- "breakpoints": true- },- {- "idx": 2,- "version": "6",- "when": 1756098771860,- "tag": "0002_odd_leopardon",- "breakpoints": true- },- {- "idx": 3,- "version": "6",- "when": 1756108852801,- "tag": "0003_bitter_mojo",- "breakpoints": true- },- {- "idx": 4,- "version": "6",- "when": 1756109583459,- "tag": "0004_tense_talisman",+ "when": 1756139400238,+ "tag": "0000_curvy_scarlet_witch","breakpoints": true}]diff --git a/server/database/schema.ts b/server/database/schema.tsindex 1156a0c4..37d9a00d 100644--- a/server/database/schema.ts+++ b/server/database/schema.ts@@ -1,4 +1,4 @@-import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'+import { sqliteTable, text, integer, real } from 'drizzle-orm/sqlite-core'import { NeededExif } from '~~/shared/types/photo'export const users = sqliteTable('users', {@@ -14,10 +14,10 @@ export const users = sqliteTable('users', {export const photos = sqliteTable('photos', {id: text('id').primaryKey().unique(),title: text('title'),- description: text(),+ description: text('description'),width: integer('width'),height: integer('height'),- aspectRatio: integer('aspect_ratio'),+ aspectRatio: real('aspect_ratio'),dateTaken: text('date_taken'),storageKey: text('storage_key'),fileSize: integer('file_size'),diff --git a/server/plugins/storage.ts b/server/plugins/storage.tsindex 01f56f9e..447b6fd1 100644--- a/server/plugins/storage.ts+++ b/server/plugins/storage.ts@@ -36,7 +36,7 @@ export default nitroPlugin(async (nitroApp) => {},}- const storageManager = new StorageManager(devConfigs.r2, logger.storage)+ const storageManager = new StorageManager(devConfigs.s3, logger.storage)// 设置全局实例globalStorageManager = storageManagerdiff --git a/server/services/image/exif.ts b/server/services/image/exif.tsindex 11c4c16d..7cf0b5d9 100644--- a/server/services/image/exif.ts+++ b/server/services/image/exif.ts@@ -1,10 +1,17 @@-import path from 'path'+import path from 'node:path'+import { mkdir, unlink, writeFile } from 'node:fs/promises'import sharp, { Metadata } from 'sharp'import type { NeededExif, PhotoInfo } from '../../../shared/types/photo'import exifr from 'exifr'-import { ExifDateTime, Tags } from 'exiftool-vendored'+import { exiftool, ExifDateTime, Tags } from 'exiftool-vendored'+import { noop } from 'es-toolkit'+import { Logger } from '~~/server/utils/logger'const neededKeys: Array<keyof Tags | (string & {})> = [+ 'Title',+ 'Subject',+ 'Keywords',+'tz','tzSource','Orientation',@@ -111,29 +118,41 @@ const processExifData = (exifData: Tags, metadata: Metadata): NeededExif => {export const extractExifData = async (imageBuffer: Buffer,rawImageBuffer?: Buffer,+ logger?: Logger['image'],): Promise<NeededExif | null> => {try {let metadata = await sharp(imageBuffer).metadata()- if (!metadata && rawImageBuffer) {+ if (!metadata.exif && rawImageBuffer) {try {metadata = await sharp(rawImageBuffer).metadata()} catch (err) {- logger.image.warn(- 'Error extracting EXIF data from raw image buffer:',- err,- )+ logger?.warn('Error extracting EXIF data from raw image buffer:', err)}}if (!metadata.exif) {+ logger?.warn('No EXIF data found in image metadata')return null}- const exifData = await exifr.parse(imageBuffer, true)- return processExifData(exifData, metadata)+ // const exifData = await exifr.parse(rawImageBuffer || imageBuffer, true)+ // return processExifData(exifData, metadata)++ logger?.info('Extracting EXIF data using exiftool...')++ const tempDir = path.resolve(process.cwd(), 'exif_workdir')+ await mkdir(tempDir, { recursive: true })+ const tempImagePath = path.resolve(tempDir, `${crypto.randomUUID()}.jpg`)++ await writeFile(tempImagePath, rawImageBuffer || imageBuffer)+ const exifData = await exiftool.read(tempImagePath)+ const result = processExifData(exifData, metadata)++ await unlink(tempImagePath).catch(noop)+ return result} catch (err) {- logger.image.error('EXIF extraction failed:', err)+ logger?.error('EXIF extraction failed:', err)return null}}@@ -150,7 +169,9 @@ export const extractPhotoInfo = (let tags: string[] = []const dirPath = path.dirname(s3key)- if (dirPath && dirPath !== '.' && dirPath !== '/') {+ if (exifData?.Subject || exifData?.Keywords) {+ tags = [...(exifData.Subject || []), ...(exifData.Keywords || [])]+ } else if (dirPath && dirPath !== '.' && dirPath !== '/') {let relativePath = dirPathrelativePath = dirPath.slice('/photos'.length)@@ -189,11 +210,13 @@ export const extractPhotoInfo = (views = Number.parseInt(viewsMatch[1])}- title = fileName- .replaceAll(/\d{4}-\d{2}-\d{2}[_-]?/g, '')- .replaceAll(/[_-]?\d+views?/gi, '')- .replaceAll(/[_-]+/g, ' ')- .trim()+ title =+ exifData?.Title ||+ fileName+ .replaceAll(/\d{4}-\d{2}-\d{2}[_-]?/g, '')+ .replaceAll(/[_-]?\d+views?/gi, '')+ .replaceAll(/[_-]+/g, ' ')+ .trim()if (!title) {title = path.basename(s3key, path.extname(s3key))diff --git a/server/services/image/processor.ts b/server/services/image/processor.tsindex 612fed55..3c87beb3 100644--- a/server/services/image/processor.ts+++ b/server/services/image/processor.ts@@ -54,7 +54,8 @@ export const convertHeicToJpeg = async (heicBuffer: Buffer) => {logger.image.info('Converting HEIC to JPEG...')const jpegBuffer = await heicConvert({- buffer: heicBuffer.buffer,+ // @ts-expect-error idk why there is a type error here+ buffer: heicBuffer,format: 'JPEG',quality: 0.95,})diff --git a/server/services/photo/pipeline-async.ts b/server/services/photo/pipeline-async.tsnew file mode 100644index 00000000..52e72ed0--- /dev/null+++ b/server/services/photo/pipeline-async.ts@@ -0,0 +1,192 @@+import path from 'path'+import {+ preprocessImage,+ processImageMetadataAndSharp,+} from '../image/processor'+import { generateThumbnailAndHash } from '../image/thumbnail'+import { Photo } from '~~/server/utils/db'+import { getStorageManager } from '~~/server/plugins/storage'+import { compressUint8Array } from '~~/shared/utils/u8array'+import { StorageObject } from '../storage'+import { extractExifData, extractPhotoInfo } from '../image/exif'++const generatePhotoId = (s3key: string) => {+ return path.basename(s3key, path.extname(s3key))+}++/**+ * 异步执行照片处理管道 - 不阻塞主线程+ */+export const execPhotoPipelineAsync = async (+ s3key: string,+ storageObject: StorageObject,+): Promise<Photo | null> => {+ return new Promise((resolve, reject) => {+ // 使用 setImmediate 确保处理在下一个事件循环中执行+ setImmediate(async () => {+ try {+ const result = await processPhotoInternal(s3key, storageObject)+ resolve(result)+ } catch (error) {+ reject(error)+ }+ })+ })+}++/**+ * 内部照片处理函数+ */+async function processPhotoInternal(+ s3key: string,+ storageObject: StorageObject,+): Promise<Photo | null> {+ const log = logger.image+ const storageProvider = getStorageManager().getProvider()+ const photoId = generatePhotoId(s3key)++ try {+ log.info(`Starting async processing for ${s3key}`)++ // 使用 Promise 包装每个步骤,确保异步执行+ const imageBuffers = await new Promise<any>((resolve, reject) => {+ setImmediate(async () => {+ try {+ const result = await preprocessImage(s3key)+ resolve(result)+ } catch (error) {+ reject(error)+ }+ })+ })++ if (!imageBuffers) {+ log.error(`Image preprocessing failed for ${s3key}`)+ return null+ }++ const processedData = await new Promise<any>((resolve, reject) => {+ setImmediate(async () => {+ try {+ const result = await processImageMetadataAndSharp(+ imageBuffers.processed,+ s3key,+ )+ resolve(result)+ } catch (error) {+ reject(error)+ }+ })+ })++ if (!processedData) {+ log.error(`Image processing failed for ${s3key}`)+ return null+ }++ const { sharpInst, imageBuffer, metadata } = processedData++ const { thumbnailBuffer, thumbnailHash } = await new Promise<any>((resolve, reject) => {+ setImmediate(async () => {+ try {+ const result = await generateThumbnailAndHash(imageBuffer)+ resolve(result)+ } catch (error) {+ reject(error)+ }+ })+ })++ const exifData = await new Promise<any>((resolve, reject) => {+ setImmediate(async () => {+ try {+ const result = await extractExifData(imageBuffer, imageBuffers.raw, log)+ resolve(result)+ } catch (error) {+ reject(error)+ }+ })+ })++ const photoInfo = extractPhotoInfo(s3key, exifData)++ const thumbnailObject = await new Promise<any>((resolve, reject) => {+ setImmediate(async () => {+ try {+ const result = await storageProvider.create(+ `thumbnails/${photoId}.webp`,+ thumbnailBuffer,+ 'image/webp'+ )+ resolve(result)+ } catch (error) {+ reject(error)+ }+ })+ })++ const result: Photo = {+ id: photoId,+ title: photoInfo.title,+ description: photoInfo.description,+ dateTaken: photoInfo.dateTaken,+ tags: photoInfo.tags,+ width: metadata.width,+ height: metadata.height,+ aspectRatio: metadata.width / metadata.height,+ storageKey: s3key,+ fileSize: storageObject.size || null,+ lastModified:+ storageObject.lastModified?.toISOString() || new Date().toISOString(),+ originalUrl: storageProvider.getPublicUrl(s3key),+ thumbnailUrl: storageProvider.getPublicUrl(thumbnailObject.key),+ thumbnailHash: thumbnailHash ? compressUint8Array(thumbnailHash) : null,+ exif: exifData,+ }++ log.info(`Async processing completed for ${s3key}`)+ return result++ } catch (err) {+ log.error(`Photo pipeline failed for ${s3key}`, err)+ return null+ }+}++/**+ * 批量异步处理照片+ */+export const execBatchPhotoPipelineAsync = async (+ photos: Array<{ s3key: string; storageObject: StorageObject }>,+ maxConcurrent = 3+): Promise<Array<{ s3key: string; photo: Photo | null; error?: string }>> => {+ const results: Array<{ s3key: string; photo: Photo | null; error?: string }> = []++ // 分批处理以限制并发数+ for (let i = 0; i < photos.length; i += maxConcurrent) {+ const batch = photos.slice(i, i + maxConcurrent)+ const batchPromises = batch.map(async ({ s3key, storageObject }) => {+ try {+ const photo = await execPhotoPipelineAsync(s3key, storageObject)+ return {+ s3key,+ photo,+ error: photo ? undefined : 'Processing failed'+ }+ } catch (error) {+ return {+ s3key,+ photo: null,+ error: error instanceof Error ? error.message : String(error)+ }+ }+ })++ const batchResults = await Promise.all(batchPromises)+ results.push(...batchResults)++ logger.image.info(`Processed async batch ${Math.floor(i / maxConcurrent) + 1} of ${Math.ceil(photos.length / maxConcurrent)}`)+ }++ return results+}diff --git a/server/services/photo/pipeline.ts b/server/services/photo/pipeline.tsindex be51b0da..e46e5612 100644--- a/server/services/photo/pipeline.ts+++ b/server/services/photo/pipeline.ts@@ -6,7 +6,7 @@ import {import { generateThumbnailAndHash } from '../image/thumbnail'import { Photo } from '~~/server/utils/db'import { getStorageManager } from '~~/server/plugins/storage'-import { compressUint8Array } from '~~/server/utils/u8array'+import { compressUint8Array } from '~~/shared/utils/u8array'import { StorageObject } from '../storage'import { extractExifData, extractPhotoInfo } from '../image/exif'@@ -40,15 +40,16 @@ export const execPhotoPipeline = async (await generateThumbnailAndHash(imageBuffer)// 4. EXIF- const exifData = await extractExifData(imageBuffer, imageBuffers.raw)+ const exifData = await extractExifData(imageBuffer, imageBuffers.raw, log)// 5. 提取照片信息const photoInfo = extractPhotoInfo(s3key, exifData)// 6. 上传缩略图const thumbnailObject = await storageProvider.create(- `thumbnails/${photoId}`,+ `thumbnails/${photoId}.webp`,thumbnailBuffer,+ 'image/webp')return {diff --git a/server/services/storage/interfaces.ts b/server/services/storage/interfaces.tsindex 417eb4d3..cd4ea789 100644--- a/server/services/storage/interfaces.ts+++ b/server/services/storage/interfaces.ts@@ -43,7 +43,11 @@ export interface UploadOptions {}export interface StorageProvider {- create(key: string, fileBuffer: Buffer): Promise<StorageObject>+ create(+ key: string,+ fileBuffer: Buffer,+ contentType?: string,+ ): Promise<StorageObject>delete(key: string): Promise<void>get(key: string): Promise<Buffer | null>getPublicUrl(key: string): stringdiff --git a/server/services/storage/providers/hub-r2.ts b/server/services/storage/providers/hub-r2.tsindex 6550e422..4de035e0 100644--- a/server/services/storage/providers/hub-r2.ts+++ b/server/services/storage/providers/hub-r2.ts@@ -23,7 +23,11 @@ export class HubR2StorageProvider implements StorageProvider {this.logger = logger}- async create(key: string, fileBuffer: Buffer): Promise<StorageObject> {+ async create(+ key: string,+ fileBuffer: Buffer,+ contentType?: string,+ ): Promise<StorageObject> {const file = new File([new Uint8Array(fileBuffer)], key)if (!file || !file.size) {diff --git a/server/services/storage/providers/s3.ts b/server/services/storage/providers/s3.tsindex 875e1052..2040efe8 100644--- a/server/services/storage/providers/s3.ts+++ b/server/services/storage/providers/s3.ts@@ -1,7 +1,9 @@import {_Object,+ DeleteObjectCommand,GetObjectCommand,ListObjectsCommand,+ PutObjectCommand,S3Client,S3ClientConfig,} from '@aws-sdk/client-s3'@@ -56,12 +58,44 @@ export class S3StorageProvider implements StorageProvider {this.client = createClient(config)}- create(key: string, data: Buffer): Promise<StorageObject> {- throw new Error('Method not implemented.')+ async create(key: string, data: Buffer, contentType?: string): Promise<StorageObject> {+ try {+ const cmd = new PutObjectCommand({+ Bucket: this.config.bucket,+ Key: key,+ Body: data,+ ContentType: contentType || 'application/octet-stream',+ })++ const resp = await this.client.send(cmd)++ this.logger?.success(`Created object with key: ${key}`)++ return {+ key,+ size: data.length,+ lastModified: new Date(),+ etag: resp.ETag,+ }+ } catch (error) {+ this.logger?.error(`Failed to create object with key: ${key}`, error)+ throw error+ }}- delete(key: string): Promise<void> {- throw new Error('Method not implemented.')+ async delete(key: string): Promise<void> {+ try {+ const cmd = new DeleteObjectCommand({+ Bucket: this.config.bucket,+ Key: key,+ })++ await this.client.send(cmd)+ this.logger?.success(`Deleted object with key: ${key}`)+ } catch (error) {+ this.logger?.error(`Failed to delete object with key: ${key}`, error)+ throw error+ }}async get(key: string): Promise<Buffer | null> {@@ -123,7 +157,9 @@ export class S3StorageProvider implements StorageProvider {expiresIn?: number,options?: UploadOptions,): Promise<{ url: string }> {- throw new Error('Method not implemented.')+ // TODO: Implement presigned URL generation+ // This requires @aws-sdk/s3-request-presigner package+ throw new Error('Presigned upload URL generation not implemented. Please install @aws-sdk/s3-request-presigner and implement this method.')}async listAll(): Promise<StorageObject[]> {diff --git a/server/utils/db.ts b/server/utils/db.tsindex 536e3b75..bcf40a65 100644--- a/server/utils/db.ts+++ b/server/utils/db.ts@@ -1,4 +1,6 @@-import { drizzle } from 'drizzle-orm/d1'+// import { drizzle } from 'drizzle-orm/d1'+import { drizzle } from 'drizzle-orm/better-sqlite3'+import Database from 'better-sqlite3'export { sql, eq, and, or } from 'drizzle-orm'import * as schema from '../database/schema'@@ -6,7 +8,9 @@ import * as schema from '../database/schema'export const tables = schemaexport function useDB() {- return drizzle(hubDatabase(), { schema })+ // return drizzle(hubDatabase(), { schema })+ const sqlite = new Database('.data/chronoframe.sqlite3')+ return drizzle(sqlite, { schema })}export type User = typeof schema.users.$inferSelectdiff --git a/shared/types/photo.ts b/shared/types/photo.tsindex 99bd94db..897fbea4 100644--- a/shared/types/photo.ts+++ b/shared/types/photo.ts@@ -1,6 +1,10 @@import type { Tags } from 'exiftool-vendored'export interface NeededExif {+ Title?: string+ Subject?: string[]+ Keywords?: string[]+zone?: stringtz?: stringtzSource?: stringdiff --git a/server/utils/u8array.ts b/shared/utils/u8array.tssimilarity index 100%rename from server/utils/u8array.tsrename to shared/utils/u8array.ts