!4729 新增系统路由sample用例

Merge pull request !4729 from yuyaozhi/master
This commit is contained in:
openharmony_ci 2024-08-27 08:15:00 +00:00 committed by Gitee
commit 3deac1b48e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
108 changed files with 3681 additions and 1 deletions

13
OAT.xml
View File

@ -1036,7 +1036,18 @@ Note:If the text contains special characters, please escape them according to th
<filteritem type="filepath" name="code/BasicFeature/Print/ScanNapiInterfaceDemo/AppScope/resources/base/media/app_icon.png" desc="Provided by code/BasicFeature/Print/ScanNapiInterfaceDemo"/>
<filteritem type="filepath" name="code/BasicFeature/Print/ScanNapiInterfaceDemo/entry/src/main/resources/base/media/foreground.png" desc="Provided by code/BasicFeature/Print/ScanNapiInterfaceDemo"/>
<filteritem type="filepath" name="code/BasicFeature/Print/ScanNapiInterfaceDemo/sceenshots/scandemo.png" desc="Provided by code/BasicFeature/Print/ScanNapiInterfaceDemo"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/entry/src/main/resources/base/media/icon.png" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/entry/src/main/resources/base/media/startIcon.png" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/entry/src/main/resources/base/media/background.png" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/AppScope/resources/base/media/app_icon.png" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/entry/src/main/resources/base/media/foreground.png" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/images/HspAPageOne.jpeg" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/images/HarAPageTwo.jpeg" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/images/HspAPageTwo.jpeg" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/images/EntryPageOne.jpeg" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/images/NavIndex.jpeg" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/images/EntryPageTwo.jpeg" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/SystemRouter/images/HarAPageOne.jpeg" desc="code/BasicFeature/ApplicationModels/SystemRouter"/>
</filefilter>
<filefilter name="defaultPolicyFilter" desc="License文件头校验策略的过滤条件" >
<filteritem type="filename" name="oh-package.json5" desc="OpenHarmony工程编译入口脚本无需添加License头"/>

View File

@ -0,0 +1,12 @@
/node_modules
/oh_modules
/local.properties
/.idea
**/build
/.hvigor
.cxx
/.clangd
/.clang-format
/.clang-tidy
**/.test
/.appanalyzer

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"app": {
"bundleName": "com.samples.systemrouter",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
}

View File

@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "SystemRouterSamples"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,89 @@
# Navigation系统路由
### 介绍
本项目提供系统路由的验证,运用系统路由表的方式,跳转到模块(HSP/HAR)的页面,可以不用配置不同跳转模块间的依赖。当发生页面跳转时,未跳转页面不会加载,
已经加载过的页面不会再次加载。 解决了不同模块依赖耦合的问题,以及首页加载时间长的问题。
详细配置可参考[系统路由表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-navigation-navigation.md)。
由于环境的差异,不建议下载后直接编译,应先当创建项目,参考示例代码进行编写。
### 效果预览
<img src="./images/NavIndex.jpeg" width="200" height="360" />
| EntryPageOne | EntryPageTwo | HarAPageOne |
|------------------------------------------------------------------|------------------------------------------------------------------|-----------------------------------------------------------------|
| <img src="./images/EntryPageOne.jpeg" width="200" height="360"/> | <img src="./images/EntryPageTwo.jpeg" width="200" height="360"/> | <img src="./images/HarAPageOne.jpeg" width="200" height="360"/> |
| HarAPageTwo | HspAPageOne | HspAPageTwo |
| <img src="./images/HarAPageTwo.jpeg" width="200" height="360"/> | <img src="./images/HspAPageOne.jpeg" width="200" height="360"/> | <img src="./images/HspAPageTwo.jpeg" width="200" height="360"/> |
使用说明
1. 主页会提供一个NavIndex的导航页点击按钮会跳转到不同的来自HAR和HSP包的页面
2. 每个HAR和HSP包的页面也存在跳转到别的页面的按钮
### 工程目录
```
├──entry/src/main/ets/
│ ├──common
│ │ └──utils
│ │ └──Logger.ets // 日志打印封装
│ ├──entryability
│ │ └──EntryAbility.ets // 程序入口
│ └──pages
│ ├──EntryPageOne.ets // 页面1
│ ├──EntryPageTwo.ets // 页面2
│ └──Index.ets // 界面实现
├──entry/src/main/resources // 应用资源目录
├──harA
├──harB
├──hspA
└──hspB
```
### 具体实现
1.创建hapA harA hspA hspB
2.在跳转目标模块的配置文件[module.json5](entry/src/main/module.json5)添加路由表配置
3.添加完路由配置文件地址后需要在工程resources/base/profile中创建[route_map.json](entry/src/main/resources/base/profile/router_map.json)
文件
4.在跳转目标页面中需要配置入口Builder函数函数名称需要和[route_map.json](entry/src/main/resources/base/profile/router_map.json)
配置文件中的buildFunction保持一致。
5.应用通过调用pushDestinationByName等方式可以获取跳转目标页面的错误信息。
6.运行时需设置引用所有HSP模块。设置运行后点击Run > entry来启动应用/服务的编译构建。
### 相关权限
不涉及
### 依赖
不涉及。
### 约束与限制
1. 本示例仅支持标准系统上运行支持设备RK3568。
2. 本示例仅支持API12版本SDK版本号5.0.0.26镜像版本号OpenHarmony 5.0.0.26。
3. 本示例需要使用DevEco Studio NEXT Developer Beta5 (Build Version: 5.0.3.700)才可编译运行;
### 下载
如需单独下载本工程,执行如下命令:
```
git init
git config core.sparsecheckout true
echo code/BasicFeature/ApplicationModels/SystemRouter > .git/info/sparse-checkout
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
git pull origin master
```

