blob: 15d85d323b0cfe0084ff6d4a984c3d0fbc38348d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// manage localStorage
const StorageKey = 'yacd.metacubex.one';
function loadState() {
try {
const serialized = localStorage.getItem(StorageKey);
if (!serialized) return undefined;
return JSON.parse(serialized);
} catch (err) {
return undefined;
}
}
function saveState(state) {
try {
const serialized = JSON.stringify(state);
localStorage.setItem(StorageKey, serialized);
} catch (err) {
// ignore
}
}
function clearState() {
try {
localStorage.removeItem(StorageKey);
} catch (err) {
// ignore
}
}
export { loadState, saveState, clearState };
|