|
|
@@ -32,51 +32,7 @@ export const showToast = (title, icon = 'none', duration = 2000) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 缓存工具类
|
|
|
- */
|
|
|
-export const storage = {
|
|
|
- /**
|
|
|
- * 设置缓存
|
|
|
- * @param {string} key - 缓存键
|
|
|
- * @param {any} value - 缓存值
|
|
|
- */
|
|
|
- set(key, value) {
|
|
|
- if (typeof value === 'object') {
|
|
|
- value = JSON.stringify(value)
|
|
|
- }
|
|
|
- uni.setStorageSync(key, value)
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取缓存
|
|
|
- * @param {string} key - 缓存键
|
|
|
- * @returns {any} 缓存值
|
|
|
- */
|
|
|
- get(key) {
|
|
|
- const value = uni.getStorageSync(key)
|
|
|
- try {
|
|
|
- return JSON.parse(value)
|
|
|
- } catch (e) {
|
|
|
- return value
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除缓存
|
|
|
- * @param {string} key - 缓存键
|
|
|
- */
|
|
|
- remove(key) {
|
|
|
- uni.removeStorageSync(key)
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 清空缓存
|
|
|
- */
|
|
|
- clear() {
|
|
|
- uni.clearStorageSync()
|
|
|
- }
|
|
|
-}
|
|
|
+export { storage } from './storage.js'
|
|
|
|
|
|
/**
|
|
|
* 时间格式化
|