feat: ship v1.1.0 writer toolkit with templates, import, export, and inspiration capture

Implement chapter templates, txt/md/docx import, submission export presets, and global inspiration shortcut. Split import handlers into a separate main bundle and fix EditorLayout setTarget loop that broke E2E.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-08 13:53:22 +08:00
parent ea4819847f
commit adf877861d
49 changed files with 2450 additions and 87 deletions
+47
View File
@@ -0,0 +1,47 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
import { readFileSync, mkdtempSync, rmSync } from 'fs'
import { join } from 'path'
import { tmpdir } from 'os'
import { BookRegistryService } from '../../src/main/services/book-registry'
import { splitPlainText } from '../../src/main/lib/chapter-splitter'
import { VolumeRepository } from '../../src/main/db/repositories/volume.repo'
import { ChapterRepository } from '../../src/main/db/repositories/chapter.repo'
import { closeAllBookDbs } from '../../src/main/db/connection'
const FIXTURE = join(import.meta.dirname, '../fixtures/import-three-chapters.txt')
describe('Import integration', () => {
let dir: string
let registry: BookRegistryService
beforeEach(() => {
dir = mkdtempSync(join(tmpdir(), 'bilin-import-'))
registry = new BookRegistryService(dir)
})
afterEach(() => {
closeAllBookDbs()
rmSync(dir, { recursive: true, force: true })
})
it('IT-IMPORT-01: split + create book chapters', () => {
const parts = splitPlainText(readFileSync(FIXTURE, 'utf8'), 'auto')
expect(parts).toHaveLength(3)
const meta = registry.create({
name: '导入测试书',
category: '玄幻',
createSampleChapter: false
})
const db = registry.getDb(meta.id)
const volId = new VolumeRepository(db).list()[0]!.id
const chapterRepo = new ChapterRepository(db)
parts.forEach((p, i) => {
chapterRepo.create(volId, p.title, i, `<p>${p.body}</p>`)
})
const opened = registry.open(meta.id)
expect(opened.chapters).toHaveLength(3)
expect(opened.chapters[0]!.title).toContain('第一章')
})
})