refactor(frontend): 動画UIのフルスクリーン周りの調整 (#14877)
* refactor(frontend): フルスクリーン周りの調整 (cherry picked from commit 783032caec5853d78d5af3391e29cf364f2282e8) * refactor(frontend): deviceKindの循環参照を除去 (cherry picked from commit 1ca471f57e968a1a6e2259bde4a7c6da1fe0c54e) * fix --------- Co-authored-by: taiyme <53635909+taiyme@users.noreply.github.com>
This commit is contained in:
parent
a4c5ce1413
commit
3a421837bf
5 changed files with 88 additions and 40 deletions
|
|
@ -3,22 +3,22 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { defaultStore } from '@/store.js';
|
||||
|
||||
await defaultStore.ready;
|
||||
export type DeviceKind = 'smartphone' | 'tablet' | 'desktop';
|
||||
|
||||
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);
|
||||
|
||||
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 DEFAULT_DEVICE_KIND: DeviceKind = (
|
||||
isSmartphone
|
||||
? 'smartphone'
|
||||
: isTablet
|
||||
? 'tablet'
|
||||
: 'desktop'
|
||||
);
|
||||
|
||||
export const isFullscreenNotSupported = isIPhone || isIos;
|
||||
export let deviceKind: DeviceKind = DEFAULT_DEVICE_KIND;
|
||||
|
||||
export const deviceKind: 'smartphone' | 'tablet' | 'desktop' = defaultStore.state.overridedDeviceKind ? defaultStore.state.overridedDeviceKind
|
||||
: isSmartphone ? 'smartphone'
|
||||
: isTablet ? 'tablet'
|
||||
: 'desktop';
|
||||
export function updateDeviceKind(kind: DeviceKind | null) {
|
||||
deviceKind = kind ?? DEFAULT_DEVICE_KIND;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue