对接评价模板新增和修改

This commit is contained in:
linxd
2025-06-23 20:29:01 +08:00
parent b9bbc906bf
commit 9eb1bed092
7 changed files with 664 additions and 124 deletions

View File

@ -32,3 +32,37 @@ export const validateFileSize = (file: File, maxSize: number,type: string[]) =>
}
return isValidFormat && isLtMaxSize;
};
// 生成固定位数的 UUID
export const generateUUID = (length: number) => {
// 使用更复杂的字符集
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
// 使用加密安全的随机数生成(如果可用)
let array;
if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
array = new Uint8Array(length);
window.crypto.getRandomValues(array);
} else {
array = new Uint8Array(length);
for (let i = 0; i < length; i++) {
array[i] = Math.floor(Math.random() * 256);
}
}
// 生成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;
};