UNPKG

my-uniapp-tools

Version:

一个功能强大、性能优化的 uni-app 开发工具库,提供剪贴板、本地存储、导航、系统信息等常用功能

95 lines (94 loc) 3.43 kB
/** * 系统信息相关工具函数(优化版本) */ /** * 获取窗口信息(优化版本) * @param useCache 是否使用缓存,默认true * @returns 窗口信息对象,包含窗口尺寸、像素比等信息 * @description 调用 uni.getWindowInfo() 获取当前设备的窗口相关信息,支持缓存 */ export declare const useWindowInfo: (useCache?: boolean) => any; /** * 获取当前运行平台 * @returns 平台类型字符串 ('weixin' | 'web' | 'app' | 'alipay' | 'h5') * @description 通过条件编译判断当前代码运行的平台环境 */ export declare const getPlatform: () => string; /** * 获取小程序账户信息 * @returns 小程序账户信息对象,包含appId、版本、环境等信息 * @description 调用 uni.getAccountInfoSync() 获取当前小程序的账户相关信息 */ export declare const getCurrentEnv: () => { appId: string; version: string; envVersion: "develop" | "trial" | "release"; accountInfo: UniApp.AccountInfo; } | { appId: string; version: string; envVersion: string; accountInfo: null; }; /** * 检查小程序版本更新 * @description 检查小程序是否有新版本,如果有则提示用户更新并重启应用 * @returns void * @example * // 在App.vue的onLaunch或onShow中调用 * onCheckForUpdate() */ export declare const onCheckForUpdate: () => void; /** * 获取状态栏高度 * @returns 状态栏高度(单位:px) * @description 获取设备状态栏的高度,用于适配不同设备的状态栏 */ export declare const getStatusBarHeight: () => number; /** * 获取菜单按钮边界信息 * @returns 菜单按钮边界信息对象或null * @description 获取小程序右上角菜单按钮的边界信息,仅在小程序平台有效 */ export declare const getMenuButtonBoundingClientRect: () => UniApp.GetMenuButtonBoundingClientRectRes | null; /** * 获取导航栏高度 * @returns 导航栏高度(单位:px) * @description 获取导航栏的总高度,根据不同平台采用不同的计算方式 */ export declare const getNavHeight: () => number; /** * @returns 包含状态栏高度和导航栏高度的配置对象 * @description 一次性获取应用所需的状态栏和导航栏高度配置信息 */ export declare const getTopNavBarHeight: () => { statusBarHeight: number; navHeight: number; }; /** * 修改浏览器标题 * @param title 新的页面标题 * @description 动态修改浏览器标签页显示的标题,仅在H5/Web平台有效 * @example * // 修改页面标题 * setPageTitle('新的页面标题') */ export declare const setPageTitle: (title: string) => boolean | null; /** * 修改浏览器图标(favicon) * @param iconUrl 新的图标URL地址 * @param iconType 图标类型,默认为 'image/x-icon' * @description 动态修改浏览器标签页显示的图标,仅在H5/Web平台有效 * @example * // 修改页面图标 * setPageIcon('https://example.com/new-icon.ico') * // 或使用PNG格式 * setPageIcon('https://example.com/new-icon.png', 'image/png') */ export declare const setPageIcon: (iconUrl: string, iconType?: string) => boolean | null; /** * 检测是否在微信浏览器中运行 * @returns 是否为微信浏览器环境 * @description 检测当前是否在微信浏览器中运行(不包括微信小程序) */ export declare const isWechat: () => boolean;