feat(w2): add PackService for .novel and .novel-all export/import

Introduce pack-bootstrap chunk, ZipArchive-based PackService with progress IPC,
book registry import helpers, and IT-PACK-01 / IT-ALL-02 integration tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-08 15:36:47 +08:00
parent 9f2b1ae3e0
commit a4412793f4
12 changed files with 1563 additions and 73 deletions
@@ -45,11 +45,11 @@
- Create: `src/main/pack-bootstrap.ts`
- Modify: `electron.vite.config.ts`
- [ ] **Step 1:** `npm install archiver` + dev `@types/archiver`
- [ ] **Step 2:** `novel-pack.ts``NOVEL_FORMAT_VERSION = 1``NovelManifest``NovelAllManifest`
- [ ] **Step 3:** `pack-bootstrap.ts` — 导出 `bootstrapPackHandlers(registry, settings)`
- [ ] **Step 4:** `electron.vite.config.ts` — 增加 `pack-bootstrap` input`external: ['archiver']`
- [ ] **Step 5:** `npm run build` 通过
- [x] **Step 1:** `npm install archiver` + dev `@types/archiver`
- [x] **Step 2:** `novel-pack.ts``NOVEL_FORMAT_VERSION = 1``NovelManifest``NovelAllManifest`
- [x] **Step 3:** `pack-bootstrap.ts` — 导出 `bootstrapPackHandlers(registry, settings)`
- [x] **Step 4:** `electron.vite.config.ts` — 增加 `pack-bootstrap` input`external: ['archiver']`
- [x] **Step 5:** `npm run build` 通过
---
@@ -59,10 +59,10 @@
- Create: `src/main/services/pack.service.ts`
- Modify: `src/main/services/book-registry.ts``importFromDb(meta, sqlitePath)` 辅助
- [ ] **Step 1:** `exportBook(bookId, destPath)` — ZIP: manifest + meta + book.sqlite + attachments
- [ ] **Step 2:** `importBook(filePath)` — 校验 formatVersion,新 UUID,注册 meta,复制 sqlite
- [ ] **Step 3:** 名称冲突时追加后缀 `(2)`
- [ ] **Step 4:** UT `tests/main/pack.service.test.ts` — 导出再导入章节数一致
- [x] **Step 1:** `exportBook(bookId, destPath)` — ZIP: manifest + meta + book.sqlite + attachments
- [x] **Step 2:** `importBook(filePath)` — 校验 formatVersion,新 UUID,注册 meta,复制 sqlite
- [x] **Step 3:** 名称冲突时追加后缀 `(2)`
- [x] **Step 4:** UT `tests/main/pack.service.test.ts` — 导出再导入章节数一致
---
@@ -72,12 +72,12 @@
- Modify: `src/main/services/pack.service.ts`
- Modify: `src/shared/types.ts`
- [ ] **Step 1:** `exportAll(destPath)` — global_settings + books/{id}/
- [ ] **Step 2:** `importAll(filePath, strategy)` — skip/overwrite/new
- [ ] **Step 3:** `onProgress` 回调 + `PACK_PROGRESS` 广播
- [ ] **Step 4:** `estimateSize` + >500MB 确认标志
- [ ] **Step 5:** AbortController 取消支持
- [ ] **Step 6:** UT IT-ALL-02 — 3 书导出删库再导入
- [x] **Step 1:** `exportAll(destPath)` — global_settings + books/{id}/
- [x] **Step 2:** `importAll(filePath, strategy)` — skip/overwrite/new
- [x] **Step 3:** `onProgress` 回调 + `PACK_PROGRESS` 广播
- [x] **Step 4:** `estimateSize` + >500MB 确认标志
- [x] **Step 5:** AbortController 取消支持
- [x] **Step 6:** UT IT-ALL-02 — 3 书导出删库再导入
---
@@ -89,7 +89,7 @@
- Modify: `src/main/index.ts`
- Modify: `src/preload/index.ts``electron-api.d.ts`
- [ ] **Step 1:** IPC 常量与 handler 注册
- [x] **Step 1:** IPC 常量与 handler 注册
- [ ] **Step 2:** preload `pack.exportBook/importBook/exportAll/importAll/pickFile`
- [ ] **Step 3:** `onPackProgress` 事件订阅