代码优化,epub阅读标签

This commit is contained in:
DelLevin-Home
2026-06-28 02:25:07 +08:00
parent c810a1a381
commit 5f434ae3fa
35 changed files with 2110 additions and 525 deletions

View File

@@ -133,4 +133,32 @@ class ReaderDao {
final db = await _db.database;
return db.delete('book_annotations', where: 'id = ?', whereArgs: [id]);
}
// ─── bookmarks ──────────────────────────────────────────────────
/// 获取某本书的所有书签
Future<List<Map<String, dynamic>>> getBookmarksByBookId(String bookId) async {
final db = await _db.database;
return db.query(
'book_annotations',
where: 'book_id = ? AND type = ?',
whereArgs: [bookId, 'bookmark'],
orderBy: 'created_at DESC',
);
}
/// 插入书签
Future<int> insertBookmark(Map<String, dynamic> bookmark) async {
final db = await _db.database;
return db.insert('book_annotations', {
...bookmark,
'type': 'bookmark',
});
}
/// 删除书签
Future<int> deleteBookmark(int id) async {
final db = await _db.database;
return db.delete('book_annotations', where: 'id = ?', whereArgs: [id]);
}
}