View File

@ -0,0 +1,88 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"app": {
"signingConfigs": [],
"products": [
{
"name": "default",
"signingConfig": "default",
"compatibleSdkVersion": 12,
"compileSdkVersion": 12,
"runtimeOS": "OpenHarmony",
"buildOption": {
"strictMode": {
"caseSensitiveCheck": true
}
}
}
],
"buildModeSet": [
{
"name": "debug",
},
{
"name": "release"
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
},
{
"name": "harA",
"srcPath": "./harA",
},
{
"name": "harB",
"srcPath": "./harB",
},
{
"name": "hspA",
"srcPath": "./hspA",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
},
{
"name": "hspB",
"srcPath": "./hspB",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}

View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"files": [
"**/*.ets"
],
"ignore": [
"**/src/ohosTest/**/*",
"**/src/test/**/*",
"**/src/mock/**/*",
"**/node_modules/**/*",
"**/oh_modules/**/*",
"**/build/**/*",
"**/.preview/**/*"
],
"ruleSet": [
"plugin:@performance/recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
}
}

View File

@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": false,
"files": [
"./obfuscation-rules.txt"
]
}
}
}
},
],
"targets": [
{
"name": "default"
},
{
"name": "ohosTest",
}
]
}

View File

@ -0,0 +1,6 @@
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}

View File

@ -0,0 +1,23 @@
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
-enable-property-obfuscation
-enable-toplevel-obfuscation
-enable-filename-obfuscation
-enable-export-obfuscation

View File

