hippofish/packages/client/src/scripts/device-kind.ts

16 lines
440 B
TypeScript
Raw Normal View History

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