优化页面
This commit is contained in:
18
components/generateMsgId.js
Normal file
18
components/generateMsgId.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// 生成 6位随机字符(包含大小写字母和数字)
|
||||
function generateRandomString(length = 6) {
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += chars[Math.floor(Math.random() * chars.length)];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//自定义消息id
|
||||
function generateMsgId() {
|
||||
const randomPart = generateRandomString();
|
||||
const timestamp = Date.now(); // 当前时间戳(毫秒级)
|
||||
return `${randomPart}${timestamp}`;
|
||||
}
|
||||
export default generateMsgId;
|
||||
|
||||
Reference in New Issue
Block a user