@ -0,0 +1,15 @@
{
"name": "entry",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {
"harATest": "file:../harA",
"harBTest": "file:../harB",
"hspATest": "file:../hspA",
"hspBTest": "file:../hspB"
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* 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.
*/
import { hilog } from '@kit.PerformanceAnalysisKit';
class Logger {
private domain: number;
private prefix: string;
private format: string = '%{public}s, %{public}s';
constructor(prefix: string) {
this.prefix = prefix;
this.domain = 0xFF00;
}
debug(...args: string[]) {
hilog.debug(this.domain, this.prefix, this.format, args);
}
info(...args: string[]) {
hilog.info(this.domain, this.prefix, this.format, args);
}
warn(...args: string[]) {
hilog.warn(this.domain, this.prefix, this.format, args);
}
error(...args: string[]) {
hilog.error(this.domain, this.prefix, this.format, args);
}
}
export default new Logger('[Sample_SystemRouter]');

View File

@ -0,0 +1,41 @@
import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
}
onDestroy(): void {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage): void {
// Main window is created, set main page for this ability
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
});
}
onWindowStageDestroy(): void {
// Main window is destroyed, release UI related resources
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground(): void {
// Ability has brought to foreground
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground(): void {
// Ability has back to background
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
}

View File

@ -0,0 +1,12 @@
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
export default class EntryBackupAbility extends BackupExtensionAbility {
async onBackup() {
hilog.info(0x0000, 'testTag', 'onBackup ok');
}
async onRestore(bundleVersion: BundleVersion) {
hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import Logger from '../common/utils/Logger';
@Builder
export function PageOneBuilder(name: string, param: Object) {
PageOne()
}
const COLUMN_SPACE: number = 12;
@Component
export struct PageOne {
pageInfos: NavPathStack = new NavPathStack();
build() {
NavDestination() {
Column({ space: COLUMN_SPACE }) {
Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Clear all pages in the stack.
this.pageInfos.clear();
})
Button($r('app.string.entry_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageTwo', null);
})
Button($r('app.string.harA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageOne', null);
})
Button($r('app.string.harA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageTwo', null);
})
Button($r('app.string.harB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarBPageOne', null);
})
Button($r('app.string.harB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarBPageTwo', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title('entry-pageOne')
.onReady((context: NavDestinationContext) => {
this.pageInfos = context.pathStack;
Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
})
}
}

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import Logger from '../common/utils/Logger';
@Builder
export function PageTwoBuilder(name: string, param: Object) {
PageTwo()
}
const COLUMN_SPACE: number = 12;
@Component
export struct PageTwo {
pageInfos: NavPathStack = new NavPathStack();
build() {
NavDestination() {
Column({ space: COLUMN_SPACE }) {
Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
this.pageInfos.clear(); //Clear all pages in the stack
})
Button($r('app.string.entry_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageOne', null);
})
Button($r('app.string.hspA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageOne', null);
})
Button($r('app.string.hspA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageTwo', null);
})
Button($r('app.string.hspB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspBPageOne', null);
})
Button($r('app.string.hspB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspBPageTwo', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title('entry-pageTwo')
.onReady((context: NavDestinationContext) => {
this.pageInfos = context.pathStack
Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
})
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
@Entry
@Component
struct NavigationExample {
pageInfos: NavPathStack = new NavPathStack();
build() {
Navigation(this.pageInfos) {
Column({ space: 12 }) {
Button($r('app.string.entry_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageOne', null);
})
Button($r('app.string.entry_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageTwo', null);
})
Button($r('app.string.harA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageOne', null);
})
Button($r('app.string.harA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageTwo', null);
})
Button($r('app.string.hspA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageOne', null);
})
Button($r('app.string.hspA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageTwo', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title($r('app.string.entry_index_title'))
}
}

View File

@ -0,0 +1,66 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"routerMap": "$profile:router_map",
"abilities": [
{
"name": "EntryAbility",
"srcEntry": "./ets/entryability/EntryAbility.ets",
"description": "$string:EntryAbility_desc",
"icon": "$media:app_icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:startIcon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "EntryBackupAbility",
"srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
"type": "backup",
"exported": false,
"metadata": [
{
"name": "ohos.extension.backup",
"resource": "$profile:backup_config"
}
]
}
]
}
}

View File

@ -0,0 +1,8 @@
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}

View File

@ -0,0 +1,84 @@
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "Navigation systemRouting"
},
{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,7 @@
{
"layered-image":
{
"background" : "$media:background",
"foreground" : "$media:foreground"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,3 @@
{
"allowToBackupRestore": true
}

View File

@ -0,0 +1,5 @@
{
"src": [
"pages/Index"
]
}

View File

@ -0,0 +1,17 @@
{
"routerMap": [
{
"name": "pageOne",
"pageSourceFile": "src/main/ets/pages/EntryPageOne.ets",
"buildFunction": "PageOneBuilder",
"data": {
"description": "this is pageOne"
}
},
{
"name": "pageTwo",
"pageSourceFile": "src/main/ets/pages/EntryPageTwo.ets",
"buildFunction": "PageTwoBuilder"
}
]
}

View File

@ -0,0 +1,84 @@
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "Navigation systemRouting"
},
{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
}
]
}

View File

@ -0,0 +1,84 @@
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "导航系统路由"
},
{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
}
]
}

View File

