3 Star 33 Fork 9

桃花镇童长老 / harmony-utils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

harmony-utils (基于API11)


📚简介

harmony-utils 一款高效的OpenHarmony/HarmonyOS工具包,封装了常用工具类,提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。

📚下载安装

ohpm i @pura/harmony-utils

OpenHarmony ohpm 环境配置等更多内容,请参考如何安装 OpenHarmony ohpm 包

📚模块介绍

模块 介绍
AppUtil APP相关工具类
DeviceUtil 设备相关工具类
DisplayUtil 屏幕相关工具类
PermissionUtil 申请授权工具类
AuthUtil 手机的生物认证(指纹、人脸、密码)工具类
NotificationUtil 通知工具类
PreferencesUtil Preferences(用户首选项)工具类
FileUtil 文件操作相关工具类
PickerUtil 拍照、文件(文件、图片、视频、音频)选择和保存,工具类
PreviewUtil 文件预览工具类
NetworkUtil 网络相关工具类
LocationUtil 定位工具类(WGS-84坐标系)
PasteboardUtil 剪贴板工具类
SnapshotUtil 组件截图和窗口截图工具类
ScanUtil 码工具类(扫码、码图生成、图片识码)
ImageUtil 图片相关工具类
KeyboardUtil 键盘工具类
LogUtil 日志工具类
CrashUtil 全局异常捕获,崩溃日志收集
StrUtil 字符串工具类
Base64Util Base64工具类
NumberUtil number工具类
DateUtil 日期工具类
ArrayUtil 数组工具类
RandomUtil 随机工具类
ObjectUtil 对象工具类
JSONUtil JSON工具类
CacheUtil 缓存工具类
ClickUtil 节流、防抖 工具类(用于点击事件,防止按钮被重复点击)
TempUtil 温度转换工具类,华氏度与摄氏度相互转换
WindowUtil 窗口工具类
ActionUtil 弹窗工具类(promptAction)
DialogUtil 弹窗工具类(AlertDialog)
ToastUtil 土司工具类(promptAction)
AlertControlDialog 操作确认类弹出框
ConfirmControlDialog 信息确认类弹出框
LoadingControlDialog 进度加载类弹出框
SelectControlDialog 选择类弹出框
TipControlDialog 提示弹出框


📚API详解

全局初始化方法,在UIAbility的onWindowStageCreate方法中初始化 AppUtil.init()
   
onWindowStageCreate(windowStage: window.WindowStage): void {
   AppUtil.init(this.context, windowStage);  
}

AppUtil(APP相关工具类) 点我见使用详细

方法 介绍
init 初始化方法,缓存全局变量,在UIAbility的onWindowStageCreate方法中初始化该方法
getContext 获取上下文,common.UIAbilityContext
getMainWindow 获取主窗口
getUIContext 获取UIContext
getWindowProperties 获取当前窗口的属性
getKeyboardAvoidMode 获取虚拟键盘抬起时的页面避让模式(OFFSET-上抬模式、RESIZE-压缩模式)
setKeyboardAvoidMode 设置虚拟键盘弹出时,页面的避让模式
isPortrait 当前设备是否以竖屏方式显示
isLandscape 当前设备是否以横屏方式显示
setPreferredOrientation 设置窗口的显示方向属性
setWindowBrightness 设置屏幕亮度值
setWindowKeepScreenOn 设置屏幕是否为常亮状态
setWindowPrivacyMode 设置窗口是否为隐私模式。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏
setWindowBackgroundColor 设置窗口的背景色。Stage模型下,该接口需要在loadContent()或setUIContent()调用生效后使用
setWindowFocusable 设置点击时是否支持切换焦点窗口
setWindowTouchable 设置窗口是否为可触状态
getStatusBarHeight 获取状态栏的高度,单位为px
getNavigationIndicatorHeight 获取底部导航条的高度,单位为px。
setStatusBar 设置沉浸式状态栏(需要配合getStatusBarHeight和getNavigationIndicatorHeight一起使用)
getBundleInfo 获取当前应用的BundleInfo
getAppInfo 获取应用程序的配置信息
toAppSetting 跳转应用设置页面
toNetworkSetting 跳转移动网络设置页面
toNotificationSetting 跳转通知设置页面
toBluetoothSetting 跳转蓝牙设置页面
toNfcSetting 跳转NFC设置页面

