1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-16 23:58:14 +09:00
hotomoe/packages/client/src/scripts/device-kind.ts

11 lines
429 B
TypeScript
Raw Normal View History

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';