1
简介
harmony-utils 是一款高效的OpenHarmony/HarmonyOS工具包,封装了常用工具类,提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。
https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils
源码地址:
https://gitee.com/tongyuyan/harmony-utils
2
下载安装
ohpm i @pura/harmony-utils
OpenHarmony ohpm 环境配置等更多内容,请参考如何安装 OpenHarmony ohpm 包。
https://ohpm.openharmony.cn/#/cn/help/downloadandinstall
3
模块介绍
4
API详解
全局初始化方法,在UIAbility的onWindowStageCreate方法中初始化 AppUtil.init()
onWindowStageCreate(windowStage: window.WindowStage): void {
AppUtil.init(this.context, windowStage);
}
AppUtil(APP相关工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/AppUtilPage.ets
DeviceUtil(设备相关工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/DeviceUtilPage.ets
DisplayUtil(屏幕相关工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/DisplayUtilPage.ets
PermissionUtil(申请授权工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/PermissionUtilPage.ets
AuthUtil(手机的生物认证(指纹、人脸、密码)工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/AuthUtilPage.ets
NotificationUtil(通知工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/NotificationUtilPage.ets
PreferencesUtil(Preferences工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/PreferencesUtilPage.ets
FileUtil(文件操作相关工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/FileUtilPage.ets
PickerUtil(拍照、文件选择和保存,工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/PickerUtilPage.ets
PreviewUtil(文件预览工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/PreviewUtilPage.ets
NetworkUtil(网络相关工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/NetworkUtilPage.ets
LocationUtil(定位工具类(WGS-84坐标系))点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/LocationUtilPage.ets
PasteboardUtil(剪贴板工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/PasteboardUtilPage.ets
SnapshotUtil(组件截图和窗口截图工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/SnapshotUtilPage.ets
ScanUtil(码工具类(扫码、码图生成、图片识码))点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/ScanUtilPage.ets
mageUtil(图片相关工具类 )点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/ImageUtilPage.ets
KeyboardUtil(键盘工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/KeyboardUtilPage.ets
LogUtil(日志工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/LogUtilPage.ets
CrashUtil(全局异常捕获,崩溃日志收集)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/CrashUtilPage.ets
StrUtil(字符串工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/StrUtilPage.ets
Base64Util(Base64工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/Base64UtilPage.ets
NumberUtil(number工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/NumberUtilPage.ets
DateUtil(日期工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/DateUtilPage.ets
ArrayUtil(数组工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/ArrayUtilPage.ets
RandomUtil(随机工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/RandomUtilPage.ets
ObjectUtil(对象工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/ObjectUtilPage.ets
JSONUtil(JSON工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/JSONUtilPage.ets
CacheUtil(缓存工具类 )点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/CacheUtilPage.ets
ClickUtil(节流、防抖 工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/ClickUtilPage.ets
TempUtil(温度转换工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/TempUtilPage.ets
ActionUtil(弹窗工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/ActionUtilPage.ets
DialogUtil(弹窗工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/DialogUtilPage.ets
ToastUtil(土司工具类)点我见使用详细
https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/ToastUtilPage.ets
仓库地址
https://gitee.com/tongyuyan/harmony-utils
后续计划
1、持续优化和添加更多的实用方法与功能(网络相关、语音、文字识别、router)。
2、添加新的模块(悬浮窗、加载动画、JSBridge)。
贡献代码
使用过程中发现任何问题都可以提Issue 给我们,当然,我们也非常欢迎你给我们发PR。
https://gitee.com/tongyuyan/harmony-utils/issues
https://gitee.com/tongyuyan/harmony-utils/pulls
开源协议
本项目基于 Apache License 2.0 ,请自由地享受和参与开源。
https://www.apache.org/licenses/LICENSE-2.0.html