DeviceUtil(设备相关工具类) 点我见使用详细

方法 介绍
getDeviceId 获取设备ID(卸载APP后依旧不变)
getConfiguration 获取设备的Configuration
getConfigurationSync 获取设备的Configuration
getDirection 获取当前设备屏幕方向
getDeviceCapability 获取设备的DeviceCapability
getDeviceCapabilitySync 获取设备的DeviceCapability
getDeviceType 获取当前设备类型
getDeviceTypeStr 获取当前设备类型,返回字符串
getScreenDensity 获取当前设备屏幕密度
startVibration 开启设备振动
stopVibration 停止设备振动(按照VIBRATOR_STOP_MODE_TIME模式)

DisplayUtil(屏幕相关工具类)点我见使用详细

方法 介绍
getDefaultDisplaySync 获取当前默认的display对象
getWidth 获取设备的屏幕宽度,单位为px
getHeight 获取设备的屏幕高度,单位为px
getOrientation 获取设备当前显示的方向
getDisplayState 获取设备的状态
getCutoutRect 获取取挖孔屏、刘海屏、瀑布屏等不可用屏幕区域信息。建议应用布局规避该区域
getCutoutHeight 获取挖孔屏、刘海屏等不可用屏幕区域的高度,单位为px
isFoldable 检查设备是否可折叠
getFoldStatus 获取可折叠设备的当前折叠状态
getFoldDisplayMode 获取可折叠设备的显示模式
onFoldStatusChange 开启折叠设备折叠状态变化的监听
offFoldStatusChange 关闭折叠设备折叠状态变化的监听

PermissionUtil(申请授权工具类)点我见使用详细

方法 介绍
checkPermissions 校验当前是否已经授权
checkRequestPermissions 校验是否授权后并申请授权
requestPermissions 申请授权
requestPermissionsList 申请组合授权

AuthUtil(手机的生物认证(指纹、人脸、密码)工具类)点我见使用详细

方法 介绍
getAvailableStatus 查询指定类型和等级的认证能力是否支持
onStartEasy 开始认证,使用指纹和密码认证
onStart 开始认证,用户指定类型认证
cancel 取消认证

NotificationUtil(通知工具类)点我见使用详细

方法 介绍
authorizeNotification 校验是否已授权通知服务
publishBasic 发布普通文本通知
publishMultiLine 发布多文本通知
publishLongText 发布长文本通知
publishPicture 发布带有图片的通知
cancel 取消通知
cancelAll 取消所有通知
setBadge 设置桌面角标个数
clearBadge 清空桌面角标
setBadgeFromNotificationCount 设置桌面角标数量,来自于通知数量
getActiveNotificationCount 获取当前应用未删除的通知数量
getActiveNotifications 获取当前应用未删除的通知列表

PreferencesUtil(Preferences工具类)点我见使用详细

方法 介绍
put 将数据缓存
get 获取缓存值
getString 获取string类型的缓存值
getNumber 获取number类型的缓存值
getBoolean 获取boolean类型的缓存值
has 检查缓存实例中是否包含给定Key的存储键值对
delete 删除缓存值
clear 清空缓存

FileUtil(文件操作相关工具类)点我见使用详细

