(prefix = "")
| 58 | * 生成唯一 ID |
| 59 | */ |
| 60 | export function generateId(prefix = ""): string { |
| 61 | const timestamp = Date.now(); |
| 62 | const random = Math.random().toString(36).substring(2, 9); |
| 63 | return prefix ? `${prefix}-${timestamp}-${random}` : `${timestamp}-${random}`; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * 截断文本 |
no test coverage detected