iceshrimp/packages/client/src/scripts/device-kind.ts
ThatOneCalculator 2aab2de38d refactor: 🎨 rome
2023-01-12 20:40:33 -08:00

16 lines
434 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";