Migrate to native Node.js file access and improve UI

This commit is contained in:
proteriax
2021-11-08 02:59:58 -05:00
parent 06e29eaba1
commit eb27e81d68
21 changed files with 472 additions and 156 deletions

View File

@ -0,0 +1,26 @@
export const enum Key {
LAST_VAULT_PATH = "lastVaultPath",
}
interface StoredData {
[Key.LAST_VAULT_PATH]: string
}
export function get<K extends keyof StoredData>(key: K) {
try {
const value = localStorage.getItem(key)
return value == null ? undefined : (JSON.parse(value!) as StoredData[K])
} catch {}
}
export function set<K extends keyof StoredData>(key: K, value: StoredData[K]) {
try {
localStorage.setItem(key, JSON.stringify(value))
} catch {}
}
export function remove(key: keyof StoredData) {
try {
localStorage.removeItem(key)
} catch {}
}