71 lines
2.2 KiB
Markdown
71 lines
2.2 KiB
Markdown
# iPad Reader (Offline Bundle Viewer)
|
||
|
||
基于 Python 导出的 iPad 数据包 (export_ipad_bundle) 的 SwiftUI 离线浏览器。
|
||
|
||
## 目标
|
||
- 离线浏览书籍元数据、书评与批注
|
||
- 快速导入 ZIP(`ipad_bundle_*.zip`)
|
||
- 原生 SwiftUI + Charts 展示周/月/年/气泡统计(含今年已读)
|
||
- 本地沙盒解压 + 简单封面缓存
|
||
|
||
## 数据包结构
|
||
```
|
||
books_meta.json # 书籍元信息数组
|
||
annotations.json # { bookId: [ {uuid, creationdate, selected, note, ...}, ... ] }
|
||
stats.json # { global: {...} }
|
||
bookintro.json # { title: review }
|
||
covers/<id>.jpg # 封面缩略图
|
||
```
|
||
|
||
## 运行环境
|
||
- Xcode 15+
|
||
- iOS 17 SDK(可改最低到 16,只要使用 Charts 框架即可)
|
||
- Swift 5.9+
|
||
|
||
## 功能概览
|
||
- 文档导入:使用 `UIDocumentPickerViewController` (通过 `UIKit` bridge) 选择 ZIP
|
||
- 解压:使用 `ZIPFoundation`(需 SPM 依赖)到 `Library/Application Support/ImportedBundle/<timestamp>/`
|
||
- 模型解析:JSONDecoder -> 内存模型 + 按需懒加载 annotations
|
||
- 统计:Swift Charts 构建 4 个图 + “已读”气泡自绘
|
||
- 搜索:标题/作者前缀过滤(基础实现)
|
||
|
||
## 目录结构
|
||
```
|
||
ipad_app/
|
||
README.md
|
||
Package.swift
|
||
Sources/
|
||
IpadReaderApp.swift # 入口
|
||
Models/BundleModels.swift # 数据模型
|
||
Services/BundleImporter.swift
|
||
Services/ImageCache.swift
|
||
ViewModels/LibraryViewModel.swift
|
||
Views/ContentView.swift
|
||
Views/BookListView.swift
|
||
Views/BookDetailView.swift
|
||
Views/StatsView.swift
|
||
Views/Components/BubbleMetricsView.swift
|
||
```
|
||
|
||
## 添加依赖
|
||
在 `Package.swift` 中引用:
|
||
```
|
||
.package(url: "https://github.com/weichsel/ZIPFoundation", from: "0.9.0")
|
||
```
|
||
|
||
## 使用步骤
|
||
1. 在根目录执行 `open ipad_app` 用 Xcode 打开 (或手动新建本地 Package App)
|
||
2. 运行到模拟器或真机(首次会是空库)
|
||
3. 点击 导入按钮,选择 Python 导出的 `ipad_bundle_*.zip`
|
||
4. 等待解析后显示书籍列表
|
||
5. 进入详情查看笔记与书评
|
||
|
||
## 后续可扩展
|
||
- Spotlight / CoreData 持久化
|
||
- 批注全文搜索、高亮段落分组
|
||
- AI 离线摘要缓存合并
|
||
- 多次导入合并策略(按 book id 去重)
|
||
|
||
---
|
||
此目录下其余 Swift 源码文件由后续步骤自动生成。
|