2023-07-27 14:31:52 +09:00
|
|
|
/*
|
2024-02-14 00:59:27 +09:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 14:31:52 +09:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-09-19 16:37:43 +09:00
|
|
|
import { defaultStore } from '@/store.js';
|
2022-02-08 18:46:39 +09:00
|
|
|
|
2023-02-02 16:43:56 +09:00
|
|
|
await defaultStore.ready;
|
|
|
|
|
2022-02-08 18:46:39 +09:00
|
|
|
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);
|
|
|
|
|
2024-01-15 18:17:01 +09:00
|
|
|
const isIPhone = /iphone|ipod/gi.test(ua) && navigator.maxTouchPoints > 1;
|
|
|
|
// navigator.platform may be deprecated but this check is still required
|
|
|
|
const isIPadOS = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
|
|
|
|
const isIos = /ipad|iphone|ipod/gi.test(ua) && navigator.maxTouchPoints > 1;
|
|
|
|
|
|
|
|
export const isFullscreenNotSupported = isIPhone || isIos;
|
|
|
|
|
2023-01-27 11:16:22 +09:00
|
|
|
export const deviceKind: 'smartphone' | 'tablet' | 'desktop' = defaultStore.state.overridedDeviceKind ? defaultStore.state.overridedDeviceKind
|
2022-02-08 18:46:39 +09:00
|
|
|
: isSmartphone ? 'smartphone'
|
|
|
|
: isTablet ? 'tablet'
|
|
|
|
: 'desktop';
|