//获取sessionStorage存储数据
export const getCache = name => {
if (!name) return
return window.sessionStorage.getItem(name)
}
//设置sessionStorage存储数据
export const setCache = (name, content) => {
if (!name) return
if (typeof content !== 'string') {
content = JSON.stringify(content)
}
window.sessionStorage.setItem(name, content)
}
//删除sessionStorage存储数据
export const removeCache = (name) => {
if (!name) return
window.sessionStorage.removeItem(name)
}
//获取localStorage存储数据
if (!name) return
return window.localStorage.getItem(name)
}
//设置localStorage存储数据
export const set_local_cache = (name, content) => {
if (!name) return
if (typeof content !== 'string') {
content = JSON.stringify(content)
}
window.localStorage.setItem(name, content)
}
//删除localStorage存储数据
export const remove_local_cache = (name) => {
if (!name) return
window.localStorage.removeItem(name)
}
网友评论