提交一下 换git仓库了

This commit is contained in:
linxd
2025-06-23 21:39:51 +08:00
parent 9eb1bed092
commit c74aefb93d
11 changed files with 741 additions and 672 deletions

View File

@ -38,31 +38,28 @@ export const validateFileSize = (file: File, maxSize: number,type: string[]) =>
export const generateUUID = (length: number) => {
// 使用更复杂的字符集
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
// 使用加密安全的随机数生成(如果可用)
let array;
// 使用加密安全的随机数生成
let result = '';
// 添加时间戳前缀,确保唯一性
const timestamp = Date.now().toString(36);
result += timestamp.substring(timestamp.length - Math.min(6, length / 4));
// 获取随机字符
const randomPart = [];
if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
array = new Uint8Array(length);
const array = new Uint8Array(length);
window.crypto.getRandomValues(array);
for (let i = 0; i < length - result.length; i++) {
randomPart.push(characters.charAt(array[i] % charactersLength));
}
} else {
array = new Uint8Array(length);
for (let i = 0; i < length; i++) {
array[i] = Math.floor(Math.random() * 256);
for (let i = 0; i < length - result.length; i++) {
randomPart.push(characters.charAt(Math.floor(Math.random() * charactersLength)));
}
}
// 生成UUID
const timestamp = Date.now().toString(36);
let result = '';
// 添加时间戳前缀最多6个字符
result += timestamp.substring(timestamp.length - Math.min(6, length / 3));
// 添加随机字符
for (let i = 0; i < length - result.length; i++) {
const randomIndex = array[i % array.length] % characters.length;
result += characters.charAt(randomIndex);
}
return result;
return result + randomPart.join('');
};