1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-09-12 16:40:40 +08:00
Files
uni-halo/src/utils/uuid.ts
T
小莫唐尼 067f3ed98a 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语法
2026-08-31 19:56:16 +08:00

21 lines
560 B
TypeScript

/**
* UUID 生成工具(源自旧项目 utils/uuid.js,按需命名导出)
*/
/**
* 生成 UUID(v4)
*/
export function generateUUID(): string {
// 使用 crypto.randomUUID(部分平台支持),否则降级为时间戳+随机数
if (typeof crypto !== 'undefined' && 'randomUUID' in crypto) {
return crypto.randomUUID()
}
let uuid = ''
const timestamp = Date.now()
for (let i = 0; i < 32; i++) {
const r = (timestamp + Math.random() * 16) % 16 | 0
uuid += (i === 12 ? 4 : (i === 16 ? (r & 3) | 8 : r)).toString(16)
}
return uuid
}