方法 介绍
getFilesDirPath 获取文件目录下的文件夹路径或文件路径
getCacheDirPath 获取缓存目录下的文件夹路径或文件路径
getTempDirPath 获取临时目录下的文件夹路径或文件路径
hasDirPath 判断是否是完整路径
getFileUri 通过URI或路径,获取FileUri
getFileName 通过URI或路径,获取文件名
getFilePath 通过URI或路径,获取文件路径
getParentUri 通过URI或路径,获取对应文件父目录的URI
getParentPath 通过URI或路径,获取对应文件父目录的路径名
getUriFromPath 以同步方法获取文件URI
getFileExtention 根据文件名获取文件后缀
isFile 判断文件是否是普通文件
isDirectory 判断文件是否是目录
rename 重命名文件或文件夹,使用Promise异步回调
renameSync 重命名文件或文件夹,以同步方法
mkdir 创建目录,当recursion指定为true,可多层级创建目录
mkdirSync 创建目录以同步方法,当recursion指定为true,可多层级创建目录
rmdir 删除整个目录,使用Promise异步回调
rmdirSync 删除整个目录,以同步方法
unlink 删除单个文件,使用Promise异步回调
unlinkSync 删除单个文件,以同步方法
access 检查文件是否存在,使用Promise异步回调
accessSync 检查文件是否存在,以同步方法
open 打开文件,支持使用URI打开文件
openSync 打开文件,支持使用URI打开文件
read 从文件读取数据
readSync 从文件读取数据
readText 基于文本方式读取文件(即直接读取文件的文本内容)
readTextSync 基于文本方式读取文件(即直接读取文件的文本内容)
write 将数据写入文件
writeSync 将数据写入文件
writeEasy 将数据写入文件,并关闭文件
close 关闭文件
closeSync 关闭文件
listFile 列出文件夹下所有文件名,支持递归列出所有文件名(包含子目录下),支持文件过滤
listFileSync 列出文件夹下所有文件名,支持递归列出所有文件名(包含子目录下),支持文件过滤
stat 获取文件详细属性信息
statSync 获取文件详细属性信息
copy 拷贝文件或者目录,支持拷贝进度监听
copyFile 复制文件
copyFileSync 以同步方法复制文件
moveFile 移动文件
moveFileSync 移动文件,以同步方法
moveDir 移动源文件夹至目标路径下
moveDirSync 以同步方法移动源文件夹至目标路径下
truncate 截断文件
truncateSync 截断文件,以同步方法
lstat 获取链接文件信息
lstatSync 获取链接文件信息,以同步方法
fsync 同步文件数据
fsyncSync 同步文件数据,以同步方法
fdatasync 实现文件内容数据同步
fdatasyncSync 实现文件内容数据同步,以同步方法
createStream 基于文件路径打开文件流
createStreamSync 基于文件路径打开文件流,以同步方法
fdopenStream 基于文件描述符打开文件流
fdopenStreamSync 基于文件描述符打开文件流,以同步方法
mkdtemp 创建临时目录
mkdtempSync 创建临时目录,以同步的方法
dup 将文件描述符转化为File
utimes 修改文件最近访问时间属性
getFormatFileSize 格式化文件大小
getRawFileContentSync 获取resources/rawfile目录下对应的rawfile文件内容
getRawFileContent 获取resources/rawfile目录下对应的rawfile文件内容
getRawFileContentStrSync 获取resources/rawfile目录下对应的rawfile文件内容
getRawFileContentStr 获取resources/rawfile目录下对应的rawfile文件内容

PickerUtil(拍照、文件选择和保存,工具类)点我见使用详细

方法 介绍
camera 调用系统相机,拍照、录视频
selectPhoto 通过选择模式拉起photoPicker界面,用户可以选择一个或多个图片/视频
savePhoto 通过保存模式拉起photoPicker进行保存图片或视频资源的文件名,若无参数,则默认需要用户自行输入
selectDocument 通过选择模式拉起documentPicker界面,用户可以选择一个或多个文件
saveDocument 通过保存模式拉起documentPicker界面,用户可以保存一个或多个文件
selectAudio 通过选择模式拉起audioPicker界面,用户可以选择一个或多个音频文件
saveAudio 通过保存模式拉起audioPicker界面,用户可以保存一个或多个音频文件
getPhotoAsset 获取对应uri的PhotoAsset对象,用于读取文件信息

PreviewUtil(文件预览工具类)点我见使用详细

方法 介绍
generatePreviewInfo 根据文件uri构建PreviewInfo
openPreview 通过传入文件预览信息,打开预览窗口。1秒内重复调用无效
openPreviewEasy 通过传入文件的uri,打开预览窗口。1秒内重复调用无效
canPreview 根据文件的uri判断文件是否可预览
hasDisplayed 判断预览窗口是否已经存在
closePreview 关闭预览窗口,仅当预览窗口存在时起效
loadData 加载预览文件信息。仅当预览窗口存在时起效
loadDataEasy 加载预览文件信息。仅当预览窗口存在时起效
onSharePreview 调用其他应用预览文件
getMimeType 根据文件后缀名获取文件mimeType
getIconFileStr 根据文件后缀名获取对应文件类型的图标
getMimeTypeMap filePreview支持的预览文件类型

