🎉 FIXED: Screenshot gallery preview and enlargement functionality
Major Issues Resolved: - Screenshot gallery images now load and display correctly - Click-to-enlarge modal functionality working - ESC key closes enlarged images (confirmed working) - Click-outside-to-close functionality added - Created new /api/image route to serve screenshots (bypasses Next.js 15 route issue) - Fixed screenshot URL formatting to use query parameter format - Added proper keyboard event handling for ESC key - Improved timeframe extraction from screenshot filenames - Enhanced trade execution error handling with detailed feedback - Fixed Next.js build cache issues causing route problems - Cleaned up debugging console logs - Restored normal conditional gallery rendering - Proper error handling for image loading failures The screenshot gallery now fully works: 1. Images display in grid layout ✅ 2. Click any image to enlarge ✅ 3. ESC key closes enlarged view ✅ 4. Click outside modal to close ✅ 5. Proper timeframe labeling ✅ 6. Trade execution shows detailed error messages ✅
This commit is contained in:
27
app/api/image/route.ts
Normal file
27
app/api/image/route.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import fs from 'fs/promises'
|
||||
import path from 'path'
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(req.url)
|
||||
const filename = searchParams.get('file')
|
||||
|
||||
if (!filename) {
|
||||
return NextResponse.json({ error: 'Filename required' }, { status: 400 })
|
||||
}
|
||||
|
||||
const screenshotsDir = path.join(process.cwd(), 'screenshots')
|
||||
const filePath = path.join(screenshotsDir, filename)
|
||||
const file = await fs.readFile(filePath)
|
||||
|
||||
return new NextResponse(file, {
|
||||
headers: {
|
||||
'Content-Type': 'image/png',
|
||||
'Content-Disposition': `inline; filename="${filename}"`
|
||||
}
|
||||
})
|
||||
} catch (e: any) {
|
||||
return NextResponse.json({ error: e.message }, { status: 404 })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user