@ -0,0 +1,261 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import { Driver, ON } from '@ohos.UiTest';
// 启动前需要安装手动安装HSP包再执行
let abilityDelegatorRegistry = AbilityDelegatorRegistry.getAbilityDelegator();
export default function abilityTest() {
describe('ActsAbilityTest', () => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
})
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
})
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
})
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
})
/**
* 拉起应用
*/
it(`StartAbility_001`, 0, async (done: Function) => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0xF811, 'testTag', 'StartAbility_001 begin');
try {
await abilityDelegatorRegistry.startAbility({
bundleName: "com.samples.systemrouter",
abilityName: 'EntryAbility'
});
done();
} catch (err) {
expect(0).assertEqual(err.code);
done();
}
hilog.info(0xF811, 'testTag', 'StartAbility_001 end');
})
/**
* 从主页跳转到entry-pageOne
*/
it('TestCase_002', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toEntryPageOne"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("entry-pageOne"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从entry-pageOne跳转到主页
*/
it('TestCase_003', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toIndex"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("NavIndex"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从主页跳转到entry-pageTwo
*/
it('TestCase_004', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toEntryPageTwo"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("entry-pageTwo"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从entry-pageTwo跳转到主页
*/
it('TestCase_005', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toIndex"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("NavIndex"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从主页跳转到harA-pageOne
*/
it('TestCase_006', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toHarAPageOne"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("harA-pageOne"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从harA-pageOne跳转到主页
*/
it('TestCase_007', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toIndex"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("NavIndex"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从主页跳转到harA-pageTwo
*/
it('TestCase_008', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toHarAPageTwo"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("harA-pageTwo"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从harA-pageTwo跳转到主页
*/
it('TestCase_009', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toIndex"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("NavIndex"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从主页跳转到hspA-pageOne
*/
it('TestCase_010', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toHspAPageOne"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("hspA-pageOne"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从hspA-pageOne跳转到主页
*/
it('TestCase_011', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toIndex"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("NavIndex"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从主页跳转到hspA-pageTwo
*/
it('TestCase_012', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toHspAPageTwo"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("hspA-pageTwo"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
/**
* 从hspA-pageTwo跳转到主页
*/
it('TestCase_013', 0, async () => {
let driver = Driver.create();
await driver.delayMs(1000);
let btnItem = await driver.findComponent(ON.text("toIndex"));
await btnItem.click();
await driver.delayMs(1000);
// 获取标题
let title = await driver.findComponent(ON.text("NavIndex"));
// 检查
expect(title != undefined).assertTrue();
await driver.delayMs(1000);
})
})
}

View File

@ -0,0 +1,5 @@
import abilityTest from './Ability.test';
export default function testsuite() {
abilityTest();
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"module": {
"name": "entry_test",
"type": "feature",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false
}
}

View File

@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test

View File

@ -0,0 +1 @@
export { MainPage } from './src/main/ets/components/MainPage'

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": false,
"files": [
"./obfuscation-rules.txt"
]
},
"consumerFiles": [
"./consumer-rules.txt"
]
}
},
},
],
"targets": [
{
"name": "default"
},
{
"name": "ohosTest"
}
]
}

View File

@ -0,0 +1,6 @@
import { harTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}

View File

@ -0,0 +1,23 @@
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
-enable-property-obfuscation
-enable-toplevel-obfuscation
-enable-filename-obfuscation
-enable-export-obfuscation

View File

@ -0,0 +1,9 @@
{
"name": "hara",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* 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.
*/
import { hilog } from '@kit.PerformanceAnalysisKit';
class Logger {
private domain: number;
private prefix: string;
private format: string = '%{public}s, %{public}s';
constructor(prefix: string) {
this.prefix = prefix;
this.domain = 0xFF00;
}
debug(...args: string[]) {
hilog.debug(this.domain, this.prefix, this.format, args);
}
info(...args: string[]) {
hilog.info(this.domain, this.prefix, this.format, args);
}
warn(...args: string[]) {
hilog.warn(this.domain, this.prefix, this.format, args);
}
error(...args: string[]) {
hilog.error(this.domain, this.prefix, this.format, args);
}
}
export default new Logger('[Sample_SystemRouter]');

View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
@Component
export struct MainPage {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width($r('app.string.full_percent'))
}
.height($r('app.string.full_percent'))
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import Logger from '../common/utils/Logger';
@Builder
export function HarAPageOneBuilder(name: string, param: Object) {
HarAPageOne()
}
const COLUMN_SPACE: number = 12;
@Component
export struct HarAPageOne {
pageInfos: NavPathStack = new NavPathStack();
build() {
NavDestination() {
Column({ space: COLUMN_SPACE }) {
Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Clear all pages in the stack.
this.pageInfos.clear();
})
Button($r('app.string.entry_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageOne', null);
})
Button($r('app.string.entry_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageTwo', null);
})
Button($r('app.string.harA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageTwo', null);
})
Button($r('app.string.harB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarBPageOne', null);
})
Button($r('app.string.harB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarBPageTwo', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title('harA-pageOne')
.onReady((context: NavDestinationContext) => {
this.pageInfos = context.pathStack
Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
})
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import Logger from '../common/utils/Logger';
@Builder
export function HarAPageTwoBuilder(name: string, param: Object) {
HarAPageTwo()
}
const COLUMN_SPACE: number = 12;
@Component
export struct HarAPageTwo {
pageInfos: NavPathStack = new NavPathStack();
build() {
NavDestination() {
Column({ space: COLUMN_SPACE }) {
Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Clear all pages in the stack.
this.pageInfos.clear();
})
Button($r('app.string.harA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageOne', null);
})
Button($r('app.string.hspA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageOne', null);
})
Button($r('app.string.hspA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageTwo', null);
})
Button($r('app.string.hspB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspBPageOne', null);
})
Button($r('app.string.hspB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspBPageTwo', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title('harA-pageTwo')
.onReady((context: NavDestinationContext) => {
this.pageInfos = context.pathStack
Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
})
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"module": {
"name": "harA",
"type": "har",
"deviceTypes": [
"default",
"tablet"
],
"routerMap": "$profile:router_map"
}
}

View File

@ -0,0 +1,84 @@
{
"string": [
{
"name": "page_show",
"value": "page from package"
},
{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "button_margin",
"value": "20"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
},
{
"name": "full_percent",
"value": "100%"
}
]
}

View File

@ -0,0 +1,17 @@
{
"routerMap": [
{
"name": "HarAPageOne",
"pageSourceFile": "src/main/ets/pages/HarAPageOne.ets",
"buildFunction": "HarAPageOneBuilder",
"data": {
"description": "this is pageOne"
}
},
{
"name": "HarAPageTwo",
"pageSourceFile": "src/main/ets/pages/HarAPageTwo.ets",
"buildFunction": "HarAPageTwoBuilder"
}
]
}

View File

@ -0,0 +1,84 @@
{
"string": [
{
"name": "page_show",
"value": "page from package"
},
{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "button_margin",
"value": "20"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
},
{
"name": "full_percent",
"value": "100%"
}
]
}

View File

@ -0,0 +1,84 @@
{
"string": [
{
"name": "page_show",
"value": "page from package"
},
{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "button_margin",
"value": "20"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
},
{
"name": "full_percent",
"value": "100%"
}
]
}

View File

@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test

View File

@ -0,0 +1 @@
export { MainPage } from './src/main/ets/components/MainPage'

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": false,
"files": [
"./obfuscation-rules.txt"
]
},
"consumerFiles": [
"./consumer-rules.txt"
]
}
},
},
],
"targets": [
{
"name": "default"
},
{
"name": "ohosTest"
}
]
}

