1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-09-12 16:40:40 +08:00

chore: 批量新增项目依赖、工具函数、页面与组件资源

1. 新增mp-html、qs等生产依赖,补全项目基础库
2. 新增平台判断、缓存、工具函数等通用工具集
3. 新增标签页、网站浏览页、关于页等业务页面
4. 新增分类卡片、通知弹窗等业务组件
5. 新增uts-progressNotification、liu-poster、uhalo-upgrade等uni模块
6. 补充audio/video组件样式补件,修复uni-components路径缺失问题
7. 新增环境变量Halo个人令牌配置项
8. 重构store导出结构,新增appConfig/halo/setting三个状态模块
9. 新增tsconfig编译目标配置,适配更高版本ES语法
This commit is contained in:
小莫唐尼
2026-08-31 19:56:16 +08:00
parent ba5b77568b
commit 067f3ed98a
147 changed files with 20866 additions and 325 deletions
+55
View File
@@ -0,0 +1,55 @@
/**
* 通用缓存(带过期时间)
* 源自旧项目 utils/storage.js,按需命名导出
*/
interface ICacheItem<T> {
data: T
/** 存储时间戳(秒) */
time: number
/** 过期时间(秒),0 表示永久有效 */
expire: number
}
/**
* 设置缓存
* @param key 缓存 key
* @param value 存储值
* @param expire 过期时间(秒),默认 0 永久有效
*/
export function setCache<T>(key: string, value: T, expire = 0): void {
const obj: ICacheItem<T> = {
data: value,
time: Date.now() / 1000,
expire,
}
uni.setStorageSync(key, JSON.stringify(obj))
}
/**
* 获取缓存,过期自动清除并返回 null
*/
export function getCache<T>(key: string): T | null {
const val = uni.getStorageSync(key)
if (!val)
return null
let item: ICacheItem<T>
try {
item = JSON.parse(val)
}
catch {
return null
}
if (item.expire && Date.now() / 1000 - item.time > item.expire) {
uni.removeStorageSync(key)
return null
}
return item.data
}
/**
* 删除缓存
*/
export function delCache(key: string): void {
uni.removeStorageSync(key)
}