Улучшены стили и функциональность компонентов мессенджера, включая поддержку многострочного ввода сообщений и обновление стилей кнопок. Добавлен новый метод скачивания файлов через API для изображений и документов с обработкой ошибок. Оптимизированы компоненты для загрузки файлов и записи голоса, улучшен интерфейс выбора эмодзи.

This commit is contained in:
Bivekich
2025-07-17 13:06:40 +03:00
parent abd0df1fe7
commit e191055682
9 changed files with 412 additions and 78 deletions

View File

@ -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 }
)
}
}

View File

@ -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 {