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:
2026-07-06 10:39:20 +08:00
parent a06038035b
commit 011bd6d4ca
70 changed files with 14245 additions and 84 deletions
+33
View File
@@ -0,0 +1,33 @@
import { create } from 'zustand'
import type { ThemeId, Language, GlobalSettings, ActionId } from '@shared/types'
import { ipcCall } from '@renderer/lib/ipc-client'
import { applyTheme } from '@renderer/lib/theme'
import i18n from '@renderer/i18n'
interface SettingsState extends GlobalSettings {
loaded: boolean
load: () => Promise<void>
update: (partial: Partial<GlobalSettings>) => Promise<void>
}
export const useSettingsStore = create<SettingsState>((set, get) => ({
penName: '未命名作者',
onboardingCompleted: false,
theme: 'default',
language: 'zh-CN',
dailyWordGoal: 0,
shortcuts: {} as Record<ActionId, string>,
loaded: false,
load: async () => {
const data = await ipcCall(() => window.electronAPI.settings.get())
set({ ...data, loaded: true })
applyTheme(data.theme)
await i18n.changeLanguage(data.language)
},
update: async (partial) => {
const data = await ipcCall(() => window.electronAPI.settings.update(partial))
set({ ...get(), ...data })
if (partial.theme) applyTheme(data.theme)
if (partial.language) await i18n.changeLanguage(data.language)
}
}))