added refresh token
This commit is contained in:
@@ -5,8 +5,17 @@ import { getImageUrl } from "../config/authConstants";
|
||||
const MAX_SIZE_MB = 5;
|
||||
export const ACCEPT = "image/jpeg,image/png,image/webp";
|
||||
|
||||
let idCounter = 0;
|
||||
const nextId = () => `img-${++idCounter}-${Date.now()}`;
|
||||
/**
|
||||
* Генератор уникального id для превью изображения.
|
||||
* crypto.randomUUID доступен во всех современных браузерах;
|
||||
* для страховки — fallback на timestamp + random.
|
||||
*/
|
||||
function generateImageId() {
|
||||
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
||||
return `img-${crypto.randomUUID()}`;
|
||||
}
|
||||
return `img-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
||||
}
|
||||
|
||||
export function useImageUpload(existingUrls = []) {
|
||||
const [images, setImages] = useState([]);
|
||||
@@ -49,7 +58,7 @@ export function useImageUpload(existingUrls = []) {
|
||||
try {
|
||||
const compressedFiles = await Promise.all(files.map(f => compressImage(f)));
|
||||
const newImages = compressedFiles.map(file => ({
|
||||
id: nextId(),
|
||||
id: generateImageId(),
|
||||
file,
|
||||
preview: URL.createObjectURL(file),
|
||||
isExisting: false,
|
||||
@@ -103,4 +112,4 @@ export function useImageUpload(existingUrls = []) {
|
||||
getFilesForUpload,
|
||||
getExistingUrlsToKeep,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user