• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3432

RouterModule/12-May-2024-262231

entry/12-May-2024-685597

harA/12-May-2024-201175

harB/12-May-2024-202175

hvigor/12-May-2024-2121

images/12-May-2024-

.gitignoreD12-May-2024119 1111

README_zh.mdD12-May-20242.7 KiB8359

build-profile.json5D12-May-20241.3 KiB5353

hvigorfile.tsD12-May-2024825 215

hvigorwD12-May-20241.4 KiB4928

hvigorw.batD12-May-20241.5 KiB6547

oh-package.json5D12-May-2024857 2827

ohosTest.mdD12-May-2024717 108

README_zh.md

1# Navigation动态路由
2
3### 介绍
4
5本项目提供动态路由的验证,运用了WrapperBuilder的自定义函数打包能力,以及动态路由的跨模块文件引用的能力,解除了har包和hap包的依赖关系,实现了
6即使hap包不引用har包,依然能跳转到har包中的页面的能力
7目前还不支持动态import变量表达式和跨模块相对路径的文件,所以代码中使用switch作为替代,若后续版本支持,会出相应的补丁
8由于环境的差异,不建议下载后直接编译,应先当创建项目,参考示例代码进行编写
9
10### 效果预览
11![image](images/Index.jpg)
12![image](images/HarA.jpg)
13![image](images/HarB.jpg)
14
15使用说明
16
171. 主页会提供一个NavIndex的导航页,点击按钮会跳转到不同的来自har包的页面
18
192. 每个har包的页面也存在跳转到别的页面的按钮
20
21### 工程目录
22
23```
24.
25├── entry // 主页面
26│   ├── pages
27│   │   ├── Index.ets   // 主页面
28│   ├── entryability
29│   │   ├── EntryAbility.ets
30├── harA // 主页面
31│   ├── pages
32│   │   ├── Index.ets   // harA
33│   ├── entryability
34│   │   ├── EntryAbility.ets
35├── harB // 主页面
36│   ├── pages
37│   │   ├── Index.ets   // harB
38│   ├── entryability
39│   │   ├── EntryAbility.ets
40├── RouterModule // 主页面
41│   ├── pages
42│   │   ├── Index.ets   // RouterModule
43│   ├── entryability
44│   │   ├── EntryAbility.ets
45.
46```
47
48### 具体实现
49
501.创建hapA harA harB
51
522.创建路由框架RouterModule,使用map存储hap包的路由和har包的页面信息
53
543.在RouterModule中封装get和set方法,并对外开放,允许外部模块引用和调用
55
564.创建push方法,允许传入一串url,并对其进行解析,通过拆解出路由名称从map中获取到路由栈,并将目标页面压栈
57
585.在hap和har包中引入RouterModule,将hap包的路由栈和har包的页面信息通过开放的set方法存入RouterModule
59
60### 相关权限
61
62不涉及
63
64### 约束与限制
65
661. 本示例仅支持标准系统上运行,支持设备:RK3568。
67
682. 本示例为Stage模型,支持API11版本SDK,SDK版本号(API Version 11 Release),镜像版本号(4.1 Release)
69
703. 本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。
71
72### 下载
73
74如需单独下载本工程,执行如下命令:
75
76```
77git init
78git config core.sparsecheckout true
79echo code/BasicFeature/Navigation/DynamicRouter > .git/info/sparse-checkout
80git remote add origin https://gitee.com/openharmony/applications_app_samples.git
81git pull origin master
82```
83