View File

@ -0,0 +1,6 @@
import { harTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}

View File

@ -0,0 +1,23 @@
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
-enable-property-obfuscation
-enable-toplevel-obfuscation
-enable-filename-obfuscation
-enable-export-obfuscation

View File

@ -0,0 +1,9 @@
{
"name": "harb",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* 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.
*/
import { hilog } from '@kit.PerformanceAnalysisKit';
class Logger {
private domain: number;
private prefix: string;
private format: string = '%{public}s, %{public}s';
constructor(prefix: string) {
this.prefix = prefix;
this.domain = 0xFF00;
}
debug(...args: string[]) {
hilog.debug(this.domain, this.prefix, this.format, args);
}
info(...args: string[]) {
hilog.info(this.domain, this.prefix, this.format, args);
}
warn(...args: string[]) {
hilog.warn(this.domain, this.prefix, this.format, args);
}
error(...args: string[]) {
hilog.error(this.domain, this.prefix, this.format, args);
}
}
export default new Logger('[Sample_SystemRouter]');

View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
@Component
export struct MainPage {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width($r('app.string.full_percent'))
}
.height($r('app.string.full_percent'))
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import Logger from '../common/utils/Logger';
@Builder
export function HarBPageOneBuilder(name: string, param: Object) {
HarBPageOne()
}
const COLUMN_SPACE: number = 12;
@Component
export struct HarBPageOne {
pageInfos: NavPathStack = new NavPathStack();
build() {
NavDestination() {
Column({ space: COLUMN_SPACE }) {
Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Clear all pages in the stack.
this.pageInfos.clear();
})
Button($r('app.string.entry_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageOne', null);
})
Button($r('app.string.entry_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageTwo', null);
})
Button($r('app.string.harA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageOne', null);
})
Button($r('app.string.harA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageTwo', null);
})
Button($r('app.string.harB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarBPageTwo', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title('harB-pageOne')
.onReady((context: NavDestinationContext) => {
this.pageInfos = context.pathStack
Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
})
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import Logger from '../common/utils/Logger';
@Builder
export function HarBPageTwoBuilder(name: string, param: Object) {
HarBPageTwo()
}
const COLUMN_SPACE: number = 12;
@Component
export struct HarBPageTwo {
pageInfos: NavPathStack = new NavPathStack();
build() {
NavDestination() {
Column({ space: COLUMN_SPACE }) {
Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Clear all pages in the stack.
this.pageInfos.clear();
})
Button($r('app.string.harB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarBPageOne', null);
})
Button($r('app.string.hspA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageOne', null);
})
Button($r('app.string.hspA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageTwo', null);
})
Button($r('app.string.hspB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspBPageOne', null);
})
Button($r('app.string.hspB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspBPageTwo', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title('harB-pageTwo')
.onReady((context: NavDestinationContext) => {
this.pageInfos = context.pathStack
Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
})
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"module": {
"name": "harB",
"type": "har",
"deviceTypes": [
"default",
"tablet"
],
"routerMap": "$profile:router_map"
}
}

View File

@ -0,0 +1,84 @@
{
"string": [
{
"name": "page_show",
"value": "page from package"
},
{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "button_margin",
"value": "20"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
},
{
"name": "full_percent",
"value": "100%"
}
]
}

View File

@ -0,0 +1,17 @@
{
"routerMap": [
{
"name": "HarBPageOne",
"pageSourceFile": "src/main/ets/pages/HarBPageOne.ets",
"buildFunction": "HarBPageOneBuilder",
"data": {
"description": "this is pageOne"
}
},
{
"name": "HarBPageTwo",
"pageSourceFile": "src/main/ets/pages/HarBPageTwo.ets",
"buildFunction": "HarBPageTwoBuilder"
}
]
}

View File

@ -0,0 +1,84 @@
{
"string": [
{
"name": "page_show",
"value": "page from package"
},
{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "button_margin",
"value": "20"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
},
{
"name": "full_percent",
"value": "100%"
}
]
}

View File

@ -0,0 +1,84 @@
{
"string": [
{
"name": "page_show",
"value": "page from package"
},
{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "button_margin",
"value": "20"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
},
{
"name": "full_percent",
"value": "100%"
}
]
}

View File

@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test

View File

@ -0,0 +1 @@
export { add } from './src/main/ets/utils/Calc'

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": false,
"files": [
"./obfuscation-rules.txt"
]
}
}
},
},
],
"targets": [
{
"name": "default"
},
{
"name": "ohosTest"
}
]
}

