| export interface AppSettings { |
| showRouteList: boolean; |
| customApiBase: string; |
| autoDevToken: boolean; |
| } |
|
|
| export const DEFAULT_SETTINGS: AppSettings = { |
| showRouteList: true, |
| customApiBase: "", |
| autoDevToken: true, |
| }; |
|
|
| const STORAGE_KEY = "saas-app-settings"; |
|
|
| export function loadSettings(): AppSettings { |
| if (typeof window === "undefined") return DEFAULT_SETTINGS; |
| try { |
| const raw = window.localStorage.getItem(STORAGE_KEY); |
| if (!raw) return DEFAULT_SETTINGS; |
| const parsed = JSON.parse(raw) as Partial<AppSettings>; |
| return { |
| ...DEFAULT_SETTINGS, |
| ...parsed, |
| }; |
| } catch { |
| return DEFAULT_SETTINGS; |
| } |
| } |
|
|
| export function saveSettings(settings: AppSettings) { |
| if (typeof window === "undefined") return; |
| window.localStorage.setItem(STORAGE_KEY, JSON.stringify(settings)); |
| } |
|
|