export function set<T extends string | number | boolean>(key: string, val: T) {
switch (typeof val) {
case 'number':
localStorage.setItem(key, val.toString())
break
case 'string':
localStorage.setItem(key, val)
case 'boolean':
localStorage.setItem(key, val ? '1' : '0')
}
export function get<T extends string | number | boolean>(key: string, def: T): T {
const store = localStorage.getItem(key)
if (store) {
switch (typeof def) {
return parseInt(store) as T
return store as T
return (store === '1') as T
default:
return def