上传头像

This commit is contained in:
pengxiaolong
2025-05-20 19:09:04 +08:00
parent 6107739077
commit 829199a197
34 changed files with 4902 additions and 233 deletions

View File

@@ -0,0 +1,19 @@
// 生成 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;
}
// 生成文件名
function generateFileName() {
const randomPart = generateRandomString();
const timestamp = Date.now(); // 当前时间戳(毫秒级)
return `${randomPart}${timestamp}.jpg`;
}
export default generateFileName;