hippofish/packages/client/src/scripts/device-kind.ts
Nyan Helsing a98a26e901 chore: format
Co-authored-by: deathg.rip <josh@deathg.rip>
2024-03-28 05:25:33 +00:00

15 lines
440 B
TypeScript

import { defaultStore } from "@/store";
const ua = navigator.userAgent.toLowerCase();
const isTablet =
/ipad/.test(ua) ||
(/mobile|iphone|android/.test(ua) && window.innerWidth > 700);
const isSmartphone = !isTablet && /mobile|iphone|android/.test(ua);
export const deviceKind = defaultStore.state.overridedDeviceKind
? defaultStore.state.overridedDeviceKind
: isSmartphone
? "smartphone"
: isTablet
? "tablet"
: "desktop";