Files
----/前端源码/uni-app/utils/device-layout.ts

21 lines
582 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 判断当前环境是否使用「电脑端网页」布局(/test-name-live 等页面)。
* - 典型手机 UA始终视为手机端
* - 其余:视口宽度 >= 992px 为电脑端,否则为手机端(含平板竖屏、窄窗口)
*/
export function getIsDesktopLayout(): boolean {
if (typeof window === 'undefined') {
return true;
}
const ua = navigator.userAgent || '';
const isPhoneUA =
/iPhone|iPod|Android.*Mobile|webOS|BlackBerry|IEMobile|Opera Mini/i.test(ua);
if (isPhoneUA) {
return false;
}
return window.innerWidth >= 992;
}