feat: 生成的唯一消息id 优化

This commit is contained in:
2025-09-15 20:00:28 +08:00
parent 1038dd3180
commit 66c256cefd
2 changed files with 7 additions and 2 deletions

View File

@@ -13,7 +13,12 @@ export class IdUtils {
* @returns {string} 消息ID
*/
static generateMessageId() {
return "mid" + new Date().getTime();
const timestamp = new Date().getTime();
const chars = "abcdefghijklmnopqrstuvwxyz";
const randomStr = Array.from({ length: 4 }, () =>
chars.charAt(Math.floor(Math.random() * chars.length))
).join("");
return "mid"+ randomStr + timestamp;
}
}