mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
- Add backendPersist Pinia plugin for declarative preferences.json persistence - Move Preferences types to @openchatlab/shared-types (single source of truth) - Migrate sessionGapThreshold from localStorage to config.toml [ui] - Migrate chatlab_filter_history from localStorage to preferences.json - Fix stale localStorage locale read in i18n/index.ts - Simplify usePreferencesSync (172 → 75 lines) by delegating to plugin Adding a new backend-synced preference now only requires 3 changes: 1. shared-types interface 2. node-runtime DEFAULTS 3. store backendPersist.pick
31 lines
916 B
TypeScript
31 lines
916 B
TypeScript
/**
|
|
* Preferences Preload API
|
|
*/
|
|
import { ipcRenderer } from 'electron'
|
|
|
|
export const preferencesApi = {
|
|
get: (): Promise<Record<string, unknown>> => {
|
|
return ipcRenderer.invoke('preferences:get')
|
|
},
|
|
|
|
save: (partial: Record<string, unknown>): Promise<{ success: boolean; error?: string }> => {
|
|
return ipcRenderer.invoke('preferences:save', partial)
|
|
},
|
|
|
|
getUiConfig: (): Promise<Record<string, unknown>> => {
|
|
return ipcRenderer.invoke('preferences:getUiConfig')
|
|
},
|
|
|
|
saveUiConfig: (partial: Record<string, unknown>): Promise<{ success: boolean; error?: string }> => {
|
|
return ipcRenderer.invoke('preferences:saveUiConfig', partial)
|
|
},
|
|
|
|
getLocale: (): Promise<string> => {
|
|
return ipcRenderer.invoke('preferences:getLocale')
|
|
},
|
|
|
|
saveLocale: (lang: string): Promise<{ success: boolean; error?: string }> => {
|
|
return ipcRenderer.invoke('preferences:saveLocale', lang)
|
|
},
|
|
}
|