鸿蒙路由源码调试步骤


TheRouter 是货拉拉基于HMRouter深度定制的开源路由框架,提供了 Android、iOS、Harmony 三端高一致性使用,在支持平台化应用实现组件化、跨模块调用、动态化等功能的集成等功能基础上,支持动态路由下发、编译时安全检查、路由Path一对多等高度动态能力。

Github: https://github.com/HuolalaTech/hll-wp-therouter-harmony/
官网:http://therouter.cn/


第一步:clone 仓库

使用命令行:

git clone git@github.com:HuolalaTech/hll-wp-therouter-harmony.git

第二步:创建 build-profile

在项目根目录中,新建一个名为 build-profile.json5 的文件,文件内加入如下内容。

{
  "app": {
    "signingConfigs": [ 
    // 签名部分需要手动从官网获取自己的开发者信息
     ],
    "products": [
      {
        "name": "default",
        "signingConfig": "xxxxx填上面的签名信息",
        "compatibleSdkVersion": "可根据自己SDK情况填写",
        "runtimeOS": "HarmonyOS",
        "buildOption": {
          "strictMode": {
            "caseSensitiveCheck": true,
            "useNormalizedOHMUrl": true
          }
        }
      }
    ],
    "buildModeSet": [
      {
        "name": "debug",
      },
      {
        "name": "release"
      }
    ]
  },
  "modules": [
    {
      "name": "entry",
      "srcPath": "./entry",
      "targets": [
        {
          "name": "default",
          "applyToProducts": [
            "default"
          ]
        }
      ]
    },
    {
      "name": "therouter",
      "srcPath": "./therouter"
    },
    {
      "name": "business_a",
      "srcPath": "./business_a"
    },
    {
      "name": "business_b",
      "srcPath": "./business_b"
    },
    {
      "name": "base",
      "srcPath": "./base"
    }
  ]
}

第三步:创建 hvigor 构建环境

在工程根目录新建一个名为 hvigor 的文件夹
文件夹内新建一个名为 hvigor-config.json5 的文件,文件内加入如下内容:

{
  "modelVersion": "根据实际情况填写版本号",
  "dependencies": {
    "@therouter/plugin": "根据实际情况填写版本号"  
  },
  "execution": {
    // "analyze": "normal",                     /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
    // "daemon": true,                          /* Enable daemon compilation. Value: [ true | false ]. Default: true */
    // "incremental": true,                     /* Enable incremental compilation. Value: [ true | false ]. Default: true */
    // "parallel": true,                        /* Enable parallel compilation. Value: [ true | false ]. Default: true */
    // "typeCheck": false,                      /* Enable typeCheck. Value: [ true | false ]. Default: false */
  },
  "logging": {
    // "level": "info"                          /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
  },
  "debugging": {
    // "stacktrace": false                      /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
  },
  "nodeOptions": {
    // "maxOldSpaceSize": 8192                  /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
    // "exposeGC": true                         /* Enable to trigger garbage collection explicitly. Default: true*/
  }
}

相关推荐:

从零接入鸿蒙路由 TheRouter从零接入鸿蒙路由 TheRouter

TheRouter 是货拉拉基于HMRouter深度定制的开源路由框架,提供了 Android、iOS、Harmony 三端高一致性使用,在支持平台化应用...

10 mins
为 TheRouter 的 AGP8 编译加个速为 TheRouter 的 AGP8 编译加个速

内容请见: 《为 TheRouter 的 AGP8 编译加个速》 https://kymjs.com/code/2024/10/31/01/

1 mins
新版本编译改动新版本编译改动

从`1.2.3-rc1`版本开始,我们对`TheRouter`编译过程做了大量优化,同时适配了`Gradle`的`4.x-8.x`全部版本,理论上更新的版本或更老的版本也能支持,只是没有去测试。

6 mins