# HarmonyOS-Component **Repository Path**: Harveyi/harmony-os-component ## Basic Information - **Project Name**: HarmonyOS-Component - **Description**: ICTT鸿蒙元服务/鸿蒙应用适配项目组件库 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-05-14 - **Last Updated**: 2025-06-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README UtilProject (大家把有用的功能加到common模块中即可) 是一个通用的工具库,主要用于元服务的功能类,app类型无需使用本库,使用ohpm中的harmony-util库即可,旨在提供用户友好的丰富的功能。 entry模块是测试模块,测试工具类的模块,可以在里面写上测试工具类的代码。 common模块是通用模块,提供封装的工具类,如存储,网络,权限申请等等。 ## 功能介绍 - huaweiLogin:提供华为登录的功能的封装。 - request:提供网络工具,是对axios的使用。 - PermissionManager:权限管理类,可以用于权限的申请。 - ClickUtil:节流、防抖 工具类(用于点击事件,防止按钮被重复点击) - EmitterUtil:Emitter工具类(进行线程间通信) - Tarbuilder:公共builder封装可以用于tab页的图标名称构建,只需放入图标与名称即可 - FlexBox:对Flex封装,只需放入图片,名称,列数即可快速生成flex布局 - StoreUtil:对首选项的封装,快速进行首选项的存,取,删除。 - UploadFileUtil:对图片文件上传的封装,点击之后会选择图片,之后会将该图片上传到对应的图片服务器,参数为对应图片服务器的url。 - TakePhotoUtil:获取图片uri的封装,从相册中获取图片uri或者拍照获取uri。 ## entry模块页面截图,主要是基础页面 ### 主页tab页 ![img.png](img.png) ### 我的tab页 ![img_1.png](img_1.png) ### 个人页面 ![img_2.png](img_2.png) ### ZRouter跳转案例 - 在hvigor-config.json5加入依赖插件 ``` "dependencies": { "router-register-plugin":"1.3.2" }, ``` - 每个模块中需要下载zrouter依赖 ```` ohpm install @hzw/zrouter ```` - 在hvigorfile.ts中添加路径 下面的是hap模块的,hsp可以将hapTasks修改为hspTasks ```` import { hapTasks } from '@ohos/hvigor-ohos-plugin'; import { routerRegisterPlugin, PluginConfig } from 'router-register-plugin' // 2、初始化配置 const config: PluginConfig = { scanDirs: ['src/main/ets'], // 扫描的目录,如果不设置,默认是扫描src/main/ets目录 logEnabled: true, // 查看日志 viewNodeInfo: false, // 查看节点信息 isAutoDeleteHistoryFiles: true ,// 删除无用编译产物 lifecycleObserverAttributeName: 'xxx' // 可选,设置全局的生命周期实现类在组件上的属性名,默认值是lifecycleObserver } export default { system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[routerRegisterPlugin(config)] /* Custom plugin to extend the functionality of Hvigor. */ } ```` - 在entry中进行初始化 ``` ZRouter.initialize((config) => { config.isLoggingEnabled = true config.isHSPModuleDependent = true///有hsp加上 }) ``` - 代码中使用 在根目录套上Navigation ```` Navigation(ZRouter.getNavStack()){ } ```` 在要去的组件中加上@Route({name:'xxx}),根目录加上NavDestination(){} ```` NavDestination(){ Column(){ Text(`使用zrouter跳转成功`) }.width('100%') .height('100%') .alignItems(HorizontalAlign.Center) .justifyContent(FlexAlign.Center) } ```` - 官网参考链接:https://ohpm.openharmony.cn/#/cn/detail/@hzw%2Fzrouter - ![img_3.png](img_3.png) - 最终效果如图所视 - ![img_4.png](img_4.png) - ![img_5.png](img_5.png)