npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

router-register-plugin

v1.8.2

Published

鸿蒙ZRouter动态路由框架插件

Readme

ZRouter

  • github:https://github.com/751496032/ZRouter
  • gitee:https://gitee.com/common-apps/ZRouter
  • 掘金:https://juejin.cn/post/7394094789287067685

基本使用

安装

在鸿蒙项目根目录的hvigor目录下的hvigor-config.json5文件中配置安装

"dependencies": {
  "router-register-plugin":"x.x.x"
},

最后记得Sync Now或重新build让插件安装生效。

配置

支持两种配置方式:

  • 工程级配置: 即在工程根目录下的hvigorfile.ts文件中全局配置;
  • 模块级配置:即在每个模块目录下的hvigorfile.ts文件中单独配置;

不建议一个项目同时使用两种配置方式,虽然是这种混合方式也是支持的,但容易出现配置冲突。模块级配置相对繁琐些,但配置项会更精细化些。

步骤:

// 1、导入
import { routerRegisterPlugin, PluginConfig } from 'router-register-plugin'

// 2、初始化配置
const config: PluginConfig = {
    scanDirs: ['src/main/ets/pages', 'src/main/ets/views'], // 扫描的目录,如果不设置,默认是扫描src/main/ets目录
    logEnabled: true, // 查看日志
    viewNodeInfo: false, // 查看节点信息
    ignoredModules:['RouterApi','common','xxx'], // 忽略的参与构建的模块,根据自己项目自行设置
    enableUiPreviewBuild: false, // 启用UI预览构建,不建议启动
}
export default {
    // 3、添加插件
    plugins:[routerRegisterPlugin(config)] 
}

注意:hvigorfile.ts文件中默认配置不要删除了。

配置参数说明:

| 参数名 | 类型 | 默认值 | 描述 | |----------------------------------|----------|-------------------|------------------------------------------------------------------------------| | scanDirs | string[] | ['src/main/ets'] | 扫描的目录,如果不设置,默认是扫描src/main/ets目录。建议配置该字段,避免扫描所有目录,影响工程编译效率** | | | logEnabled | boolean | true | 是否打印日志 | | | viewNodeInfo | boolean | false | 查看节点信息,只有与logEnable同时为true才会打印输出 | | ~~isAutoDeleteHistoryFiles~~ | boolean | false | 是否在构建时删除编译产物,已弃用,在项目clean自动删除无用编译产物,请不要设置此参数。 | | | lifecycleObserverAttributeName | string | lifecycleObserver | 如果使用了NavDest页面模板化功能,该配置字段会生效,默认属性名是lifecycleObserver,也可以在@Route注解上单独设置这个属性 | | ignoredModules | string[] | [] | 忽略需要扫描的模块,填写模块名称,默认是全部模块;插件在工程级时使用,该字段才会生效。建议配置该字段,避免扫描所有模块,影响工程编译效率 | | enableUiPreviewBuild | boolean | false | 是否在ui预览构建时生成,默认不启用, 会降低ui预览构建效率 |

注意: 以上配置参数都是可选的,建议配置scanDirsignoredModules字段,避免扫描所有目录和模块,影响工程编译效率。

更新记录

1.8.2 / 2025-9-4

  • 修复在DevEco 5.1.1版本下clean任务报错问题

1.8.0 / 2025-8-31

  • 支持路由表预加载;
  • 优化clean任务。

1.6.0 / 2025-6-27

  • Builder函数支持参数传递

1.5.0 / 2025-5-25

  • 同时支持工程级和模块级两种方式配置;
  • 支持项目clean时自动删除编译产物;
  • 优化构建效率,减少不必要的场景扫描构建生成;新增配置项ignoredModules,工程级配置可设置忽略模块,避免扫描所有模块;新增配置项enableUiPreviewBuild,避免在ui预览构建时生成, 影响ui预览效率。

1.3.2 / 2025-4-20

  • @Route注解不设置任何属性时,默认生成的路由名称为当前页面的类名;
  • 修复一些已知问题。

1.3.0 / 2024-12-24

  • NavDestination页面模板化的生命周期实现类属性支持全局和单个页面自定义命名。

1.2.1 / 2024-12-19

  • 修复NavDestination页面模板化的问题;
  • 配置新增lifecycleObserverAttributeName字段,用于NavDestination页面模板化自定义lifecycleObserver属性名称;

1.2.0 / 2024-12-8

  • 支持NavDestination页面模板化;
  • 修复dependencies依赖路径存在空格而导致常量查找失败的问题。

1.1.1

  • 修复删除历史编译产物问题

1.1.0

  • 对扫码的目录进行安全校验
  • 优化路由表的生成

1.0.9

  • 支持服务路由。

1.0.8

  • 优化@Route装饰器上的常量查找逻辑;
  • 配置新增scanDirs字段,支持配置多个扫描目录,~~scanDir~~字段已设过期状态;
  • 配置新增isAutoDeleteHistoryFiles字段,用于是否自动删除无用编译产物。

1.0.7

  • @Route装饰器上的name属性支持常量设置,支持跨模块定义。

1.0.6

  • 修改生成文件的名称,统一加前缀ZR,适配混淆;
  • 支持自动删除历史残余文件。

1.0.5

  • 修复部分windows系统下编译报错问题
  • 删除模块下Index.ets导出
  • 修改Builder函数生成的文件路径,避免加载所有的组件;
  • 如果插件不生效,关闭IDE并清缓存重启。

其他

大家使用中有疑问或者建议,可以扫码或加v(751496032)进群交流,备注鸿蒙ZRouter

在这里插入图片描述