Add support to load chapter lists from databases

This commit is contained in:
2026-02-18 10:27:27 +08:00
parent e160b1da53
commit a2dbabc5ae
7 changed files with 204 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
import { DbConfig, DbType } from "../config";
import { IndexedDb } from "./indexedDb";
import { PocketBaseDb } from "./pocketBase";
import type { QdChapterInfo, QdBookInfo, PagedData } from "../types";
import type { QdChapterInfo, QdBookInfo, PagedData, QdChapterSimpleInfo } from "../types";
export interface Db {
init(): Promise<void>;
@@ -17,6 +17,12 @@ export interface Db {
saveQdBook(info: QdBookInfo): Promise<void>;
getQdBook(id: number): Promise<QdBookInfo | undefined>;
getQdBooks(page: number, pageSize: number): Promise<PagedData<QdBookInfo>>;
/**
* Retrieve chapter list of a book. if bookId is not found, return empty array.
* Primary key should be the latest (time is biggest) saved chapter.
* @param bookId Book ID
*/
getChapterSimpleInfos(bookId: number): Promise<QdChapterSimpleInfo[]>;
close(): void;
}