Skip to content

feat: Legado 备份导入 & WebDAV 阅读进度同步#2

Open
aimercat1994 wants to merge 2 commits into
Maple0517:mainfrom
aimercat1994:feat/legado-import-and-webdav-sync
Open

feat: Legado 备份导入 & WebDAV 阅读进度同步#2
aimercat1994 wants to merge 2 commits into
Maple0517:mainfrom
aimercat1994:feat/legado-import-and-webdav-sync

Conversation

@aimercat1994

Copy link
Copy Markdown

Legado 备份导入

解析 Legado App 的 WebDAV 备份 .zip 文件,转换为 reader-next 原生格式并导入:

  • 支持数据:书籍、书源(412个)、分组、书签、净化规则、RSS 源
  • 智能过滤:跳过 content:// 手机本地文件,解码 data: 内联书籍
  • 排序逻辑:按阅读进度降序排列(章节数 → 章节内位置 → 时间戳)
  • 预览确认:导入前显示各类数据数量统计,确认后才执行

WebDAV 阅读进度同步

实现 Legado 兼容的 WebDAV 阅读进度同步,格式:/legado/bookProgress/{书名}_{作者}.json

  • 自动拉取:书架加载时从 WebDAV 同步进度,按章节数比较(远程更远则更新)
  • 自动推送:阅读翻章时自动写入 WebDAV(fire-and-forget,不阻塞阅读)
  • 手动同步:备份管理界面新增「拉取进度」「推送进度」按钮

文件变更

文件 状态 说明
frontend/src/utils/legadoImport.ts 新增 Legado zip 解析 + 数据转换
frontend/src/utils/webdavSync.ts 新增 WebDAV 进度同步(读/写/合并)
frontend/src/utils/legadoImport.test.ts 新增 15 个单元测试
frontend/src/components/WebdavManager.vue 修改 导入 UI + 同步按钮 + 预览模态框
frontend/src/stores/bookshelf.ts 修改 书架加载时自动拉取 WebDAV 进度
frontend/src/stores/reader.ts 修改 翻章时自动推送进度到 WebDAV
frontend/package.json 修改 新增 jszip 依赖

测试

cd frontend && npx vitest run src/utils/legadoImport.test.ts
# PASS (15) FAIL (0)

## Legado Backup Import
- Parse Legado App WebDAV backup .zip files and import into reader-next
- Supports: books, book sources, book groups, bookmarks, replace rules, RSS sources
- Auto-filters content:// local files, decodes data: URI inline books
- Sorts imported books by reading progress (chapter index > position > time)
- Preview modal shows import summary before confirming

## WebDAV Reading Progress Sync
- Legado-compatible progress format: /legado/bookProgress/{name}_{author}.json
- Auto-pull: syncs progress from WebDAV on bookshelf load (chapter index wins)
- Auto-push: writes progress to WebDAV on each chapter save (fire-and-forget)
- Manual sync: pull/push buttons in backup manager UI

## Files Changed
- frontend/src/utils/legadoImport.ts (new)
- frontend/src/utils/webdavSync.ts (new)
- frontend/src/utils/legadoImport.test.ts (new, 15 tests)
- frontend/src/components/WebdavManager.vue (modified)
- frontend/src/stores/bookshelf.ts (modified)
- frontend/src/stores/reader.ts (modified)
- frontend/package.json (added jszip dependency)
- Filter out data: URI decoded books with empty bookUrl to prevent
  'bookUrl required' error from saveBooks API
- Revert import sort to use durChapterTime (last read time) instead
  of chapter index, which is more meaningful for shelf display order
- Update tests to match new sort behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant