feat(id): replace crypto.randomUUID with nanoid for unique ID generation

This commit is contained in:
HouYunFei
2026-07-15 11:55:36 +08:00
parent a4dcc679c9
commit ee8f126da7
5 changed files with 24 additions and 4 deletions
+12
View File
@@ -1,6 +1,18 @@
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
import { nanoid } from "nanoid";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
/**
* Generate a unique id.
*
* Avoid `crypto.randomUUID`, which is only exposed in secure contexts (HTTPS or
* localhost) — over plain HTTP it is undefined and throws. `nanoid` works in any
* context.
*/
export function randomId(): string {
return nanoid();
}