Resim ile beraber epub da yükleme özelliği eklendi

This commit is contained in:
2025-11-17 23:21:29 +03:00
parent cc07b02e3b
commit b6155c3fcb
5 changed files with 335 additions and 15 deletions

View File

@@ -21,6 +21,7 @@ const OcrStep = () => {
const setError = useAppStore((state) => state.setError);
const clearTranslation = useAppStore((state) => state.clearTranslation);
const bookMetadata = useAppStore((state) => state.bookMetadata);
const epubImports = useAppStore((state) => state.epubImports);
const [status, setStatus] = useState('idle');
const [currentIndex, setCurrentIndex] = useState(0);
const [previewText, setPreviewText] = useState('');
@@ -118,6 +119,7 @@ const OcrStep = () => {
}, [assetBase, isDev, orderedImages.length, setError]);
useEffect(() => {
if (!orderedImages.length) return;
setStatus('idle');
setCurrentIndex(0);
setPreviewText('');
@@ -174,7 +176,7 @@ const OcrStep = () => {
}, [orderedImages, setError, setOcrText, status, total, workerReady]);
if (!orderedImages.length) {
if (!orderedImages.length && !epubImports.length) {
return (
<Stack spacing={2}>
<Alert severity="info">Önce görselleri cropla.</Alert>
@@ -185,6 +187,57 @@ const OcrStep = () => {
);
}
if (!orderedImages.length && epubImports.length) {
return (
<Stack spacing={4}>
{bookMetadata && (
<Typography variant="body2" color="success.main">
Seçilen kitap: <strong>{bookMetadata.title}</strong>
{bookMetadata.authors?.length ? `${bookMetadata.authors.join(', ')}` : ''}
</Typography>
)}
<Box textAlign="center">
<Typography variant="h5">EPUB metni ayrıştırıldı</Typography>
<Typography color="text.secondary">
{epubImports.length > 1
? `${epubImports.length} EPUB dosyasından metin çıkarıldı.`
: 'EPUB dosyasındaki metin çıkarıldı.'}
</Typography>
</Box>
<Box sx={{ p: 2, borderRadius: 2, bgcolor: 'background.default' }}>
<Typography variant="subtitle1">Ön izleme</Typography>
<Box
ref={previewRef}
sx={{
mt: 1,
maxHeight: '10em',
overflowY: 'auto',
whiteSpace: 'pre-wrap',
lineHeight: 1.5,
fontSize: '0.95rem',
color: 'text.secondary',
pr: 1,
}}
>
{ocrText?.trim() || 'Metin ayrıştırılıyor...'}
</Box>
</Box>
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} justifyContent="space-between">
<Button variant="contained" onClick={() => navigate('/')}>
Yükleme adımına dön
</Button>
<Button
variant="contained"
onClick={() => navigate('/translate')}
disabled={!ocrText?.trim()}
>
Çeviri adımına geç
</Button>
</Stack>
</Stack>
);
}
const progressValue =
workerReady && total ? (currentIndex / total) * 100 : 0;
const progressVariant = workerReady ? 'determinate' : 'indeterminate';