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

16 lines
434 B
TypeScript
Raw Normal View History

2023-01-13 13:40:33 +09:00
import { defaultStore } from "@/store";
const ua = navigator.userAgent.toLowerCase();
2023-01-13 13:40:33 +09: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 13:40:33 +09:00
export const deviceKind = defaultStore.state.overridedDeviceKind
? defaultStore.state.overridedDeviceKind
: isSmartphone
? "smartphone"
: isTablet
? "tablet"
: "desktop";