feat: 实现笔临 P0/P1 Electron 桌面应用 v0.1.0
交付写作核心(TipTap、自动保存、分卷分章)、Onboarding、7 主题与双语 i18n、快捷键设置;主进程使用 node:sqlite;补全 Vitest 与 Playwright E2E;统一 design/ 目录并移除 desigin 拼写错误路径。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import type { IpcError, IpcResult } from '@shared/types'
|
||||
|
||||
export class IpcCallError extends Error {
|
||||
ipcError: IpcError
|
||||
|
||||
constructor(ipcError: IpcError) {
|
||||
super(ipcError.message)
|
||||
this.name = 'IpcCallError'
|
||||
this.ipcError = ipcError
|
||||
}
|
||||
}
|
||||
|
||||
export async function ipcCall<T>(fn: () => Promise<IpcResult<T>>): Promise<T> {
|
||||
const result = await fn()
|
||||
if (!result.ok) throw new IpcCallError(result.error)
|
||||
return result.data
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { ThemeId } from '@shared/types'
|
||||
|
||||
export function applyTheme(theme: ThemeId): void {
|
||||
if (theme === 'default') {
|
||||
document.documentElement.removeAttribute('data-theme')
|
||||
} else {
|
||||
document.documentElement.setAttribute('data-theme', theme)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user