NetworkUtil(网络相关工具类)点我见使用详细

方法 介绍
hasDefaultNet 检查默认数据网络是否被激活
hasDefaultNetSync 检查默认数据网络是否被激活
hasNetWiFi 判断当前网络是否是Wi-Fi,否则是移动流量热点网络
getNetBearType 获取网络类型
getIpAddress 获取当前设备的IP地址(设备连接Wi-Fi后)
register 订阅指定网络状态变化的通知,支持多事件监听回调
unregister 取消订阅默认网络状态变化的通知

LocationUtil(定位工具类(WGS-84坐标系))点我见使用详细

方法 介绍
isLocationEnabled 判断位置服务是否已经使能(定位是否开启)。
requestLocationPermissions 申请定位权限
getCurrentLocationEasy 获取当前位置
getCurrentLocation 获取当前位置
onLocationChangeEasy 开启位置变化订阅,并发起定位请求。
onLocationChange 开启位置变化订阅,并发起定位请求
offLocationChange 关闭位置变化订阅,并删除对应的定位请求。
getAddressFromLocationName 地理逆编码,将地理描述转换为具体坐标
getGeoAddressFromLocationName 地理逆编码,将地理描述转换为具体坐标
getAddressFromLocation 地理逆编码,将坐标转换为地理描述
getGeoAddressFromLocation 地理逆编码,将坐标转换为地理描述集合
getCountryCode 获取当前的国家码

PasteboardUtil(剪贴板工具类 )点我见使用详细

方法 介绍
setDataText 将纯文本数据写入系统剪贴板
setDataHtml 将Htm数据写入系统剪贴板
setDataUri 将Uri数据写入系统剪贴板
getData 读取系统剪贴板内容
getDataSync 读取系统剪贴板内容
getDataStr 读取系统剪贴板里的字符串
getDataSyncStr 读取系统剪贴板里的字符串
clearData 清空系统剪贴板内容
hasData 判断系统剪贴板中是否有内容
hasDataSync 判断系统剪贴板中是否有内容

SnapshotUtil(组件截图和窗口截图工具类)点我见使用详细

方法 介绍
get 获取已加载的组件的截图,传入组件的组件id,找到对应组件进行截图。通过Promise返回结果
createFromBuilder 在应用后台渲染CustomBuilder自定义组件,并输出其截图
snapshot 获取窗口截图,使用Promise异步回调

ScanUtil(码工具类(扫码、码图生成、图片识码))点我见使用详细

方法 介绍
startScanForResult 调用默认界面扫码,使用Promise方式异步返回解码结果
generateBarcode 码图生成,使用Promise异步返回生成的码图
onPickerScanForResult 通过picker拉起图库并选择图片,并调用图片识码
onDetectBarCode 调用图片识码,使用Promise方式异步返回识码结果
canIUseScan 判断当前设备是否支持码能力

ImageUtil(图片相关工具类 )点我见使用详细

方法 介绍
base64ToPixelMap 图片base64字符串转PixelMap
pixelMapToBase64Str PixelMap转图片base64字符串
savePixelMap 保存pixelMap到本地
saveImageSource 保存ImageSource到本地
createImageSource 创建图片源实例
createIncrementalSource 以增量的方式创建图片源实例
packingFromPixelMap 图片压缩或重新打包,使用Promise形式返回结果
packingFromImageSource 图片压缩或重新打包,使用Promise形式返回结果
packToFileFromPixelMap 将PixelMap图片源编码后直接打包进文件
packToFileFromImageSource 将ImageSource图片源编码后直接打包进文件
getPixelMapFromMedia 用户获取resource目录下的media中的图片PixelMap

KeyboardUtil(键盘工具类)点我见使用详细

方法 介绍
hide 隐藏键盘
onKeyboardListener 订阅输入法软键盘显示和隐藏事件
removeKeyboardListener 取消订阅输入法软键盘显示或隐藏事件
onInputTextChanged 订阅文本内容变化
removeInputTextChanged 取消订阅文本内容变化

LogUtil(日志工具类)点我见使用详细

