fix(web,api): UI fiche livre et lecteur — progression, locators EPUB/PDF, styles
- web: BookPage/ReaderPage enrichis, sauvegarde de progression lecteur - web: locators EPUB/PDF normalisés (+ tests), EpubReader/PdfReader ajustés - web: nginx et service worker ajustés - api: progress — corrections contrôleur/service Refs: #13
This commit is contained in:
10
apps/web/src/reader/locators.ts
Normal file
10
apps/web/src/reader/locators.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export function parsePdfPageLocator(locator?: string | null): number | null {
|
||||
if (!locator?.startsWith("pdf:page:")) return null;
|
||||
const value = Number(locator.split(":").at(-1));
|
||||
return Number.isInteger(value) && value > 0 ? value : null;
|
||||
}
|
||||
|
||||
export function pdfPagePercent(page: number, pages: number): number {
|
||||
if (!Number.isFinite(page) || !Number.isFinite(pages) || pages < 1) return 0;
|
||||
return Math.max(0, Math.min(100, Math.round((page / pages) * 100)));
|
||||
}
|
||||
Reference in New Issue
Block a user