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
chore: 删除不再使用的页面,调整日志输出
Timothy Yin8a591e5b3a08
diff --git a/app/pages/webgl/demo.vue b/app/pages/webgl/demo.vuedeleted file mode 100644index 62869f7e..00000000--- a/app/pages/webgl/demo.vue+++ /dev/null@@ -1,236 +0,0 @@-<script setup lang="ts">-import { ref } from 'vue'-import { WebGLImageViewer } from '@chronoframe/webgl-image'-import type { LoadingState, WebGLImageViewerRef } from '@chronoframe/webgl-image'--// 响应式数据-const debugMode = ref(true)-const controlledViewerRef = ref<WebGLImageViewerRef>()--// 事件处理-const handleZoomChange = (originalScale: number, relativeScale: number) => {- console.log('Zoom changed:', { originalScale, relativeScale })-}--// 控制方法-const zoomIn = () => {- controlledViewerRef.value?.zoomIn(true)-}--const zoomOut = () => {- controlledViewerRef.value?.zoomOut(true)-}--const resetView = () => {- controlledViewerRef.value?.resetView()-}--const handleLoadingStateChange = (- isLoading: boolean,- state: LoadingState | undefined,- quality: "high" | "medium" | "low" | "unknown" | undefined,-): void => {- console.log('Loading state changed:', { isLoading, state, quality })-}-</script>--<template>- <div class="webgl-demo-page">- <div class="container">- <h1>WebGL Image Viewer Demo</h1>-- <div class="demo-section">- <h2>基础示例</h2>- <div class="viewer-wrapper">- <WebGLImageViewer- src="https://cdn.lens.bh8.ga/photos/General%203840x2160%20nature%20landscape%20trees%20plants%20mountains%20snowy%20p.png"- class="demo-viewer"- :debug="debugMode"- :initial-scale="1"- @zoom-change="handleZoomChange"- @loading-state-change="handleLoadingStateChange"- />- </div>- <div class="viewer-wrapper">- <WebGLImageViewer- src="https://cdn.lens.bh8.ga/photos/mmexport1724859755873.jpg"- class="demo-viewer"- :debug="debugMode"- :initial-scale="1"- :min-scale="1"- center-on-init- limit-to-bounds- smooth- @loading-state-change="handleLoadingStateChange"- @zoom-change="handleZoomChange"- />- </div>- </div>-- <div class="demo-section">- <h2>控制示例</h2>- <div class="viewer-wrapper">- <WebGLImageViewer- ref="controlledViewerRef"- src="https://cdn.lens.bh8.ga/photos/IMG_3354.jpeg"- class="demo-viewer"- debug- :min-scale="0.2"- :max-scale="15"- :wheel="{ step: 0.05 }"- :double-click="{ mode: 'zoom', step: 1.8, animationTime: 400 }"- @loading-state-change="handleLoadingStateChange"- />- </div>-- <div class="controls">- <button- class="control-btn"- @click="zoomIn"- >- 放大- </button>- <button- class="control-btn"- @click="zoomOut"- >- 缩小- </button>- <button- class="control-btn"- @click="resetView"- >- 重置- </button>- </div>- </div>- </div>- </div>-</template>--<style scoped>-.webgl-demo-page {- min-height: 100vh;- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);- padding: 20px;-}--.container {- max-width: 1200px;- margin: 0 auto;-}--h1 {- text-align: center;- color: white;- margin-bottom: 40px;- font-size: 2.5rem;- text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);-}--.demo-section {- background: white;- border-radius: 12px;- padding: 24px;- margin-bottom: 32px;- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);-}--.demo-section h2 {- color: #333;- margin-bottom: 20px;- font-size: 1.5rem;- border-bottom: 2px solid #667eea;- padding-bottom: 8px;-}--.viewer-wrapper {- width: 100%;- height: 800px;- border: 2px solid #e0e0e0;- border-radius: 8px;- overflow: hidden;- margin-bottom: 16px;- background: #f8f9fa;-}--.demo-viewer {- width: 100%;- height: 100%;-}--.controls {- display: flex;- align-items: center;- gap: 16px;- flex-wrap: wrap;-}--.controls label {- display: flex;- align-items: center;- gap: 8px;- font-size: 14px;- color: #555;-}--.control-btn {- padding: 10px 20px;- background: #667eea;- color: white;- border: none;- border-radius: 6px;- cursor: pointer;- font-size: 14px;- font-weight: 500;- transition: all 0.2s ease;-}--.control-btn:hover {- background: #5a67d8;- transform: translateY(-1px);-}--.control-btn:active {- transform: translateY(0);-}--.zoom-info {- font-weight: bold;- color: #667eea;- background: #f0f4ff;- padding: 6px 12px;- border-radius: 4px;- font-size: 14px;-}--/* 响应式设计 */-@media (max-width: 768px) {- .webgl-demo-page {- padding: 16px;- }-- h1 {- font-size: 2rem;- margin-bottom: 24px;- }-- .demo-section {- padding: 16px;- margin-bottom: 20px;- }-- .viewer-wrapper {- height: 300px;- }-- .controls {- flex-direction: column;- align-items: stretch;- }-- .control-btn {- width: 100%;- }-}-</style>diff --git a/app/pages/webgl/features.vue b/app/pages/webgl/features.vuedeleted file mode 100644index 23771d09..00000000--- a/app/pages/webgl/features.vue+++ /dev/null@@ -1,376 +0,0 @@-<script setup lang="ts">-import { ref, computed } from 'vue'-import { WebGLImageViewer } from '@chronoframe/webgl-image'--const imageUrl = ref('https://cdn.lens.bh8.ga/photos/mmexport1724859755873.jpg')--const useCustomSize = ref(false)-const customWidth = ref(600)-const customHeight = ref(400)--const config = ref({- debug: true,- limitToBounds: true,- smooth: true,- centerOnInit: true,- minScale: 0.1,- maxScale: 10,-})--const wheelConfig = computed(() => ({- step: 0.2,- wheelDisabled: false,- touchPadDisabled: false,-}))--const pinchConfig = computed(() => ({- step: 0.2,- disabled: false,-}))--const doubleClickConfig = computed(() => ({- step: 0.7,- disabled: false,- mode: 'toggle' as const,- animationTime: 300,-}))--const panningConfig = computed(() => ({- disabled: false,- velocityDisabled: false,-}))--const alignmentAnimationConfig = computed(() => ({- duration: 300,- easing: (t: number) => 1 - Math.pow(1 - t, 3),-}))--const velocityAnimationConfig = computed(() => ({- duration: 500,- easing: (t: number) => 1 - Math.pow(1 - t, 3),-}))--const viewerRef = ref()-const currentScale = ref(1)-const isLoading = ref(false)-const lastZoomChange = ref<{ original: number; relative: number } | null>(null)--const handleZoomIn = () => {- viewerRef.value?.zoomIn(false)-}--const handleZoomInAnimated = () => {- viewerRef.value?.zoomIn(true)-}--const handleZoomOut = () => {- viewerRef.value?.zoomOut(false)-}--const handleZoomOutAnimated = () => {- viewerRef.value?.zoomOut(true)-}--const handleReset = () => {- viewerRef.value?.resetView()-}--const handleZoomChange = (originalScale: number, relativeScale: number) => {- currentScale.value = originalScale- lastZoomChange.value = { original: originalScale, relative: relativeScale }-}--const handleImageCopied = () => {- console.log('图片已复制到剪贴板')-}--const handleLoadingStateChange = (loading: boolean) => {- isLoading.value = loading-}-</script>--<template>- <div class="demo-container">- <h1>WebGL Image Viewer - 完整功能测试</h1>-- <div class="controls">- <div class="control-group">- <label>图片URL:</label>- <input- v-model="imageUrl"- type="url"- placeholder="请输入图片URL"- class="url-input"- />- </div>-- <div class="control-group">- <label>尺寸控制:</label>- <div class="size-controls">- <label>- <input- v-model="useCustomSize"- type="checkbox"- />- 自定义尺寸- </label>- <template v-if="useCustomSize">- <input- v-model.number="customWidth"- type="number"- placeholder="宽度"- min="200"- max="1000"- />- x- <input- v-model.number="customHeight"- type="number"- placeholder="高度"- min="200"- max="800"- />- </template>- </div>- </div>-- <div class="control-group">- <label>配置选项:</label>- <div class="config-controls">- <label>- <input- v-model="config.debug"- type="checkbox"- />- 调试模式- </label>- <label>- <input- v-model="config.limitToBounds"- type="checkbox"- />- 限制边界- </label>- <label>- <input- v-model="config.smooth"- type="checkbox"- />- 平滑处理- </label>- <label>- <input- v-model="config.centerOnInit"- type="checkbox"- />- 初始居中- </label>- </div>- </div>-- <div class="control-group">- <label>缩放控制:</label>- <div class="scale-controls">- <input- v-model.number="config.minScale"- type="number"- step="0.1"- min="0.1"- max="1"- placeholder="最小缩放"- />- <span>到</span>- <input- v-model.number="config.maxScale"- type="number"- step="1"- min="1"- max="20"- placeholder="最大缩放"- />- </div>- </div>-- <div class="button-group">- <button- class="btn"- @click="handleZoomIn"- >- 放大 (无动画)- </button>- <button- class="btn"- @click="handleZoomInAnimated"- >- 放大 (动画)- </button>- <button- class="btn"- @click="handleZoomOut"- >- 缩小 (无动画)- </button>- <button- class="btn"- @click="handleZoomOutAnimated"- >- 缩小 (动画)- </button>- <button- class="btn"- @click="handleReset"- >- 重置- </button>- </div>- </div>-- <div class="viewer-container">- <WebGLImageViewer- ref="viewerRef"- :src="imageUrl"- :width="useCustomSize ? customWidth : undefined"- :height="useCustomSize ? customHeight : undefined"- :debug="config.debug"- :limit-to-bounds="config.limitToBounds"- :smooth="config.smooth"- :center-on-init="config.centerOnInit"- :min-scale="config.minScale"- :max-scale="config.maxScale"- :wheel="wheelConfig"- :pinch="pinchConfig"- :double-click="doubleClickConfig"- :panning="panningConfig"- :alignment-animation="alignmentAnimationConfig"- :velocity-animation="velocityAnimationConfig"- @zoom-change="handleZoomChange"- @image-copied="handleImageCopied"- @loading-state-change="handleLoadingStateChange"- />- </div>-- <div class="status">- <p>当前缩放: {{ currentScale.toFixed(2) }}</p>- <p>加载状态: {{ isLoading ? '加载中...' : '已加载' }}</p>- <p v-if="lastZoomChange">- 最后缩放变化: 原始={{ lastZoomChange.original.toFixed(2) }}, 相对={{- lastZoomChange.relative.toFixed(2)- }}- </p>- </div>- </div>-</template>--<style scoped>-.demo-container {- padding: 20px;- max-width: 1200px;- margin: 0 auto;-}--h1 {- text-align: center;- margin-bottom: 30px;-}--.controls {- background: #f5f5f5;- padding: 20px;- border-radius: 8px;- margin-bottom: 20px;- font-size: 11px;-}--.control-group {- margin-bottom: 15px;-}--.control-group label {- display: block;- font-weight: bold;- margin-bottom: 5px;-}--.url-input {- width: 100%;- padding: 8px;- border: 1px solid #ddd;- border-radius: 4px;-}--.size-controls,-.config-controls,-.scale-controls {- display: flex;- gap: 15px;- align-items: center;- flex-wrap: wrap;-}--.size-controls input[type='number'] {- width: 80px;- padding: 4px;- border: 1px solid #ddd;- border-radius: 4px;-}--.scale-controls input {- width: 100px;- padding: 4px;- border: 1px solid #ddd;- border-radius: 4px;-}--.config-controls label {- display: flex;- align-items: center;- gap: 5px;- font-weight: normal;- margin-bottom: 0;-}--.button-group {- display: flex;- gap: 10px;- flex-wrap: wrap;- margin-top: 15px;-}--.btn {- padding: 8px 16px;- background: #007bff;- color: white;- border: none;- border-radius: 4px;- cursor: pointer;- font-size: 14px;-}--.btn:hover {- background: #0056b3;-}--.viewer-container {- background: #f9f9f9;- border: 2px solid #ddd;- border-radius: 8px;- overflow: hidden;- margin-bottom: 20px;-}--.viewer {- width: 100%;- height: 650px;-}--.status {- background: #e9ecef;- padding: 15px;- border-radius: 8px;- font-family: monospace;-}--.status p {- margin: 5px 0;-}-</style>diff --git a/app/pages/webgl/index.vue b/app/pages/webgl/index.vuedeleted file mode 100644index 303c89fa..00000000--- a/app/pages/webgl/index.vue+++ /dev/null@@ -1,238 +0,0 @@-<script setup lang="ts"></script>--<template>- <div class="home-page">- <div class="hero-section">- <div class="container">- <h1 class="hero-title">ChronoFrame</h1>- <p class="hero-subtitle">高性能 WebGL 图片查看器</p>- <p class="hero-description">- 基于 WebGL 的硬件加速图片渲染组件,为 Nuxt 4- 项目提供流畅的缩放、平移体验。- </p>- <div class="hero-actions">- <NuxtLink- to="/webgl/demo"- class="btn btn-primary"- >- 查看演示- </NuxtLink>- <a- href="https://github.com/your-repo/chrono-frame"- class="btn btn-secondary"- target="_blank"- rel="noopener noreferrer"- >- GitHub- </a>- </div>- </div>- </div>-- <div class="features-section">- <div class="container">- <h2 class="section-title">核心特性</h2>- <div class="features-grid">- <div class="feature-card">- <div class="feature-icon">🚀</div>- <h3>硬件加速</h3>- <p>基于 WebGL 的 GPU 渲染,提供极致性能表现</p>- </div>-- <div class="feature-card">- <div class="feature-icon">🖼️</div>- <h3>高分辨率支持</h3>- <p>支持任意尺寸图片,智能纹理管理</p>- </div>-- <div class="feature-card">- <div class="feature-icon">📱</div>- <h3>跨平台兼容</h3>- <p>支持桌面和移动设备的鼠标、触摸操作</p>- </div>-- <div class="feature-card">- <div class="feature-icon">🎨</div>- <h3>平滑动画</h3>- <p>物理感的缓动动画,流畅的用户体验</p>- </div>-- <div class="feature-card">- <div class="feature-icon">⚡</div>- <h3>性能优化</h3>- <p>渲染节流、防抖更新、内存管理</p>- </div>-- <div class="feature-card">- <div class="feature-icon">🔧</div>- <h3>高度可配置</h3>- <p>丰富的配置选项和回调函数</p>- </div>- </div>- </div>- </div>- </div>-</template>--<style scoped>-.home-page {- min-height: 100vh;-}--.hero-section {- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);- color: white;- padding: 80px 20px;- text-align: center;-}--.container {- max-width: 1200px;- margin: 0 auto;-}--.hero-title {- font-size: 4rem;- font-weight: 700;- margin-bottom: 1rem;- text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);-}--.hero-subtitle {- font-size: 1.5rem;- margin-bottom: 1.5rem;- opacity: 0.9;-}--.hero-description {- font-size: 1.2rem;- margin-bottom: 2.5rem;- opacity: 0.8;- max-width: 600px;- margin-left: auto;- margin-right: auto;- line-height: 1.6;-}--.hero-actions {- display: flex;- gap: 1rem;- justify-content: center;- flex-wrap: wrap;-}--.btn {- display: inline-block;- padding: 12px 32px;- border-radius: 8px;- text-decoration: none;- font-weight: 600;- font-size: 1rem;- transition: all 0.2s ease;- border: 2px solid transparent;-}--.btn-primary {- background: white;- color: #667eea;-}--.btn-primary:hover {- background: #f7fafc;- transform: translateY(-2px);- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);-}--.btn-secondary {- background: transparent;- color: white;- border-color: white;-}--.btn-secondary:hover {- background: white;- color: #667eea;- transform: translateY(-2px);- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);-}--.features-section {- padding: 80px 20px;- background: #f7fafc;-}--.section-title {- text-align: center;- font-size: 2.5rem;- color: #2d3748;- margin-bottom: 3rem;-}--.features-grid {- display: grid;- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));- gap: 2rem;-}--.feature-card {- background: white;- padding: 2rem;- border-radius: 12px;- text-align: center;- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);- transition: all 0.2s ease;-}--.feature-card:hover {- transform: translateY(-4px);- box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);-}--.feature-icon {- font-size: 3rem;- margin-bottom: 1rem;-}--.feature-card h3 {- font-size: 1.25rem;- color: #2d3748;- margin-bottom: 1rem;-}--.feature-card p {- color: #718096;- line-height: 1.6;-}--/* 响应式设计 */-@media (max-width: 768px) {- .hero-title {- font-size: 2.5rem;- }-- .hero-subtitle {- font-size: 1.25rem;- }-- .hero-description {- font-size: 1rem;- }-- .hero-actions {- flex-direction: column;- align-items: center;- }-- .btn {- width: 200px;- }-- .features-grid {- grid-template-columns: 1fr;- }-- .section-title {- font-size: 2rem;- }-}-</style>diff --git a/server/services/image/blurhash.ts b/server/services/image/blurhash.tsindex 657d93ea..6d71e1e6 100644--- a/server/services/image/blurhash.ts+++ b/server/services/image/blurhash.ts@@ -1,7 +1,10 @@import sharp from 'sharp'import { rgbaToThumbHash } from 'thumbhash'-export const generateBlurHash = async (buffer: Buffer) => {+export const generateBlurHash = async (+ buffer: Buffer,+ logger?: Logger[keyof Logger],+) => {try {const { data, info } = await sharp(buffer).resize(100, 100, { fit: 'inside' })@@ -14,7 +17,7 @@ export const generateBlurHash = async (buffer: Buffer) => {const thumbHash = rgbaToThumbHash(info.width, info.height, data)return thumbHash} catch (error) {- logger.image.error('Generate thumbhash failed', error)+ logger?.error('Generate thumbhash failed', error)return null}}diff --git a/server/services/image/exif.ts b/server/services/image/exif.tsindex 7bed7bbb..c7d46912 100644--- a/server/services/image/exif.ts+++ b/server/services/image/exif.ts@@ -6,7 +6,6 @@ import type { NeededExif, PhotoInfo } from '../../../shared/types/photo'import type { ExifDateTime, Tags } from 'exiftool-vendored'import { exiftool } from 'exiftool-vendored'import { noop } from 'es-toolkit'-import type { Logger } from '~~/server/utils/logger'const neededKeys: Array<keyof Tags | (string & {})> = ['Title',@@ -273,7 +272,7 @@ const processExifData = (exifData: Tags, metadata: Metadata): NeededExif => {export const extractExifData = async (imageBuffer: Buffer,rawImageBuffer?: Buffer,- logger?: Logger['image'],+ logger?: Logger[keyof Logger],): Promise<NeededExif | null> => {try {let metadata = await sharp(imageBuffer).metadata()@@ -291,12 +290,9 @@ export const extractExifData = async (return null}- // 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')+ const tempDir = path.resolve(process.cwd(), 'data/.exif_workdir')await mkdir(tempDir, { recursive: true })const tempImagePath = path.resolve(tempDir, `${crypto.randomUUID()}.jpg`)@@ -306,20 +302,12 @@ export const extractExifData = async (// 记录颜色空间信息的来源if (result.ColorSpace) {- if (exifData.ColorSpace) {- logger?.info(`ColorSpace from EXIF: ${result.ColorSpace}`)- } else {- logger?.info(- `ColorSpace inferred from image data: ${result.ColorSpace}`,- )- logger?.info(- `Image format: ${metadata.format}, Space: ${metadata.space}, Has ICC: ${!!metadata.icc}`,- )- }+ logger?.success(`Inferred ColorSpace: ${result.ColorSpace}`)} else {- logger?.warn('No ColorSpace information available')+ logger?.info('ColorSpace could not be determined')}+ // 清理临时文件await unlink(tempImagePath).catch(noop)return result} catch (err) {diff --git a/server/services/image/thumbnail.ts b/server/services/image/thumbnail.tsindex cc9071c9..eaf8dd72 100644--- a/server/services/image/thumbnail.ts+++ b/server/services/image/thumbnail.ts@@ -1,12 +1,15 @@-import sharp from "sharp"-import { generateBlurHash } from "./blurhash"+import sharp from 'sharp'+import { generateBlurHash } from './blurhash'-export const generateThumbnailAndHash = async (buffer: Buffer) => {- const sharpInst = sharp(buffer).rotate()- const thumbnailBuffer = await sharpInst- .resize(600, null, { withoutEnlargement: true })- .webp({ quality: 100 })- .toBuffer()- const thumbnailHash = await generateBlurHash(thumbnailBuffer)- return { thumbnailBuffer, thumbnailHash }-}\ No newline at end of file+export const generateThumbnailAndHash = async (+ buffer: Buffer,+ logger?: Logger[keyof Logger],+) => {+ const sharpInst = sharp(buffer).rotate()+ const thumbnailBuffer = await sharpInst+ .resize(600, null, { withoutEnlargement: true })+ .webp({ quality: 100 })+ .toBuffer()+ const thumbnailHash = await generateBlurHash(thumbnailBuffer, logger)+ return { thumbnailBuffer, thumbnailHash }+}diff --git a/server/services/photo/pipeline-async.ts b/server/services/photo/pipeline-async.tsindex 05fb7366..319bd27c 100644--- a/server/services/photo/pipeline-async.ts+++ b/server/services/photo/pipeline-async.ts@@ -93,7 +93,7 @@ async function processPhotoInternal((resolve, reject) => {setImmediate(async () => {try {- const result = await generateThumbnailAndHash(imageBuffer)+ const result = await generateThumbnailAndHash(imageBuffer, logger.image)resolve(result)} catch (error) {reject(error)@@ -121,7 +121,7 @@ async function processPhotoInternal(const result = await extractExifData(imageBuffer,imageBuffers.raw,- log,+ logger.image,)resolve(result)} catch (error) {diff --git a/server/utils/logger.ts b/server/utils/logger.tsindex 7153ae7b..36c68921 100644--- a/server/utils/logger.ts+++ b/server/utils/logger.ts@@ -9,13 +9,13 @@ const mConsola = createConsola({})export const logger = {- chrono: mConsola.withTag('CHRONO'),- storage: mConsola.withTag('STORAGE'),- fs: mConsola.withTag('FS'),- image: mConsola.withTag('IMG/PHOTO'),- location: mConsola.withTag('LOCATION'),+ chrono: mConsola.withTag('cframe/main'),+ storage: mConsola.withTag('cframe/storage'),+ fs: mConsola.withTag('cframe/fs'),+ image: mConsola.withTag('cframe/image'),+ location: mConsola.withTag('cframe/location'),dynamic: (id: string) => mConsola.withTag(id.toUpperCase()),}-export type Logger = typeof logger+export type Logger = Omit<typeof logger, 'dynamic'>export type DynamicLogger = typeof logger.dynamic