Spaces:
Runtime error
Runtime error
File size: 583 Bytes
13095e0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import { Settings } from '@/types/settings';
const STORAGE_KEY = 'settings';
export const getSettings = (): Settings => {
let settings: Settings = {
theme: 'dark',
};
const settingsJson = localStorage.getItem(STORAGE_KEY);
if (settingsJson) {
try {
let savedSettings = JSON.parse(settingsJson) as Settings;
settings = Object.assign(settings, savedSettings);
} catch (e) {
console.error(e);
}
}
return settings;
};
export const saveSettings = (settings: Settings) => {
localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));
};
|