siteFront/utils/storage.ts

46 lines
807 B
TypeScript
Raw Normal View History

2024-11-05 10:09:18 +08:00
/**
* @description
*/
export default {
/**
*
* @param key
* @param value
*/
set(key: string, value: any) {
uni.setStorageSync(key, value)
},
/**
*
* @param key
* @returns
*/
get(key: string) {
try {
const value = uni.getStorageSync(key)
if (!value) return
return value
} catch (e) {
console.error('获取数据缓存失败', e)
return
}
},
/**
*
* @param key
*/
remove(key: string) {
uni.removeStorageSync(key)
},
/**
*
*/
clear() {
uni.clearStorageSync()
},
}