diff --git a/thread/JsWorker/README_zh.md b/thread/JsWorker/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..0de2cfc76b0f0c236ca1aae8ba330133aa5de687 --- /dev/null +++ b/thread/JsWorker/README_zh.md @@ -0,0 +1,19 @@ +# JsWorker + + + +### 简介 + +本示例展示了在Js中如何启动一个worker线程,并实现worker线程和宿主线程的通信。 + +### 使用说明 + +1、在首页中显示了排序前的四个字符串,点击**字符串排序**按钮,会将排序前的字符串发送给worker线程,在worker线程实现字符串排序,然后将排序后的字符串发送给主线程,主线程中显示排序后的字符串。 + +2、点击**清除**按钮,清除排序后的字符串。 + + + +### 约束与限制 + +本示例仅支持标准系统上运行。 diff --git a/thread/JsWorker/build.gradle b/thread/JsWorker/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..8469dbed391d35ea3560bcb82b1258e27bdeb09a --- /dev/null +++ b/thread/JsWorker/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' + +// For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 7 + supportSystem "standard" +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } + dependencies { + classpath 'com.huawei.ohos:hap:3.0.3.4' + classpath 'com.huawei.ohos:decctest:1.2.6.0' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } +} diff --git a/thread/JsWorker/entry/build.gradle b/thread/JsWorker/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..895f5ab55babc59d9158eda9724930a93d1c9c72 --- /dev/null +++ b/thread/JsWorker/entry/build.gradle @@ -0,0 +1,21 @@ +apply plugin: 'com.huawei.ohos.hap' +// For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 7 + defaultConfig { + compatibleSdkVersion 7 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + testImplementation 'junit:junit:4.13.1' +} diff --git a/thread/JsWorker/entry/src/main/config.json b/thread/JsWorker/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..d4c96c5d84e3f037c94ecaea025a92a51ae75b51 --- /dev/null +++ b/thread/JsWorker/entry/src/main/config.json @@ -0,0 +1,60 @@ +{ + "app": { + "bundleName": "ohos.samples.jsworker", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.jsworker", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "js", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/thread/JsWorker/entry/src/main/js/MainAbility/app.js b/thread/JsWorker/entry/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..58d12b7b501fbf46db906a86187aaf18dfb1f677 --- /dev/null +++ b/thread/JsWorker/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * 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("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } +}; diff --git a/thread/JsWorker/entry/src/main/js/MainAbility/i18n/en-US.json b/thread/JsWorker/entry/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..2bc254fa3d24cd2526a5e8552a091ab1270f506c --- /dev/null +++ b/thread/JsWorker/entry/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,12 @@ +{ + "strings": { + "title": "JsWorker", + "tip_before": "Before sort:", + "tip_after": "After sort:", + "send_string": "Sort string array", + "clear": "Clear", + "menus": ["string adc","string adcf","string afc","string aaccdd"] + }, + "Files": { + } +} \ No newline at end of file diff --git a/thread/JsWorker/entry/src/main/js/MainAbility/i18n/zh-CN.json b/thread/JsWorker/entry/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..7353845156c22057f94b0de34d937528a7a4773b --- /dev/null +++ b/thread/JsWorker/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,11 @@ +{ + "strings": { + "title": "JsWorker", + "tip_before": "排序前:", + "tip_after": "排序后:", + "send_string": "字符串排序", + "clear": "清除" + }, + "Files": { + } +} \ No newline at end of file diff --git a/thread/JsWorker/entry/src/main/js/MainAbility/pages/index/index.css b/thread/JsWorker/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..50d91acf9a9c06a7420e390d9385ab2d75afd847 --- /dev/null +++ b/thread/JsWorker/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,67 @@ +/* + * 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 { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 42px; + color: #FFFFFF; + opacity: 0.9; + width: 100%; + padding: 10px; + background-color: dodgerblue; + height: 90px; +} + +.content { + width: 100%; + padding: 15px; + align-content: flex-start; + flex-direction: column; +} + +.btn { + width: 90%; + height: 90px; + font-size: 40px; + margin-top: 30px; + align-self: center; +} + +.tip { + font-size: 40px; + color: black; + margin-top: 20px; +} + +.text { + font-size: 40px; + color: black; + opacity: 0.9; + width: 100%; + height: 250px; + padding: 10px; + background-color: #F0F0F0; + margin-top: 10px; +} diff --git a/thread/JsWorker/entry/src/main/js/MainAbility/pages/index/index.hml b/thread/JsWorker/entry/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..9cf0c7dd52286d4a67f9eba8d440308e17310726 --- /dev/null +++ b/thread/JsWorker/entry/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,28 @@ + + +