方法 介绍
init 初始化日志参数(该方法建议在Ability里调用)
setDomain 设置日志对应的领域标识,范围是0x0~0xFFFF。(该方法建议在Ability里调用)
setTag 设置日志标识(该方法建议在Ability里调用)
setShowLog 是否打印日志(该方法建议在Ability里调用)
debug 打印DEBUG级别日志
info 打印INFO级别日志
warn 打印WARN级别日志
error 打印ERROR级别日志
fatal 打印FATAL级别日志
print 打印JSON对象和JSON字符串(日志过滤tag为:JSAPP)

CrashUtil(全局异常捕获,崩溃日志收集)点我见使用详细

方法 介绍
onError 注册错误观测器。注册后可以捕获到应用产生的js crash,应用崩溃时进程不会退出。将异常信息写入本地文件
offError 注销错误观测器
readErrorText 读取错误日志文件
onExportErrorLog 导出错误日志文件
enableAppRecovery 启用应用恢复功能,参数按顺序填入。该接口调用后,应用从启动器启动时第一个Ability支持恢复。
restartApp 重启APP,并拉起应用启动时第一个Ability,可以配合errorManager相关接口使用
saveAppState 保存当前App状态 或 主动保存Ability的状态,这个状态将在下次恢复启动时使用。可以配合errorManager相关接口使用
setRestartWant 设置下次恢复主动拉起场景下的Ability。该Ability必须为当前包下的UIAbility

StrUtil(字符串工具类)点我见使用详细

方法 介绍
isNull 字符串是否为空(undefined、null)
isNotNull 判断字符串是否为非空
isEmpty 字符串是否为空(undefined、null、字符串长度为0)
isNotEmpty 判断字符串是否为非空
isBlank 判断字符串是否为空和空白符(空白符包括空格、制表符、全角空格和不间断空格)
isNotBlank 判断字符串是否为非空
replace 替换字符串中匹配的正则为给定的字符串
startsWith 检查字符串是否以给定的字符串开头
endsWith 检查字符串是否以给定的字符串结尾
repeat 将字符串重复指定次数
toLower 转换整个字符串的字符为小写
toUpper 转换整个字符串的字符为大写
capitalize 转换字符串首字母为大写,剩下为小写
equal 判断两个传入的数值或者是字符串是否相等
notEqual 判断两个传入的数值或者是字符串是否不相等
strToUint8Array 字符串转Uint8Array
unit8ArrayToStr Uint8Array转字符串
strToBase64 字符串转Base64字符串
base64ToStr Base64字符串转字符串
strToBuffer 字符串转ArrayBuffer
bufferToStr ArrayBuffer转字符串
bufferToUint8Array ArrayBuffer转Uint8Array
unit8ArrayToBuffer Uint8Array转ArrayBuffer

Base64Util(Base64工具类)点我见使用详细

方法 介绍
encodeSync 编码,通过输入参数编码后输出Uint8Array对象
encodeToStrSync 编码,通过输入参数编码后输出对应文本
decodeSync 解码,通过输入参数解码后输出对应Uint8Array对象
encode 编码,通过输入参数编码后输出Uint8Array对象
encodeToStr 编码,通过输入参数编码后输出对应文本
decode 解码,通过输入参数解码后输出对应Uint8Array对象

NumberUtil(number工具类)点我见使用详细

方法 介绍
isNumber 判断是否是数值
toInt 将字符串转换为整数
toFloat 将字符串转换为浮点数

DateUtil(日期工具类)点我见使用详细

方法 介绍
getToday 获取今天的日期
getTodayTime 获取今天的时间戳
getTodayStr 获取今天的时间,字符串类型
getFormatDate 获取格式化日期,将传入的日期格式化为Date
getFormatDateStr 获取格式化日期,将传入的日期格式化为指定格式的字符串
getTipDateStr 格式化时间戳,获取提示性时间字符串
getDateDiff 获取两个Date的日期差单位为天

ArrayUtil(数组工具类)点我见使用详细

