This commit is contained in:
douboer
2025-09-07 13:06:31 +08:00
parent 5150525195
commit 2f26e95052
17 changed files with 606 additions and 134 deletions

154
readme.md
View File

@@ -16,7 +16,9 @@
---
## 2. 主要功能
## 2. 功能
## 2.1 主要功能
- 自动同步 iBooks 数据库和书籍信息文件到本地 `./data` 目录。
- 解析 iBooks 笔记数据库,构建结构化的 `booksnote` 数据。
@@ -26,6 +28,17 @@
- 书名中如含有“-xxxx”后缀仅保留“-”前的主书名。
- 书籍选择菜单按最近打开时间last_open降序排序显示格式为“书名 [时间戳]”。
## 2.1 GUI
![img](uml/iShot_2025-09-07_12.22.26.png)
![img](uml/iShot_2025-09-07_12.22.05.png)
![img](uml/iShot_2025-09-07_12.22.16.png)
笔记导出markdown格式
![img](uml/iShot_2025-09-07_12.31.49.png)
![img](uml/iShot_2025-09-07_12.32.41.png)
---
## 3. 主要数据结构
@@ -365,151 +378,24 @@ AI 请求 -> BookReviewWorker -> DashScopeChatClient.ask -> bookintro.json -> _o
> 注:使用 Mermaid 语法,支持在支持渲染的 Markdown 查看。类之间仅展示主要依赖/调用,非完整字段集合。
### 13.1 类图(核心模块)
```mermaid
classDiagram
class IBookExportApp {
+_load_initial()
+update_book_info(row)
+export_notes()
+_on_finished_cover_clicked(asset_id)
+_on_main_tab_changed(index)
}
class CoverMixin {
+find_book_cover(assetid, info)
+_apply_cover_scale()
+set_cover_ratio(r, force)
}
class FinishedBooksMixin {
+_populate_finished_books_grid()
+_relayout_finished_grid()
}
class BookReviewWorker {
+run()
+finished(book, review)
}
class BookListManager {
+get_books_info()
+get_books_last_open()
+get_finished_books_this_year()
+get_total_readtime(days)
}
class BookNotesExporter {
+build_booksnote(bookid)
+export_booksnote_to_md(note, info, path)
}
class AnnotationManager {
+get_annotations(bookid)
}
class DashScopeChatClient {
+ask(prompt)
}
class BarChartWidget
class BubbleMetricsWidget
class ScatterChartWidget
IBookExportApp --> CoverMixin : mixin
IBookExportApp --> FinishedBooksMixin : mixin
IBookExportApp --> BookListManager : uses
IBookExportApp --> BookNotesExporter : uses
IBookExportApp --> BookReviewWorker : creates
BookReviewWorker --> DashScopeChatClient : uses
BookListManager --> AnnotationManager : uses
IBookExportApp --> BarChartWidget : creates
IBookExportApp --> BubbleMetricsWidget : creates
IBookExportApp --> ScatterChartWidget : creates
FinishedBooksMixin --> BookListManager : query finished
CoverMixin --> config : paths
```
![img](uml/iShot_2025-09-07_12.55.41.png)
### 13.2 时序图:应用启动
```mermaid
sequenceDiagram
participant User
participant App as IBookExportApp
participant Sync as sync_source_files
participant BLM as BookListManager
participant Exporter as BookNotesExporter
User->>App: 启动应用
App->>Sync: 同步原始数据
App->>BLM: 构造 & 加载 booksinfo
App->>Exporter: 初始化导出器
App->>App: _load_initial() (封面/首书)
App->>App: _populate_finished_books_grid()
App->>App: 延迟 _relayout_finished_grid()
App-->>User: 主界面显示
```
![img](uml/iShot_2025-09-07_12.56.27.png)
### 13.3 时序图:选择书籍 + AI 简评
```mermaid
sequenceDiagram
participant User
participant App as IBookExportApp
participant Cover as CoverMixin
participant Worker as BookReviewWorker
participant Chat as DashScopeChatClient
User->>App: 列表选择书籍
App->>Cover: find_book_cover()
Cover-->>App: 封面路径/None
App->>App: update_book_info() 刷新封面/HTML
alt 本地已有简评
App-->>User: 显示简评
else 无简评
App->>Worker: 创建并 start()
Worker->>Chat: ask(prompt)
Chat-->>Worker: review 文本
Worker-->>App: finished(book, review)
App-->>User: 渲染书评
end
```
![img](uml/iShot_2025-09-07_12.56.00.png)
### 13.4 时序图:导出 Markdown
![img](uml/iShot_2025-09-07_12.57.06.png)
```mermaid
sequenceDiagram
participant User
participant App as IBookExportApp
participant Exporter as BookNotesExporter
User->>App: 点击 导出
App->>Exporter: build_booksnote(bookid)
Exporter-->>App: 笔记结构
App->>Exporter: export_booksnote_to_md()
Exporter-->>App: 输出路径
App-->>User: 弹窗提示成功
```
### 13.5 时序图:已读书籍网格刷新
![img](uml/iShot_2025-09-07_12.57.19.png)
```mermaid
sequenceDiagram
participant User
participant App as IBookExportApp
participant FB as FinishedBooksMixin
participant BLM as BookListManager
User->>App: 切换到 已读书籍 Tab
App->>FB: _populate_finished_books_grid() (必要时)
FB->>BLM: get_finished_books_this_year()
BLM-->>FB: 已读列表
FB->>FB: _relayout_finished_grid()
FB-->>User: 网格显示
```
### 13.6 时序图:点击已读封面跳转
```mermaid
sequenceDiagram
participant User
participant FB as FinishedBooksMixin
participant App as IBookExportApp
User->>FB: 点击封面 QLabel
FB->>App: _on_finished_cover_clicked(asset_id)
App->>App: _switch_to_export_tab()
App->>App: listwidget.setCurrentRow()
App->>App: update_book_info()
App-->>User: 显示书籍 & 简评/加载中
```
![img](uml/iShot_2025-09-07_12.57.28.png)
---