Archived
feat: implement mobile reader
- implement mobile epub reader
This commit is contained in:
+17
-36
@@ -1,54 +1,35 @@
|
||||
import { apiClient } from "./client";
|
||||
import { apiClient, getApiBaseUrl } from "./client";
|
||||
import type {
|
||||
EBookListItem,
|
||||
EBookDetail,
|
||||
ReadingProgress,
|
||||
ReadingSettings,
|
||||
TocResponse,
|
||||
ContentResponse,
|
||||
PaginatedResponse,
|
||||
} from "@cloud-reader/shared";
|
||||
|
||||
export const ebooksApi = {
|
||||
/** List uploaded e-books */
|
||||
/** List the authenticated user's uploaded e-books */
|
||||
list() {
|
||||
return apiClient.get<PaginatedResponse<EBookListItem>>("/api/ebooks/");
|
||||
return apiClient.get<PaginatedResponse<EBookListItem>>(
|
||||
"/api/books/ebooks/",
|
||||
);
|
||||
},
|
||||
|
||||
/** Get e-book detail */
|
||||
/** Get e-book detail (metadata, format, progress) */
|
||||
get(id: number) {
|
||||
return apiClient.get<EBookDetail>(`/api/ebooks/${id}/`);
|
||||
return apiClient.get<EBookDetail>(`/api/books/ebooks/${id}/`);
|
||||
},
|
||||
|
||||
/** Get table of contents */
|
||||
/** Get the table of contents (used as a fallback for chapter navigation) */
|
||||
getToc(id: number) {
|
||||
return apiClient.get<TocResponse>(`/api/ebooks/${id}/toc/`);
|
||||
return apiClient.get<TocResponse>(`/api/books/ebooks/${id}/toc/`);
|
||||
},
|
||||
|
||||
/** Get page content */
|
||||
getContent(id: number, page: number) {
|
||||
return apiClient.get<ContentResponse>(
|
||||
`/api/ebooks/${id}/content/?page=${page}`,
|
||||
);
|
||||
/**
|
||||
* Absolute URL to stream the raw ebook file. The endpoint requires JWT auth,
|
||||
* so callers download it with an Authorization header (e.g. via
|
||||
* expo-file-system) rather than handing the URL to a renderer directly.
|
||||
*/
|
||||
getFileUrl(id: number): string {
|
||||
return `${getApiBaseUrl()}/api/books/ebooks/${id}/file/`;
|
||||
},
|
||||
|
||||
/** Update reading progress */
|
||||
updateProgress(id: number, data: Partial<ReadingProgress>) {
|
||||
return apiClient.patch<ReadingProgress>(
|
||||
`/api/ebooks/${id}/progress/`,
|
||||
data,
|
||||
);
|
||||
},
|
||||
|
||||
/** Get or update reading settings */
|
||||
getSettings(id: number) {
|
||||
return apiClient.get<ReadingSettings>(`/api/ebooks/${id}/settings/`);
|
||||
},
|
||||
|
||||
updateSettings(id: number, data: Partial<ReadingSettings>) {
|
||||
return apiClient.patch<ReadingSettings>(
|
||||
`/api/ebooks/${id}/settings/`,
|
||||
data,
|
||||
);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user