You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
585 B
TypeScript
22 lines
585 B
TypeScript
// frontend/lib/tasks/store.ts — UI 상태만 localStorage 영속 (ari.tasks.*)
|
|
const PREFIX = "ari.tasks.";
|
|
|
|
export function loadLS<T>(key: string, fallback: T): T {
|
|
if (typeof window === "undefined") return fallback;
|
|
try {
|
|
const v = localStorage.getItem(PREFIX + key);
|
|
return v === null ? fallback : (JSON.parse(v) as T);
|
|
} catch {
|
|
return fallback;
|
|
}
|
|
}
|
|
|
|
export function saveLS<T>(key: string, value: T): void {
|
|
if (typeof window === "undefined") return;
|
|
try {
|
|
localStorage.setItem(PREFIX + key, JSON.stringify(value));
|
|
} catch {
|
|
/* quota */
|
|
}
|
|
}
|