View File

@ -0,0 +1,6 @@
import { hspTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}

View File

@ -0,0 +1,23 @@
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
-enable-property-obfuscation
-enable-toplevel-obfuscation
-enable-filename-obfuscation
-enable-export-obfuscation

View File

@ -0,0 +1,11 @@
{
"name": "hspa",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"packageType": "InterfaceHar",
"dependencies": {
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* 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.
*/
import { hilog } from '@kit.PerformanceAnalysisKit';
class Logger {
private domain: number;
private prefix: string;
private format: string = '%{public}s, %{public}s';
constructor(prefix: string) {
this.prefix = prefix;
this.domain = 0xFF00;
}
debug(...args: string[]) {
hilog.debug(this.domain, this.prefix, this.format, args);
}
info(...args: string[]) {
hilog.info(this.domain, this.prefix, this.format, args);
}
warn(...args: string[]) {
hilog.warn(this.domain, this.prefix, this.format, args);
}
error(...args: string[]) {
hilog.error(this.domain, this.prefix, this.format, args);
}
}
export default new Logger('[Sample_SystemRouter]');

View File

@ -0,0 +1,90 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import Logger from '../common/utils/Logger';
@Builder
export function HspAPageOneBuilder(name: string, param: Object) {
HspAPageOne()
}
const COLUMN_SPACE: number = 12;
@Component
export struct HspAPageOne {
pageInfos: NavPathStack = new NavPathStack();
build() {
NavDestination() {
Column({ space: COLUMN_SPACE }) {
Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Clear all pages in the stack.
this.pageInfos.clear();
})
Button($r('app.string.entry_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageOne', null);
})
Button($r('app.string.entry_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageTwo', null);
})
Button($r('app.string.hspA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageTwo', null);
})
Button($r('app.string.hspB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspBPageOne', null);
})
Button($r('app.string.hspB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspBPageTwo', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title('hspA-pageOne')
.onReady((context: NavDestinationContext) => {
this.pageInfos = context.pathStack
Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
})
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import Logger from '../common/utils/Logger';
@Builder
export function HspAPageTwoBuilder(name: string, param: Object) {
HspAPageTwo()
}
const COLUMN_SPACE: number = 12;
@Component
export struct HspAPageTwo {
pageInfos: NavPathStack = new NavPathStack();
build() {
NavDestination() {
Column({ space: COLUMN_SPACE }) {
Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Clear all pages in the stack.
this.pageInfos.clear();
})
Button($r('app.string.hspA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageOne', null);
})
Button($r('app.string.harA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageOne', null);
})
Button($r('app.string.harA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageTwo', null);
})
Button($r('app.string.harB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarBPageOne', null);
})
Button($r('app.string.harB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarBPageTwo', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title('hspA-pageTwo')
.onReady((context: NavDestinationContext) => {
this.pageInfos = context.pathStack
Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
})
}
}

