fix(webui): sync file edit display preference

This commit is contained in:
chengyongru
2026-07-09 10:42:43 +08:00
committed by Xubin Ren
parent 7768672c5b
commit 6851a6ebd4
4 changed files with 69 additions and 7 deletions
+13
View File
@@ -11,6 +11,7 @@ export interface LocalPreferences {
}
export const LOCAL_PREFS_STORAGE_KEY = "nanobot-webui.settings-preferences";
export const LOCAL_PREFS_CHANGED_EVENT = "nanobot-webui.local-preferences-changed";
export const DEFAULT_LOCAL_PREFS: LocalPreferences = {
density: "comfortable",
@@ -40,3 +41,15 @@ export function readLocalPreferences(): LocalPreferences {
return DEFAULT_LOCAL_PREFS;
}
}
export function writeLocalPreferences(preferences: LocalPreferences): void {
try {
window.localStorage.setItem(LOCAL_PREFS_STORAGE_KEY, JSON.stringify(preferences));
} catch {
// Browser-only preferences should never block settings.
}
window.dispatchEvent(new CustomEvent<LocalPreferences>(
LOCAL_PREFS_CHANGED_EVENT,
{ detail: preferences },
));
}