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(style): fix lint warnings and errors
Timothy Yineadbe49645b4
diff --git a/app/composables/useMapPerformance.ts b/app/composables/useMapPerformance.tsdeleted file mode 100644index e69de29b..00000000diff --git a/app/libs/histogram.ts b/app/libs/histogram.tsindex 34786fca..5e121a95 100644--- a/app/libs/histogram.ts+++ b/app/libs/histogram.ts@@ -12,7 +12,6 @@ export interface HistogramDataCompressed {gray: number[]}-const zeroArray = (length: number): number[] => new Array(length).fill(0)const compressHistogramBin = (data: number[]): number[] => {const compressed: number[] = zeroArray(128)for (let i = 0; i < data.length; i++) {diff --git a/app/pages/dashboard/index.vue b/app/pages/dashboard/index.vueindex 79b0cb05..01dbf410 100644--- a/app/pages/dashboard/index.vue+++ b/app/pages/dashboard/index.vue@@ -25,7 +25,7 @@ const selectedYear = ref<number | 'recent'>('recent')const refreshData = async () => {isLoading.value = truetry {- await Promise.all([refreshStats()])+ await refreshStats()} finally {isLoading.value = false}diff --git a/package.json b/package.jsonindex 3cdb937c..a09a6a2e 100644--- a/package.json+++ b/package.json@@ -93,6 +93,7 @@"@nuxt/test-utils": "3.19.2","@types/better-sqlite3": "^7.6.13","@types/heic-convert": "^2.1.0",+ "baseline-browser-mapping": "^2.10.13","consola": "^3.4.2","dayjs": "^1.11.15","drizzle-kit": "^0.31.4",diff --git a/packages/webgl-image/src/core/WebGLImageViewerEngine.ts b/packages/webgl-image/src/core/WebGLImageViewerEngine.tsindex 5fef7e45..e92d296d 100644--- a/packages/webgl-image/src/core/WebGLImageViewerEngine.ts+++ b/packages/webgl-image/src/core/WebGLImageViewerEngine.ts@@ -35,17 +35,15 @@ interface Tile {const TILE_DEBUG_BORDER_PX = 2.4const TILE_DEBUG_BORDER_COLOR: [number, number, number, number] = [- 0.4,- 0.7,- 0.9,- 0.25,+ 0.4, 0.7, 0.9, 0.25,]export class WebGLImageViewerEngine {private canvas: HTMLCanvasElementprivate gl: WebGLRenderingContextprivate config: EngineConfig- private image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | null = null+ private image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | null =+ nullprivate texture: WebGLTexture | null = nullprivate program: WebGLProgram | null = nullprivate tiles: Tile[] = []@@ -90,9 +88,18 @@ export class WebGLImageViewerEngine {private resizeObserver: ResizeObserver | null = null// 绑定的事件处理器(用于正确添加/移除全局事件监听器)+ private boundHandleMouseDown: (event: MouseEvent) => voidprivate boundHandleMouseUp: () => voidprivate boundHandleMouseMove: (event: MouseEvent) => voidprivate boundHandleMouseLeave: () => void+ private boundHandleWheel: (event: WheelEvent) => void+ private boundHandleClick: (event: MouseEvent) => void+ private boundHandleTouchStart: (event: TouchEvent) => void+ private boundHandleTouchMove: (event: TouchEvent) => void+ private boundHandleTouchEnd: (event: TouchEvent) => void+ private boundHandleContextLost: (event: Event) => void+ private boundHandleContextRestored: () => void+ private boundHandleContextMenu: (event: MouseEvent) => void// 回调函数private onZoomChange?: (originalScale: number, relativeScale: number) => void@@ -133,9 +140,18 @@ export class WebGLImageViewerEngine {)// 绑定事件处理器+ this.boundHandleMouseDown = this.handleMouseDown.bind(this)this.boundHandleMouseUp = this.handleMouseUp.bind(this)this.boundHandleMouseMove = this.handleMouseMove.bind(this)this.boundHandleMouseLeave = this.handleMouseLeave.bind(this)+ this.boundHandleWheel = this.handleWheel.bind(this)+ this.boundHandleClick = this.handleClick.bind(this)+ this.boundHandleTouchStart = this.handleTouchStart.bind(this)+ this.boundHandleTouchMove = this.handleTouchMove.bind(this)+ this.boundHandleTouchEnd = this.handleTouchEnd.bind(this)+ this.boundHandleContextLost = this.handleContextLost.bind(this)+ this.boundHandleContextRestored = this.handleContextRestored.bind(this)+ this.boundHandleContextMenu = (event: MouseEvent) => event.preventDefault()this.init()}@@ -306,40 +322,38 @@ export class WebGLImageViewerEngine {private setupEventListeners(): void {// 鼠标事件- this.canvas.addEventListener('mousedown', this.handleMouseDown.bind(this))+ this.canvas.addEventListener('mousedown', this.boundHandleMouseDown)this.canvas.addEventListener('mouseleave', this.boundHandleMouseLeave)- this.canvas.addEventListener('wheel', this.handleWheel.bind(this), {+ this.canvas.addEventListener('wheel', this.boundHandleWheel, {passive: false,})- this.canvas.addEventListener('click', this.handleClick.bind(this))+ this.canvas.addEventListener('click', this.boundHandleClick)// 触摸事件- this.canvas.addEventListener(- 'touchstart',- this.handleTouchStart.bind(this),- { passive: false },- )- this.canvas.addEventListener('touchmove', this.handleTouchMove.bind(this), {+ this.canvas.addEventListener('touchstart', this.boundHandleTouchStart, {+ passive: false,+ })+ this.canvas.addEventListener('touchmove', this.boundHandleTouchMove, {passive: false,})- this.canvas.addEventListener('touchend', this.handleTouchEnd.bind(this), {+ this.canvas.addEventListener('touchend', this.boundHandleTouchEnd, {passive: false,})// WebGL 上下文丢失事件this.canvas.addEventListener('webglcontextlost',- this.handleContextLost.bind(this),+ this.boundHandleContextLost,false,)this.canvas.addEventListener('webglcontextrestored',- this.handleContextRestored.bind(this),+ this.boundHandleContextRestored,false,)// 防止上下文菜单- this.canvas.addEventListener('contextmenu', (e) => e.preventDefault())+ this.canvas.addEventListener('contextmenu', this.boundHandleContextMenu)}private setupResizeObserver(): void {@@ -370,8 +384,14 @@ export class WebGLImageViewerEngine {this.imageLoadingReject = rejectif (this.worker) {try {- const absolute = new URL(src, self.location?.origin || 'http://localhost')- this.worker.postMessage({ type: 'load', payload: { src: absolute.toString() } })+ const absolute = new URL(+ src,+ self.location?.origin || 'http://localhost',+ )+ this.worker.postMessage({+ type: 'load',+ payload: { src: absolute.toString() },+ })} catch {this.worker.postMessage({ type: 'load', payload: { src } })}@@ -429,7 +449,7 @@ export class WebGLImageViewerEngine {const ctx = offscreen.getContext('2d')if (ctx) {ctx.imageSmoothingEnabled = true-+ctx.imageSmoothingQuality = 'high'ctx.drawImage(imageSource as any, 0, 0, targetWidth, targetHeight)finalSource = offscreen@@ -490,7 +510,8 @@ export class WebGLImageViewerEngine {if (!this.config.tileEnabled) return falsereturn (- source.width > this.config.tileSize || source.height > this.config.tileSize+ source.width > this.config.tileSize ||+ source.height > this.config.tileSize)}@@ -606,7 +627,10 @@ export class WebGLImageViewerEngine {}}} catch (error) {- console.warn('Failed to create tiles, falling back to single texture.', error)+ console.warn(+ 'Failed to create tiles, falling back to single texture.',+ error,+ )disposeTiles()this.cleanupTiles()return false@@ -630,8 +654,8 @@ export class WebGLImageViewerEngine {return this.tiles}- const viewLeft = (-this.transform.translateX) / scale- const viewTop = (-this.transform.translateY) / scale+ const viewLeft = -this.transform.translateX / scale+ const viewTop = -this.transform.translateY / scaleconst viewRight = (this.canvas.width - this.transform.translateX) / scaleconst viewBottom = (this.canvas.height - this.transform.translateY) / scale@@ -792,7 +816,11 @@ export class WebGLImageViewerEngine {gl.clear(gl.COLOR_BUFFER_BIT)gl.useProgram(this.program)- gl.uniform2f(this.resolutionLocation, this.canvas.width, this.canvas.height)+ gl.uniform2f(+ this.resolutionLocation,+ this.canvas.width,+ this.canvas.height,+ )gl.uniform1i(this.imageLocation, 0)const matrix = createTransformMatrix(@@ -1525,31 +1553,22 @@ export class WebGLImageViewerEngine {}// 清理事件监听器- this.canvas.removeEventListener(- 'mousedown',- this.handleMouseDown.bind(this),- )+ this.canvas.removeEventListener('mousedown', this.boundHandleMouseDown)this.canvas.removeEventListener('mouseleave', this.boundHandleMouseLeave)- this.canvas.removeEventListener('wheel', this.handleWheel.bind(this))- this.canvas.removeEventListener('click', this.handleClick.bind(this))- this.canvas.removeEventListener(- 'touchstart',- this.handleTouchStart.bind(this),- )- this.canvas.removeEventListener(- 'touchmove',- this.handleTouchMove.bind(this),- )- this.canvas.removeEventListener('touchend', this.handleTouchEnd.bind(this))+ this.canvas.removeEventListener('wheel', this.boundHandleWheel)+ this.canvas.removeEventListener('click', this.boundHandleClick)+ this.canvas.removeEventListener('touchstart', this.boundHandleTouchStart)+ this.canvas.removeEventListener('touchmove', this.boundHandleTouchMove)+ this.canvas.removeEventListener('touchend', this.boundHandleTouchEnd)this.canvas.removeEventListener('webglcontextlost',- this.handleContextLost.bind(this),+ this.boundHandleContextLost,)this.canvas.removeEventListener('webglcontextrestored',- this.handleContextRestored.bind(this),+ this.boundHandleContextRestored,)- this.canvas.removeEventListener('contextmenu', (e) => e.preventDefault())+ this.canvas.removeEventListener('contextmenu', this.boundHandleContextMenu)// 清理全局事件监听器(防止内存泄露)document.removeEventListener('mouseup', this.boundHandleMouseUp)diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 018be8c7..16a81901 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -186,6 +186,9 @@ importers:'@types/heic-convert':specifier: ^2.1.0version: 2.1.0+ baseline-browser-mapping:+ specifier: ^2.10.13+ version: 2.10.13consola:specifier: ^3.4.2version: 3.4.2@@ -3706,8 +3709,9 @@ packages:resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}- resolution: {integrity: sha512-j5zJcx6golJYTG6c05LUZ3Z8Gi+M62zRT/ycz4Xq4iCOdpcxwg7ngEYD4KA0eWZC7U17qh/Smq8bYbACJ0ipBA==}+ resolution: {integrity: sha512-BL2sTuHOdy0YT1lYieUxTw/QMtPBC3pmlJC6xk8BBYVv6vcw3SGdKemQ+Xsx9ik2F/lYDO9tqsFQH1r9PFuHKw==}+ engines: {node: '>=6.0.0'}hasBin: true@@ -11478,7 +11482,7 @@ snapshots:- [email protected]: {}+ [email protected]: {}@@ -11524,7 +11528,7 @@ snapshots:dependencies:- baseline-browser-mapping: 2.8.17+ baseline-browser-mapping: 2.10.13caniuse-lite: 1.0.30001751electron-to-chromium: 1.5.237node-releases: 2.0.25diff --git a/server/api/wizard/complete.post.ts b/server/api/wizard/complete.post.tsindex 87f6b03b..903a096a 100644--- a/server/api/wizard/complete.post.ts+++ b/server/api/wizard/complete.post.ts@@ -1,6 +1,6 @@import { settingsManager } from '~~/server/services/settings/settingsManager'-export default eventHandler(async (event) => {+export default eventHandler(async (_event) => {// Set firstLaunch to false// Pass true as the last argument (sudo) to bypass readonly checkawait settingsManager.set('system', 'firstLaunch', false, undefined, true)diff --git a/server/services/image/histogram.ts b/server/services/image/histogram.tsindex a7a83cbd..e62d4b27 100644--- a/server/services/image/histogram.ts+++ b/server/services/image/histogram.ts@@ -25,12 +25,11 @@ export const calculateHistogram = async (const { width, height, channels } = infoconst totalPixels = width * height-// 初始化直方图数组(256个bin,对应0-255的像素值)- const histogramR = new Array(256).fill(0)- const histogramG = new Array(256).fill(0)- const histogramB = new Array(256).fill(0)- const histogramGray = new Array(256).fill(0)+ const histogramR = zeroArray(256)+ const histogramG = zeroArray(256)+ const histogramB = zeroArray(256)+ const histogramGray = zeroArray(256)// 遍历像素数据计算直方图for (let i = 0; i < data.length; i += channels) {diff --git a/shared/utils/index.ts b/shared/utils/index.tsnew file mode 100644index 00000000..b6a440c1--- /dev/null+++ b/shared/utils/index.ts@@ -0,0 +1,2 @@+export const zeroArray = (length: number): number[] =>+ Array.from({ length }, () => 0)