当前位置: 首页 > news >正文

uniapp小程序获取手机设备安全距离

utils.js
 

let systemInfo = null;export const getSystemInfo = () => {if (!systemInfo) {systemInfo = uni.getSystemInfoSync();// 补充安全区域默认值systemInfo.safeAreaInsets = systemInfo.safeAreaInsets || {top: 0,bottom: 0,left: 0,right: 0};// 确保statusBarHeight存在(兼容旧版本)systemInfo.statusBarHeight = systemInfo.statusBarHeight || (systemInfo.platform === 'android' ? 25 : 20);}return systemInfo;
};// 获取状态栏高度(px)
export const getStatusBarHeight = () => getSystemInfo().statusBarHeight;// 获取iPhone底部下巴高度(px)
export const getIphoneBottomHeight = () => {const { platform, safeAreaInsets } = getSystemInfo();return platform === 'ios' ? safeAreaInsets.bottom : 0;
};// 是否全面屏设备
export const isNotchScreen = () => {const { model, statusBarHeight } = getSystemInfo();return statusBarHeight > 20 || /iphone x|iphone 1[1-5]/i.test(model);
};

import { getSystemInfo, getStatusBarHeight, getIphoneBottomHeight } from '@/utils/device';

  computed: {// 底部安全区域高度(单位:px)bottomSafeArea() {return getIphoneBottomHeight();},// 转换为rpx单位bottomSafeAreaRpx() {return this.bottomSafeArea * (750 / this.deviceInfo.windowWidth);}},created() {// 获取设备状态栏高度const { statusBarHeight } = uni.getSystemInfoSync();this.navBarHeight = statusBarHeight;},

http://www.xdnf.cn/news/522685.html

相关文章:

  • 中小实验室质检LIMS 系统选型 从成本管控到竞争力升级的黄金法则
  • 【MySQL】基础操作
  • 用户行为日志分析的常用架构
  • TCP和套接字SSL加密连接行为分析
  • 二分交互题总结
  • 深入探讨死区生成:原理、实现与应用
  • 词嵌入基础
  • 【Rust迭代器】Rust迭代器用法解析与应用实战
  • Python Django 的 ORM 编程思想及使用步骤
  • R语言数据可视化
  • Elasticsearch 深入分析三种分页查询【Elasticsearch 深度分页】
  • 力扣面试150题--从前序与中序遍历序列构造二叉树
  • Windows 下 Nginx 安装与配置指南 [特殊字符]
  • Axure难点解决分享:垂直菜单展开与收回(4大核心问题与专家级解决方案)
  • LeetCode 35 搜索插入位置题解
  • Axure设计数字乡村可视化大屏:构建乡村数据全景图
  • 【滑动窗口】LeetCode 1004题解 | 最大连续1的个数 Ⅲ
  • 小程序弹出层/抽屉封装 (抖音小程序)
  • CSS- 4.6 radiu、shadow、animation动画
  • CVE-2015-4553 Dedecms远程写文件
  • prisma连接非关系型数据库mongodb并简单使用
  • 【QT】类A和类B共用类C
  • 分布式数据库TiDB:深度解析原理、优化与架构设计
  • 永磁同步电机高性能控制算法(22)——基于神经网络的转矩脉动抑制算法为什么低速时的转速波动大?
  • 批量剪辑 + 矩阵分发 + 数字人分身源码搭建全技术解析,支持OEM
  • 【NLP】37. NLP中的众包
  • VR 互动实训与展示,借科技开启沉浸式体验新篇​
  • 【内测征集】LarkVR 播控系统上新:VR 应用一站式专业播控与管理工具
  • 基于CATIA参数化圆锥建模的自动化插件开发实践——NX建模之圆锥体命令的参考与移植(一)
  • Python函数——万字详解