const ls = window.localStorage const ss = window.sessionStorage export const Local = { get(key, def) { let value = null try { value = JSON.parse(ls.getItem(key)) } catch (e) { console.log(" ") } return value == null && def != null ? def : value }, set(key, val) { try { const setting = arguments[0] if (Object.prototype.toString.call(setting).slice(8, -1) === "Object") { for (const i in setting) { ls.setItem(i, JSON.stringify(setting[i])) } } else { ls.setItem(key, JSON.stringify(val)) } } catch (e) { console.log("'") } }, remove(key) { ls.removeItem(key) }, clear() { ls.clear() }, } export const Session = { get(key) { try { return JSON.parse(ss.getItem(key)) } catch (e) { return null } }, set(key, val) { const setting = arguments[0] if (Object.prototype.toString.call(setting).slice(8, -1) === "Object") { for (const i in setting) { ss.setItem(i, JSON.stringify(setting[i])) } } else { ss.setItem(key, JSON.stringify(val)) } }, remove(key) { ss.removeItem(key) }, clear() { ss.clear() }, }