方法 介绍
isNotEmpty 集合是否为非空集合
isEmpty 集合是否为空集合
removeEmpty 去除集合中的空值
trim 去除传入集合的每个值的前后空格
distinct 数组去重,去重后生成新的数组,原数组不变
reverse 反转数组,会修改原始数组
filter 通过传入的filter实现来过滤返回需要的元素
append 将新元素添加到已有数组中 添加新元素会生成一个新的数组,不影响原数组
setOrAppend 将元素值设置为数组的某个位置,当给定的index大于数组长度,则追加
min 获取数组(数值、字符串、日期)最小值
max 获取数组(数值、字符串、日期)最大值
flatten 平铺二维数组
union 平铺二维数组,并去重

RandomUtil(随机工具类)点我见使用详细

方法 介绍
randomInt 生成随机数number值
randomLimit 生成指定范围内的随机数 [0,limit)
randomNumber 生成指定范围内的随机数
randomBoolean 生成随机Boolean值
randomStr 根据指定字符串,随机生成指定长度的字符串
randomChinese 生成随机汉字
randomColor 生成随机颜色,十六进制
generateUUID36 生成36位UUID,带-
generateUUID32 生成32位UUID,带-
generateRandomUUID 使用加密安全随机数生成器生成随机的RFC 4122版本4的string类型UUID
generateRandomBinaryUUID 使用加密安全随机数生成器生成随机的RFC 4122版本4的Uint8Array类型UUID

ObjectUtil(对象工具类)点我见使用详细

方法 介绍
isString 判断是否是String
isNull 判断对象是否为空
deepCopy 深度拷贝对象

JSONUtil(JSON工具类)点我见使用详细

方法 介绍
jsonToBean JSON字符串转Class对象
jsonToArray JSON字符串转Array
jsonToMap JSON转Map
beanToJsonStr 对象转字符串
isJSONStr 判断是否是字符串格式json

CacheUtil(缓存工具类 )点我见使用详细

方法 介绍
save 存值
get 取值

ClickUtil(节流、防抖 工具类)点我见使用详细

方法 介绍
throttle 节流:在一定时间内,只触发一次
debounce 防抖:一定时间内,只有最后一次操作,再过wait毫秒后才执行函数

TempUtil(温度转换工具类)点我见使用详细

方法 介绍
F2C 华氏度转摄氏度
C2F 摄氏度转华氏度

ActionUtil(弹窗工具类)点我见使用详细

方法 介绍
showConfirmDialog 显示弹窗(一个按钮)
showPrimaryDialog 显示弹窗(两个按钮)
showDialog 显示弹窗(多个按钮)
showActionMenuEasy 显示操作菜单(简单易用)
showActionMenu 显示操作菜单

DialogUtil(弹窗工具类)点我见使用详细

方法 介绍
showConfirmDialog 显示弹窗(一个按钮)
showPrimaryDialog 显示弹窗(两个按钮)
showDialog 显示弹窗(可多个按钮)
showDialogEasy 显示弹窗(可多个按钮,简单易用)
showActionSheet 列表选择弹窗
showActionSheetEasy 列表选择弹窗(简单易用)
showCalendarPicker 日历选择器弹窗
showDatePicker 日期滑动选择器弹窗
showTimePicker 时间滑动选择器弹窗
showTextPicker 文本滑动选择器弹窗

ToastUtil(土司工具类)点我见使用详细

方法 介绍
showToast 弹出土司,默认时长为2s
showShort 弹出短土司,默认时长为:1.5s
showLong 弹出长土司,默认时长为:10s

📚仓库地址

https://gitee.com/tongyuyan/harmony-utils

💖后续计划

1、持续优化和添加更多的实用方法与功能(网络相关、语音、文字识别、文件预览)。
2、添加新的模块(悬浮窗、加载动画、JSBridge)。

💖技术交流

QQ群:569512366

🙏贡献代码

使用过程中发现任何问题都可以提 Issue 给我们,当然,我们也非常欢迎你给我们发 PR

📚开源协议

本项目基于 Apache License 2.0 ,请自由地享受和参与开源。

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

harmony-utils 一款高效的OpenHarmony/HarmonyOS工具包,封装了常用工具类,提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。 展开 收起
TypeScript 等 3 种语言
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/tongyuyan/harmony-utils.git
git@gitee.com:tongyuyan/harmony-utils.git
tongyuyan
harmony-utils
harmony-utils
master

搜索帮助