mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-20 18:05:53 +08:00
commit message
This commit is contained in:
30
manager/src/libs/storage.js
Normal file
30
manager/src/libs/storage.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 存储localStorage
|
||||
*/
|
||||
export const setStore = (name, content) => {
|
||||
if (!name) return;
|
||||
if (typeof content !== 'string') {
|
||||
content = JSON.stringify(content);
|
||||
}
|
||||
window.localStorage.setItem(name, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取localStorage
|
||||
*/
|
||||
export const getStore = name => {
|
||||
if (!name) return;
|
||||
let v = window.localStorage.getItem(name);
|
||||
if (v == null) {
|
||||
return "";
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除localStorage
|
||||
*/
|
||||
export const removeStore = name => {
|
||||
if (!name) return;
|
||||
window.localStorage.removeItem(name);
|
||||
}
|
||||
Reference in New Issue
Block a user