diff --git a/src/app/api/download-file/route.ts b/src/app/api/download-file/route.ts new file mode 100644 index 0000000..bb1fb78 --- /dev/null +++ b/src/app/api/download-file/route.ts @@ -0,0 +1,64 @@ +import { NextRequest, NextResponse } from 'next/server' + +export async function GET(request: NextRequest) { + try { + const searchParams = request.nextUrl.searchParams + const fileUrl = searchParams.get('url') + const fileName = searchParams.get('filename') + + if (!fileUrl) { + return NextResponse.json( + { error: 'File URL is required' }, + { status: 400 } + ) + } + + // Проверяем, что URL принадлежит нашему S3 хранилищу + if (!fileUrl.includes('s3.twcstorage.ru/617774af-sfera/')) { + return NextResponse.json( + { error: 'Invalid file URL' }, + { status: 400 } + ) + } + + console.log('🔽 Проксируем скачивание файла:', fileUrl) + + // Загружаем файл с S3 + const response = await fetch(fileUrl, { + method: 'GET', + headers: { + 'User-Agent': 'Mozilla/5.0 (compatible; SferaApp/1.0)', + } + }) + + if (!response.ok) { + console.error('❌ Ошибка загрузки с S3:', response.status, response.statusText) + return NextResponse.json( + { error: `Failed to fetch file: ${response.status}` }, + { status: response.status } + ) + } + + // Получаем содержимое файла + const buffer = await response.arrayBuffer() + + console.log('✅ Файл успешно загружен с S3, размер:', buffer.byteLength) + + // Возвращаем файл с правильными заголовками для скачивания + return new NextResponse(buffer, { + headers: { + 'Content-Type': 'application/octet-stream', // Принудительное скачивание + 'Content-Disposition': `attachment; filename="${fileName || 'file'}"`, + 'Content-Length': buffer.byteLength.toString(), + 'Cache-Control': 'no-cache', + }, + }) + + } catch (error) { + console.error('❌ Ошибка в download-file API:', error) + return NextResponse.json( + { error: 'Failed to download file' }, + { status: 500 } + ) + } +} \ No newline at end of file diff --git a/src/app/globals.css b/src/app/globals.css index bacc02d..ae0c3bb 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -192,14 +192,18 @@ backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.15); transition: all 0.3s ease; + outline: none; } - .glass-input:focus { + .glass-input:focus, + .glass-input:focus-visible { background: rgba(255, 255, 255, 0.12); - border: 1px solid rgba(168, 85, 247, 0.5); + border: 1px solid rgba(168, 85, 247, 0.6); box-shadow: - 0 0 0 3px rgba(168, 85, 247, 0.15), - 0 4px 16px rgba(147, 51, 234, 0.25); + 0 0 0 3px rgba(168, 85, 247, 0.2), + 0 4px 20px rgba(147, 51, 234, 0.3), + 0 0 20px rgba(168, 85, 247, 0.15); + outline: none; } .glass-button { diff --git a/src/components/messenger/messenger-chat.tsx b/src/components/messenger/messenger-chat.tsx index ea33060..d1fd178 100644 --- a/src/components/messenger/messenger-chat.tsx +++ b/src/components/messenger/messenger-chat.tsx @@ -360,7 +360,7 @@ export function MessengerChat({ counterparty }: MessengerChatProps) { )}
{msg.content}
+{msg.content}
{fileName}
+ {fileSize && ( +{formatFileSize(fileSize)}
+ )} +Zoom: {Math.round(zoom * 100)}%
++ ESC - закрыть • Клик - увеличить • Перетаскивание при зуме +
+