platform detection type + func

This commit is contained in:
2024-12-23 13:35:56 -06:00
parent 4eeb9ddcef
commit 152635d7db

View File

@@ -9,3 +9,12 @@ export function cn(...inputs: ClassValue[]) {
export function plural(text: string, count: number) {
return `${text}${count === 1 ? "" : "s"}`;
}
export type Platform = "windows" | "mac" | "linux";
export function os(): Platform | "other" {
if (navigator.userAgent.includes("win")) return "windows";
else if (navigator.userAgent.includes("mac")) return "mac";
else if (navigator.userAgent.includes("linux")) return "linux";
return "other";
}