upload project source code
This commit is contained in:
20
前端源码/uni-app/utils/device-layout.ts
Normal file
20
前端源码/uni-app/utils/device-layout.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 判断当前环境是否使用「电脑端网页」布局(/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;
|
||||
}
|
||||
Reference in New Issue
Block a user