mirror of
https://github.com/neosubhamoy/neodlp-website.git
synced 2026-02-04 13:22:23 +05:30
(chore): initial MVP release
This commit is contained in:
30
src/lib/utils.ts
Normal file
30
src/lib/utils.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import type { OS } from "@/types/os";
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
export function getOS(): OS {
|
||||
const userAgent = window.navigator.userAgent;
|
||||
const platform = (window.navigator as any)?.userAgentData?.platform || window.navigator.platform;
|
||||
|
||||
const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K', 'macOS'];
|
||||
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
|
||||
const iosPlatforms = ['iPhone', 'iPad', 'iPod'];
|
||||
|
||||
if (macosPlatforms.includes(platform)) {
|
||||
return 'macos';
|
||||
} else if (iosPlatforms.includes(platform)) {
|
||||
return 'ios';
|
||||
} else if (windowsPlatforms.includes(platform)) {
|
||||
return 'windows';
|
||||
} else if (/Android/.test(userAgent)) {
|
||||
return 'android';
|
||||
} else if (/Linux/.test(platform)) {
|
||||
return 'linux';
|
||||
} else {
|
||||
return 'unknown';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user