查看原文
其他

受欢迎的鸿蒙工具库(harmony-utils)

桃花镇童长老 鸿洋
2024-08-24

本文作者


作者:桃花镇童长老ᥫ᭡

链接:

https://blog.csdn.net/qq_32922545/article/details/139104721

本文由作者授权发布。


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模块介绍


4API详解


全局初始化方法,在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

ImageUtil(图片相关工具类 )点我见使用详细
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


最后推荐一下我做的网站,玩Android: wanandroid.com ,包含详尽的知识体系、好用的工具,还有本公众号文章合集,欢迎体验和收藏!


推荐阅读

NDK开发、Native Hook、Android性能优化必知:动态链接
Gradle既要、又要、还要的多模块的调试方案
Android存储系统成长记,来认识我的团队成员



扫一扫 关注我的公众号

如果你想要跟大家分享你的文章,欢迎投稿~


┏(^0^)┛明天见!

继续滑动看下一个
鸿洋
向上滑动看下一个

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存