View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
@Entry
@Component
export struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width($r('app.string.full_percent'))
}
.height($r('app.string.full_percent'))
}
}

View File

@ -0,0 +1,3 @@
export function add(a: number, b: number) {
return a + b;
}

View File

@ -0,0 +1,29 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"module": {
"name": "hspA",
"type": "shared",
"description": "$string:shared_desc",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"pages": "$profile:main_pages",
"routerMap": "$profile:router_map"
}
}

View File

@ -0,0 +1,83 @@
{
"string": [
{
"name": "shared_desc",
"value": "description"
},{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "button_margin",
"value": "20"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
},
{
"name": "full_percent",
"value": "100%"
}
]
}

View File

@ -0,0 +1,5 @@
{
"src": [
"pages/Index"
]
}

View File

@ -0,0 +1,17 @@
{
"routerMap": [
{
"name": "HspAPageOne",
"pageSourceFile": "src/main/ets/pages/HspAPageOne.ets",
"buildFunction": "HspAPageOneBuilder",
"data": {
"description": "this is pageOne"
}
},
{
"name": "HspAPageTwo",
"pageSourceFile": "src/main/ets/pages/HspAPageTwo.ets",
"buildFunction": "HspAPageTwoBuilder"
}
]
}

View File

@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test

View File

@ -0,0 +1 @@
export { add } from './src/main/ets/utils/Calc'

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": false,
"files": [
"./obfuscation-rules.txt"
]
}
}
},
},
],
"targets": [
{
"name": "default"
},
{
"name": "ohosTest"
}
]
}

View File

@ -0,0 +1,6 @@
import { hspTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}

View File

@ -0,0 +1,23 @@
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
-enable-property-obfuscation
-enable-toplevel-obfuscation
-enable-filename-obfuscation
-enable-export-obfuscation

View File

