readful/lib/models/book.g.dart
ddshi bef0de5909 feat: 完成文件导入功能和Book模型扩展
## 新增功能
- EPUB文件导入功能:支持文件选择、解析和存储
- 文件重复检测:避免重复导入同一文件
- 导入状态反馈:成功/失败消息提示

## 模型扩展
- Book模型新增多作者支持(authors字段)
- 新增章节数统计(chapterCount字段)
- 新增语言标识(language字段)
- 新增EPUB标识符(identifier字段)
- 优化TypeAdapter序列化支持

## 服务优化
- 新增EpubParserService:EPUB文件解析服务
- 改进DatabaseService:错误处理和数据迁移
- 优化BookRepository:调试日志和错误追踪

## 依赖更新
- 新增epubx ^4.0.0:EPUB电子书解析库
- 更新pubspec.lock:同步依赖版本

## UI改进
- AppHeader组件集成完整导入功能
- SafeArea适配:避免系统状态栏重叠
- 优化测试数据结构

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 20:34:16 +08:00

186 lines
4.5 KiB
Dart

// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'book.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class BookAdapter extends TypeAdapter<Book> {
@override
final int typeId = 2;
@override
Book read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return Book(
id: fields[0] as String,
title: fields[1] as String,
author: fields[2] as String?,
authors: (fields[16] as List).cast<String>(),
publisher: fields[3] as String?,
description: fields[4] as String?,
coverImagePath: fields[5] as String?,
filePath: fields[6] as String,
format: fields[7] as BookFormat,
fileSize: fields[8] as int,
addedDate: fields[9] as DateTime,
status: fields[10] as ReadingStatus,
rating: fields[11] as double?,
tags: (fields[12] as List).cast<String>(),
totalPages: fields[13] as int,
chapterCount: fields[17] as int?,
language: fields[18] as String?,
identifier: fields[19] as String?,
);
}
@override
void write(BinaryWriter writer, Book obj) {
writer
..writeByte(18)
..writeByte(0)
..write(obj.id)
..writeByte(1)
..write(obj.title)
..writeByte(2)
..write(obj.author)
..writeByte(16)
..write(obj.authors)
..writeByte(3)
..write(obj.publisher)
..writeByte(4)
..write(obj.description)
..writeByte(5)
..write(obj.coverImagePath)
..writeByte(6)
..write(obj.filePath)
..writeByte(7)
..write(obj.format)
..writeByte(8)
..write(obj.fileSize)
..writeByte(9)
..write(obj.addedDate)
..writeByte(10)
..write(obj.status)
..writeByte(11)
..write(obj.rating)
..writeByte(12)
..write(obj.tags)
..writeByte(13)
..write(obj.totalPages)
..writeByte(17)
..write(obj.chapterCount)
..writeByte(18)
..write(obj.language)
..writeByte(19)
..write(obj.identifier);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BookAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class BookFormatAdapter extends TypeAdapter<BookFormat> {
@override
final int typeId = 0;
@override
BookFormat read(BinaryReader reader) {
switch (reader.readByte()) {
case 0:
return BookFormat.epub;
case 1:
return BookFormat.mobi;
case 2:
return BookFormat.txt;
case 3:
return BookFormat.pdf;
default:
return BookFormat.epub;
}
}
@override
void write(BinaryWriter writer, BookFormat obj) {
switch (obj) {
case BookFormat.epub:
writer.writeByte(0);
break;
case BookFormat.mobi:
writer.writeByte(1);
break;
case BookFormat.txt:
writer.writeByte(2);
break;
case BookFormat.pdf:
writer.writeByte(3);
break;
}
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BookFormatAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class ReadingStatusAdapter extends TypeAdapter<ReadingStatus> {
@override
final int typeId = 1;
@override
ReadingStatus read(BinaryReader reader) {
switch (reader.readByte()) {
case 0:
return ReadingStatus.reading;
case 1:
return ReadingStatus.completed;
case 2:
return ReadingStatus.pending;
default:
return ReadingStatus.reading;
}
}
@override
void write(BinaryWriter writer, ReadingStatus obj) {
switch (obj) {
case ReadingStatus.reading:
writer.writeByte(0);
break;
case ReadingStatus.completed:
writer.writeByte(1);
break;
case ReadingStatus.pending:
writer.writeByte(2);
break;
}
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ReadingStatusAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}