import type { AgentThreadContext } from "../threads"; export const DEFAULT_LOCAL_SETTINGS: LocalSettings = { notification: { enabled: true, }, context: { model_name: undefined, mode: undefined, reasoning_effort: undefined, }, layout: { sidebar_collapsed: false, }, }; const LOCAL_SETTINGS_KEY = "deerflow.local-settings"; export interface LocalSettings { notification: { enabled: boolean; }; context: Omit< AgentThreadContext, "thread_id" | "is_plan_mode" | "thinking_enabled" | "subagent_enabled" > & { mode: "flash" | "thinking" | "pro" | "ultra" | undefined; reasoning_effort?: "minimal" | "low" | "medium" | "high"; }; layout: { sidebar_collapsed: boolean; }; } export function getLocalSettings(): LocalSettings { if (typeof window === "undefined") { return DEFAULT_LOCAL_SETTINGS; } const json = localStorage.getItem(LOCAL_SETTINGS_KEY); try { if (json) { const settings = JSON.parse(json); const mergedSettings = { ...DEFAULT_LOCAL_SETTINGS, context: { ...DEFAULT_LOCAL_SETTINGS.context, ...settings.context, }, layout: { ...DEFAULT_LOCAL_SETTINGS.layout, ...settings.layout, }, notification: { ...DEFAULT_LOCAL_SETTINGS.notification, ...settings.notification, }, }; return mergedSettings; } } catch {} return DEFAULT_LOCAL_SETTINGS; } export function saveLocalSettings(settings: LocalSettings) { void settings; // 注释了,因为本地存储会污染模型配置 console.log("localStorage设置,已经注释"); localStorage.removeItem(LOCAL_SETTINGS_KEY); // localStorage.setItem(LOCAL_SETTINGS_KEY, JSON.stringify(settings)); }