Files
bilin/src/renderer/stores/useSettingsStore.ts
T
bing aa2c7dfed3 feat: ship v0.7.0 with AI knowledge context integration
Add semi-automatic knowledge suggestions and user-confirmed injection across chat, interactive, auto, and wizard modes; fix writing flows to persist full systemPrompt in contextJson.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 15:33:53 +08:00

41 lines
1.3 KiB
TypeScript

import { create } from 'zustand'
import type { ThemeId, Language, GlobalSettings, ActionId } from '@shared/types'
import { DEFAULT_AI_CONFIG } 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,
updateSchedule: 'none',
stockBufferThreshold: 3,
shortcuts: {} as Record<ActionId, string>,
aiConfig: { ...DEFAULT_AI_CONFIG },
namingIgnoreWords: [] as string[],
knowledgeAutoSuggest: true,
knowledgeSuggestTopN: 8,
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)
}
}))