011bd6d4ca
交付写作核心(TipTap、自动保存、分卷分章)、Onboarding、7 主题与双语 i18n、快捷键设置;主进程使用 node:sqlite;补全 Vitest 与 Playwright E2E;统一 design/ 目录并移除 desigin 拼写错误路径。 Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { ipcMain } from 'electron'
|
|
import { IPC } from '../../../shared/ipc-channels'
|
|
import type { BookMeta, CreateBookParams } from '../../../shared/types'
|
|
import { BookRegistryService } from '../../services/book-registry'
|
|
import { wrap } from '../result'
|
|
|
|
export function registerBookHandlers(registry: BookRegistryService): void {
|
|
ipcMain.handle(IPC.BOOK_LIST, () => wrap(() => registry.list()))
|
|
|
|
ipcMain.handle(IPC.BOOK_CREATE, (_event, params: CreateBookParams) =>
|
|
wrap(() => registry.create(params))
|
|
)
|
|
|
|
ipcMain.handle(IPC.BOOK_DELETE, (_event, { bookId }: { bookId: string }) =>
|
|
wrap(() => {
|
|
registry.delete(bookId)
|
|
})
|
|
)
|
|
|
|
ipcMain.handle(IPC.BOOK_OPEN, (_event, { bookId }: { bookId: string }) =>
|
|
wrap(() => registry.open(bookId))
|
|
)
|
|
|
|
ipcMain.handle(
|
|
IPC.BOOK_UPDATE_META,
|
|
(
|
|
_event,
|
|
{
|
|
bookId,
|
|
...patch
|
|
}: {
|
|
bookId: string
|
|
lastChapterId?: string | null
|
|
lastOpenedAt?: string
|
|
status?: BookMeta['status']
|
|
}
|
|
) => wrap(() => registry.updateMeta(bookId, patch))
|
|
)
|
|
}
|