Numerous Bug Fixes
Some checks failed
Automated Container Build / build-and-push (push) Failing after 8s
Some checks failed
Automated Container Build / build-and-push (push) Failing after 8s
This commit is contained in:
parent
02eefdac0e
commit
267d429122
959 changed files with 145571 additions and 221 deletions
|
|
@ -4,6 +4,9 @@ import { useState, useEffect } from 'react';
|
|||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
import { X, Download, File, Image as ImageIcon, Film, Music, FileText, Code, Loader2 } from 'lucide-react';
|
||||
import api from '@/lib/api';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
const DynamicPdfViewer = dynamic(() => import('./PdfViewer'), { ssr: false });
|
||||
|
||||
interface FilePreviewProps {
|
||||
file: {
|
||||
|
|
@ -64,7 +67,7 @@ export default function FilePreview({ file, onClose }: FilePreviewProps) {
|
|||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
className="fixed inset-0 z-[100] flex items-center justify-center p-4 sm:p-8"
|
||||
className="fixed inset-0 z-[100] flex items-center justify-center p-2 sm:p-4"
|
||||
style={{ backgroundColor: 'rgba(0, 0, 0, 0.8)', backdropFilter: 'blur(8px)' }}
|
||||
onClick={onClose}
|
||||
>
|
||||
|
|
@ -73,7 +76,11 @@ export default function FilePreview({ file, onClose }: FilePreviewProps) {
|
|||
animate={{ scale: 1, opacity: 1, y: 0 }}
|
||||
exit={{ scale: 0.95, opacity: 0, y: 20 }}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className="relative flex flex-col w-full max-w-5xl h-full max-h-[90vh] rounded-2xl overflow-hidden shadow-2xl"
|
||||
className={`relative flex flex-col max-w-[95vw] max-h-[95vh] rounded-2xl overflow-hidden shadow-2xl ${
|
||||
(previewType === 'image' || previewType === 'video' || previewType === 'pdf') ? 'w-fit' : 'w-full'
|
||||
} ${
|
||||
(previewType === 'image' || previewType === 'video') ? 'h-fit' : 'h-full'
|
||||
}`}
|
||||
style={{ backgroundColor: 'var(--color-bg-elevated)', border: '1px solid var(--color-border)' }}
|
||||
>
|
||||
{/* Header */}
|
||||
|
|
@ -111,12 +118,12 @@ export default function FilePreview({ file, onClose }: FilePreviewProps) {
|
|||
</div>
|
||||
|
||||
{/* Content Area */}
|
||||
<div className="flex-1 overflow-auto flex items-center justify-center p-4 relative" style={{ backgroundColor: 'var(--color-bg-primary)' }}>
|
||||
<div className={`flex-1 overflow-auto flex items-center justify-center relative ${previewType === 'image' || previewType === 'video' ? 'p-4' : ''}`} style={{ backgroundColor: 'var(--color-bg-primary)' }}>
|
||||
{previewType === 'image' && (
|
||||
<img
|
||||
src={downloadUrl}
|
||||
alt={file.name}
|
||||
className="max-w-full max-h-full object-contain rounded-lg"
|
||||
className="max-w-[calc(95vw-2rem)] max-h-[calc(95vh-6rem)] object-contain"
|
||||
/>
|
||||
)}
|
||||
|
||||
|
|
@ -138,11 +145,7 @@ export default function FilePreview({ file, onClose }: FilePreviewProps) {
|
|||
)}
|
||||
|
||||
{previewType === 'pdf' && (
|
||||
<iframe
|
||||
src={`${downloadUrl}#navpanes=0&view=FitH`}
|
||||
title={file.name}
|
||||
className="w-full h-full rounded-lg border-0 bg-white"
|
||||
/>
|
||||
<DynamicPdfViewer url={downloadUrl} />
|
||||
)}
|
||||
|
||||
{(previewType === 'text' || previewType === 'code') && (
|
||||
|
|
@ -220,10 +223,10 @@ function getPreviewType(file: { name: string; mime_type: string }): PreviewType
|
|||
if (['txt', 'md', 'csv', 'json', 'log'].includes(ext)) return 'text';
|
||||
if (['js', 'ts', 'jsx', 'tsx', 'html', 'css', 'go', 'py', 'rs', 'c', 'cpp', 'java', 'sh', 'yml', 'yaml', 'xml'].includes(ext)) return 'code';
|
||||
|
||||
if (file.mime_type.startsWith('image/')) return 'image';
|
||||
if (file.mime_type.startsWith('video/')) return 'video';
|
||||
if (file.mime_type.startsWith('audio/')) return 'audio';
|
||||
if (file.mime_type.startsWith('text/')) return 'text';
|
||||
if (file.mime_type?.startsWith('image/')) return 'image';
|
||||
if (file.mime_type?.startsWith('video/')) return 'video';
|
||||
if (file.mime_type?.startsWith('audio/')) return 'audio';
|
||||
if (file.mime_type?.startsWith('text/')) return 'text';
|
||||
|
||||
return 'unsupported';
|
||||
}
|
||||
|
|
@ -246,3 +249,5 @@ function formatSize(bytes: number): string {
|
|||
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||
return `${(bytes / Math.pow(1024, i)).toFixed(1)} ${units[i]}`;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Reference in a new issue