fix(web): lecteurs EPUB/PDF — gestion d'erreurs, worker pdf.js local
Composant ReaderError avec diagnostic et actions de repli, worker pdf.js servi localement (pdfWorker) pour éviter les CDN, typage du view foliate, navigation retour vers la fiche livre et styles lecteur associés. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
53
apps/web/src/reader/ReaderError.tsx
Normal file
53
apps/web/src/reader/ReaderError.tsx
Normal file
@ -0,0 +1,53 @@
|
||||
import { ArrowLeft, Download, RotateCcw } from "lucide-react";
|
||||
import { navigate } from "../router";
|
||||
|
||||
export function readerErrorMessage(error: unknown, fallback: string): string {
|
||||
if (error instanceof Error && error.message.trim()) return error.message;
|
||||
if (typeof error === "string" && error.trim()) return error;
|
||||
return fallback;
|
||||
}
|
||||
|
||||
export function ReaderError({
|
||||
title,
|
||||
detail,
|
||||
technicalDetail,
|
||||
downloadUrl,
|
||||
backHref,
|
||||
onRetry
|
||||
}: {
|
||||
title: string;
|
||||
detail: string;
|
||||
technicalDetail?: string;
|
||||
downloadUrl: string;
|
||||
backHref: string;
|
||||
onRetry: () => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="reader-error">
|
||||
<div>
|
||||
<h2>{title}</h2>
|
||||
<p>{detail}</p>
|
||||
</div>
|
||||
<div className="reader-error-actions">
|
||||
<button className="ghost-button" onClick={onRetry}>
|
||||
<RotateCcw size={16} />
|
||||
Réessayer
|
||||
</button>
|
||||
<button className="ghost-button" onClick={() => navigate(backHref)}>
|
||||
<ArrowLeft size={16} />
|
||||
Retour à la fiche
|
||||
</button>
|
||||
<a className="ghost-button" href={downloadUrl} download>
|
||||
<Download size={16} />
|
||||
Télécharger
|
||||
</a>
|
||||
</div>
|
||||
{technicalDetail && (
|
||||
<details>
|
||||
<summary>Détail technique</summary>
|
||||
<pre>{technicalDetail}</pre>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user