@ -0,0 +1,11 @@
{
"name": "hspb",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"packageType": "InterfaceHar",
"dependencies": {
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* 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.
*/
import { hilog } from '@kit.PerformanceAnalysisKit';
class Logger {
private domain: number;
private prefix: string;
private format: string = '%{public}s, %{public}s';
constructor(prefix: string) {
this.prefix = prefix;
this.domain = 0xFF00;
}
debug(...args: string[]) {
hilog.debug(this.domain, this.prefix, this.format, args);
}
info(...args: string[]) {
hilog.info(this.domain, this.prefix, this.format, args);
}
warn(...args: string[]) {
hilog.warn(this.domain, this.prefix, this.format, args);
}
error(...args: string[]) {
hilog.error(this.domain, this.prefix, this.format, args);
}
}
export default new Logger('[Sample_SystemRouter]');

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import Logger from '../common/utils/Logger';
@Builder
export function HspBPageOneBuilder(name: string, param: Object) {
HspBPageOne()
}
const COLUMN_SPACE: number = 12;
@Component
export struct HspBPageOne {
pageInfos: NavPathStack = new NavPathStack();
build() {
NavDestination() {
Column({ space: COLUMN_SPACE }) {
Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Clear all pages in the stack.
this.pageInfos.clear();
})
Button($r('app.string.hspB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspBPageTwo', null);
})
Button($r('app.string.harA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageOne', null);
})
Button($r('app.string.harA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarAPageTwo', null);
})
Button($r('app.string.harB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarBPageOne', null);
})
Button($r('app.string.harB_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HarBPageTwo', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title('hspB-pageOne')
.onReady((context: NavDestinationContext) => {
this.pageInfos = context.pathStack
Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
})
}
}

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
import Logger from '../common/utils/Logger';
@Builder
export function HspBPageTwoBuilder(name: string, param: Object) {
HspBPageTwo()
}
const COLUMN_SPACE: number = 12;
@Component
export struct HspBPageTwo {
pageInfos: NavPathStack = new NavPathStack();
build() {
NavDestination() {
Column({ space: COLUMN_SPACE }) {
Button($r('app.string.entry_index'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Clear all pages in the stack.
this.pageInfos.clear();
})
Button($r('app.string.entry_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageOne', null);
})
Button($r('app.string.entry_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('pageTwo', null);
})
Button($r('app.string.hspA_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageOne', null);
})
Button($r('app.string.hspA_pageTwo'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspAPageTwo', null);
})
Button($r('app.string.hspB_pageOne'), { stateEffect: true, type: ButtonType.Capsule })
.width($r('app.string.button_width'))
.height($r('app.string.button_height'))
.onClick(() => {
//Push the NavDestination page information specified by name onto the stack, and pass the data as param.
this.pageInfos.pushPathByName('HspBPageOne', null);
})
}
.width($r('app.string.navDestination_width'))
.height($r('app.string.navDestination_height'))
.justifyContent(FlexAlign.End)
.padding({
bottom: $r('app.string.column_padding'),
left: $r('app.string.column_padding'),
right: $r('app.string.column_padding')
})
}
.title('hspB-pageTwo')
.onReady((context: NavDestinationContext) => {
this.pageInfos = context.pathStack
Logger.info('current page config info is ' + JSON.stringify(context.getConfigInRouteMap()));
})
}
}

View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
@Entry
@Component
export struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width($r('app.string.full_percent'))
}
.height($r('app.string.full_percent'))
}
}

View File

@ -0,0 +1,3 @@
export function add(a: number, b: number) {
return a + b;
}

View File

@ -0,0 +1,29 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* 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.
*/
{
"module": {
"name": "hspB",
"type": "shared",
"description": "$string:shared_desc",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"pages": "$profile:main_pages",
"routerMap": "$profile:router_map"
}
}

View File

@ -0,0 +1,83 @@
{
"string": [
{
"name": "shared_desc",
"value": "description"
},{
"name": "navDestination_width",
"value": "100%"
},
{
"name": "navDestination_height",
"value": "100%"
},
{
"name": "button_width",
"value": "100%"
},
{
"name": "button_height",
"value": "40"
},
{
"name": "button_margin",
"value": "20"
},
{
"name": "column_padding",
"value": "16"
},
{
"name": "entry_index_title",
"value": "NavIndex"
},
{
"name": "entry_index",
"value": "toIndex"
},
{
"name": "entry_pageOne",
"value": "toEntryPageOne"
},
{
"name": "entry_pageTwo",
"value": "toEntryPageTwo"
},
{
"name": "harA_pageOne",
"value": "toHarAPageOne"
},
{
"name": "harA_pageTwo",
"value": "toHarAPageTwo"
},
{
"name": "harB_pageOne",
"value": "toHarBPageOne"
},
{
"name": "harB_pageTwo",
"value": "toHarBPageTwo"
},
{
"name": "hspA_pageOne",
"value": "toHspAPageOne"
},
{
"name": "hspA_pageTwo",
"value": "toHspAPageTwo"
},
{
"name": "hspB_pageOne",
"value": "toHspBPageOne"
},
{
"name": "hspB_pageTwo",
"value": "toHspBPageTwo"
},
{
"name": "full_percent",
"value": "100%"
}
]
}

View File

@ -0,0 +1,5 @@
{
"src": [
"pages/Index"
]
}

View File

@ -0,0 +1,17 @@
{
"routerMap": [
{
"name": "HspBPageOne",
"pageSourceFile": "src/main/ets/pages/HspBPageOne.ets",
"buildFunction": "HspBPageOneBuilder",
"data": {
"description": "this is pageOne"
}
},
{
"name": "HspBPageTwo",
"pageSourceFile": "src/main/ets/pages/HspBPageTwo.ets",
"buildFunction": "HspBPageTwoBuilder"
}
]
}

View File

@ -0,0 +1,22 @@
{
"modelVersion": "5.0.0",
"dependencies": {
},
"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*/
}
}

View File

@ -0,0 +1,6 @@
import { appTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Some files were not shown because too many files have changed in this diff Show More