diff --git a/UI/JsRouter/README_zh.md b/UI/JsRouter/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..a3a1dcbe8e553d3c153e66633c3453beb7e1a99b --- /dev/null +++ b/UI/JsRouter/README_zh.md @@ -0,0 +1,15 @@ +# 页面路由 + +### 简介 + +本示例使用router接口来实现页面跳转能力,以及页面跳转过程中参数的传递。 + +### 使用说明 + +点击页面文本内容,页面跳转到指定的页面。 + +### 约束与限制 + +注意:页面路由需要在页面渲染完成之后才能调用,在onInit和onReady生命周期中页面还处于渲染阶段,禁止调用页面路由方法。 + +本示例仅支持在标准系统上运行。 \ No newline at end of file diff --git a/UI/JsRouter/build.gradle b/UI/JsRouter/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..bbe463c74d9fc7d2ffb0e2d94e3204426a0015ad --- /dev/null +++ b/UI/JsRouter/build.gradle @@ -0,0 +1,34 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'com.huawei.ohos.app' + +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } + dependencies { + classpath 'com.huawei.ohos:hap:2.4.4.3-RC' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } +} diff --git a/UI/JsRouter/entry/build.gradle b/UI/JsRouter/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..bdd062a7561aa5eb7aff41d19322ee21d13a72a5 --- /dev/null +++ b/UI/JsRouter/entry/build.gradle @@ -0,0 +1,17 @@ +apply plugin: 'com.huawei.ohos.hap' + +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + supportSystem "standard" +} \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/config.json b/UI/JsRouter/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..d419a29f909e7bfc646c76d6d6f3143902d97476 --- /dev/null +++ b/UI/JsRouter/entry/src/main/config.json @@ -0,0 +1,58 @@ +{ + "app": { + "bundleName": "ohos.samples.router", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.router", + "name": ".MyApplication", + "mainAbility": "ohos.samples.router.MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "ohos.samples.router.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index", + "pages/pushPage/index", + "pages/replacePage/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + } + ] + } +} \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/js/default/app.js b/UI/JsRouter/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..d7e076f8bc1c94876554011c7dc9cef4385e1593 --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/app.js @@ -0,0 +1,24 @@ +'@file function' +/* + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/UI/JsRouter/entry/src/main/js/default/common/index.css b/UI/JsRouter/entry/src/main/js/default/common/index.css new file mode 100644 index 0000000000000000000000000000000000000000..93bfad3f30366ec76a01706a364e1081ae137b91 --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/common/index.css @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2021 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 30px; + color: black; + opacity: .9; +} \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/js/default/i18n/en-US.json b/UI/JsRouter/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..edc5cfcd32e79400f16d9dd118ce35efa3b1e844 --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,9 @@ +{ + "strings": { + "hello": "Hello", + "world": "Home page", + "push": "This is the push page. Welcome", + "value": "Value passed on the home page", + "replace": "This is the Replace page" + } +} \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/js/default/i18n/zh-CN.json b/UI/JsRouter/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..ac7a4580a1365c365d7757928aec3ee779ae73ed --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,9 @@ +{ + "strings": { + "hello": "您好,", + "page": "首页", + "push": "这是push页面,欢迎", + "value": "首页传递的值", + "replace": "这是replace页面" + } +} \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/js/default/pages/index/index.css b/UI/JsRouter/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..be3890a4da5b75de4eaf9538e6b9a41905f00f8e --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1 @@ +@import '../../common/index.css'; \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/js/default/pages/index/index.hml b/UI/JsRouter/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..efdc4198b98f64fcb68fa3ea22c68a50266f9421 --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,20 @@ + + +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/UI/JsRouter/entry/src/main/js/default/pages/index/index.js b/UI/JsRouter/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..2c5599895cd3ffab03576d980cc1d693418b3d97 --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,35 @@ +'@file function' +/* + * Copyright (c) 2021 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 router from '@system.router'; + +export default { + data: { + title: '' + }, + onInit() { + this.title = this.$t('strings.page'); + }, + pushPage() { + router.push({ + uri: 'pages/pushPage/index', + params: { + data1: + this.$t('strings.value') + } + }); + } +}; diff --git a/UI/JsRouter/entry/src/main/js/default/pages/pushPage/index.css b/UI/JsRouter/entry/src/main/js/default/pages/pushPage/index.css new file mode 100644 index 0000000000000000000000000000000000000000..be3890a4da5b75de4eaf9538e6b9a41905f00f8e --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/pages/pushPage/index.css @@ -0,0 +1 @@ +@import '../../common/index.css'; \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/js/default/pages/pushPage/index.hml b/UI/JsRouter/entry/src/main/js/default/pages/pushPage/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..42368e59dd9e1a917ff0b37f8f9cfcf68c83cb5f --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/pages/pushPage/index.hml @@ -0,0 +1,20 @@ + + +
+ + {{ $t('strings.hello') }} {{ $t('strings.push') }} {{ data1 }} + +
\ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/js/default/pages/pushPage/index.js b/UI/JsRouter/entry/src/main/js/default/pages/pushPage/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7a102a3712bdd3d40728bae6359ff7d3df1067be --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/pages/pushPage/index.js @@ -0,0 +1,28 @@ +'@file function' +/* + * Copyright (c) 2021 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 router from '@system.router'; + +export default { + data: { + data1: 'default' + }, + replacePage() { + router.replace({ + uri: 'pages/replacePage/index' + }); + } +}; \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/js/default/pages/replacePage/index.css b/UI/JsRouter/entry/src/main/js/default/pages/replacePage/index.css new file mode 100644 index 0000000000000000000000000000000000000000..be3890a4da5b75de4eaf9538e6b9a41905f00f8e --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/pages/replacePage/index.css @@ -0,0 +1 @@ +@import '../../common/index.css'; \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/js/default/pages/replacePage/index.hml b/UI/JsRouter/entry/src/main/js/default/pages/replacePage/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..afa35b80d0a26b60a8adf6265d18a11c738177e6 --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/pages/replacePage/index.hml @@ -0,0 +1,20 @@ + + +
+ + {{ $t('strings.hello') }} {{ dataValue }} + +
\ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/js/default/pages/replacePage/index.js b/UI/JsRouter/entry/src/main/js/default/pages/replacePage/index.js new file mode 100644 index 0000000000000000000000000000000000000000..26e77f8f3dcfb6a4c04639ee362daaa1658ca195 --- /dev/null +++ b/UI/JsRouter/entry/src/main/js/default/pages/replacePage/index.js @@ -0,0 +1,31 @@ +'@file function' +/* + * Copyright (c) 2021 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 router from '@system.router'; + +export default { + data: { + dataValue: '' + }, + onInit() { + this.dataValue = this.$t('strings.replace'); + }, + backPage() { + router.back({ + uri: 'pages/index/index' + }); + } +}; \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/resources/base/element/string.json b/UI/JsRouter/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..cfb90cdb72c3db62f39c8b3d037913bd3ca8d7ca --- /dev/null +++ b/UI/JsRouter/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Router" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/UI/JsRouter/entry/src/main/resources/base/media/icon.png b/UI/JsRouter/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/UI/JsRouter/entry/src/main/resources/base/media/icon.png differ diff --git a/UI/JsRouter/screenshots/device/homePage.png b/UI/JsRouter/screenshots/device/homePage.png new file mode 100644 index 0000000000000000000000000000000000000000..94c1adc3b25c917f52b903bdc19e930031eb1d1f Binary files /dev/null and b/UI/JsRouter/screenshots/device/homePage.png differ diff --git a/UI/JsRouter/screenshots/device/pushPage.png b/UI/JsRouter/screenshots/device/pushPage.png new file mode 100644 index 0000000000000000000000000000000000000000..a424aa7d0f037c46b40338aec8ce0ec9b055123f Binary files /dev/null and b/UI/JsRouter/screenshots/device/pushPage.png differ diff --git a/UI/JsRouter/screenshots/device/replacePage.png b/UI/JsRouter/screenshots/device/replacePage.png new file mode 100644 index 0000000000000000000000000000000000000000..542d93130ecf096d238b1c465418e96b98847406 Binary files /dev/null and b/UI/JsRouter/screenshots/device/replacePage.png differ diff --git a/UI/JsRouter/settings.gradle b/UI/JsRouter/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..4773db73233a570c2d0c01a22e75321acfbf7a07 --- /dev/null +++ b/UI/JsRouter/settings.gradle @@ -0,0 +1 @@ +include ':entry'