detectAppSafeAreaProfile
检测应用 safe-area 配置档:Capacitor 原生 / 移动浏览器 / 桌面。
前置依赖
依赖参数
| 参数名 | 类型 | 说明 |
|---|---|---|
deps.isCapacitorNativePlatform | () => boolean | 是否 Capacitor 原生 |
deps.userAgent | Navigator['userAgent'] | UA 字符串 |
deps.hasTouch | boolean | 是否支持触摸 |
deps.innerWidth | Window['innerWidth'] | 视口宽度 |
函数签名
typescript
function detectAppSafeAreaProfile(
deps: DetectAppSafeAreaProfileDeps,
): AppSafeAreaProfile
function isStandaloneMobileDisplay(
deps: IsStandaloneMobileDisplayDeps,
): boolean参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
deps | DetectAppSafeAreaProfileDeps | 是 | 环境探测依赖 |
返回值
| 类型 | 说明 |
|---|---|
AppSafeAreaProfile | 'capacitor-native' | 'mobile-browser' | 'desktop' |
工作原理
- Capacitor 原生优先返回
capacitor-native。 - Electron UA 或桌面视口返回
desktop。 - 移动 UA + 触摸 + 窄视口返回
mobile-browser,否则desktop。