Files
deer-flow/frontend/src/core/settings/local.ts

51 lines
1.2 KiB
TypeScript
Raw Normal View History

2026-01-16 09:55:02 +08:00
import type { AgentThreadContext } from "../threads";
export const DEFAULT_LOCAL_SETTINGS: LocalSettings = {
context: {
2026-01-16 14:03:34 +08:00
model_name: "deepseek-v3.2",
2026-01-16 09:55:02 +08:00
thinking_enabled: true,
2026-01-22 13:46:43 +08:00
is_plan_mode: false,
2026-01-16 09:55:02 +08:00
},
2026-01-16 23:03:39 +08:00
layout: {
sidebar_collapsed: false,
},
2026-01-16 09:55:02 +08:00
};
const LOCAL_SETTINGS_KEY = "deerflow.local-settings";
export interface LocalSettings {
context: Omit<AgentThreadContext, "thread_id">;
2026-01-16 23:03:39 +08:00
layout: {
sidebar_collapsed: boolean;
};
2026-01-16 09:55:02 +08:00
}
export function getLocalSettings(): LocalSettings {
if (typeof window === "undefined") {
return DEFAULT_LOCAL_SETTINGS;
}
const json = localStorage.getItem(LOCAL_SETTINGS_KEY);
try {
if (json) {
2026-01-16 23:03:39 +08:00
const settings = JSON.parse(json);
2026-01-22 00:26:11 +08:00
const mergedSettings = {
2026-01-16 23:03:39 +08:00
...DEFAULT_LOCAL_SETTINGS,
2026-01-22 00:26:11 +08:00
context: {
...DEFAULT_LOCAL_SETTINGS.context,
...settings.context,
},
layout: {
...DEFAULT_LOCAL_SETTINGS.layout,
...settings.layout,
},
2026-01-16 23:03:39 +08:00
};
2026-01-22 00:26:11 +08:00
return mergedSettings;
2026-01-16 09:55:02 +08:00
}
} catch {}
return DEFAULT_LOCAL_SETTINGS;
}
export function saveLocalSettings(settings: LocalSettings) {
localStorage.setItem(LOCAL_SETTINGS_KEY, JSON.stringify(settings));
}