diff --git a/DFX/JsDotTest/.gitignore b/DFX/JsDotTest/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/DFX/JsDotTest/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/DFX/JsDotTest/README_zh.md b/DFX/JsDotTest/README_zh.md index b63a7108d5b84c1e0b2acaf6032615cb86dfafc1..11fb27fd210bb562d8046c0e8c0cac27cf0089a1 100644 --- a/DFX/JsDotTest/README_zh.md +++ b/DFX/JsDotTest/README_zh.md @@ -32,4 +32,4 @@ 2.性能打点验证只能通过上述命令获取日志来进行验证。 -3.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/DFX/JsDotTest/entry/src/main/js/MainAbility/pages/index/index.hml b/DFX/JsDotTest/entry/src/main/js/MainAbility/pages/index/index.hml index c30232738cb1c30c1363b5d82a9a6de419d80510..d9987717140cee11646a297b01058a31138975fa 100644 --- a/DFX/JsDotTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/DFX/JsDotTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -14,14 +14,14 @@ -->
- {{ $t('strings.appName') }} - {{ this.Text }} -
- -
-
- {{ $t('strings.disable') }} - -
+ {{ $t('strings.appName') }} + {{ this.Text }} +
+ +
+
+ {{ $t('strings.disable') }} + +
diff --git a/DFX/JsDotTest/package.json b/DFX/JsDotTest/package.json index 890101f4d1f566f936302ead461e00937feafe11..511a79fe1fa930e6f7a71070e5af7b9779877538 100644 --- a/DFX/JsDotTest/package.json +++ b/DFX/JsDotTest/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } diff --git a/FileManager/FileIo/.gitignore b/FileManager/FileIo/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/FileManager/FileIo/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/FileManager/FileIo/README_zh.md b/FileManager/FileIo/README_zh.md index 04425af9a9afa56fe702d84a6d07783cd7ed0083..000ea8c458f7a15bf144a4f9534a745adc03b5a2 100644 --- a/FileManager/FileIo/README_zh.md +++ b/FileManager/FileIo/README_zh.md @@ -30,4 +30,4 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/FileManager/FileIo/entry/src/main/ets/MainAbility/pages/Index.ets b/FileManager/FileIo/entry/src/main/ets/MainAbility/pages/Index.ets index 0faf3eadb8d50f48a96c8ff04fe536010841f3b1..107df277e9728563bebe79bdf141dfdebaaf3f56 100644 --- a/FileManager/FileIo/entry/src/main/ets/MainAbility/pages/Index.ets +++ b/FileManager/FileIo/entry/src/main/ets/MainAbility/pages/Index.ets @@ -39,7 +39,7 @@ struct Index { $r('app.string.read_fileIo'), $r('app.string.delete_fileIo') ] - private stream: fileIo.Stream + private stream: fileIo.Stream create_fileIo() { this.result = path + '/xxx.txt' diff --git a/MultiDeviceAppDev/AdaptiveCapabilities/.gitignore b/MultiDeviceAppDev/AdaptiveCapabilities/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/MultiDeviceAppDev/AdaptiveCapabilities/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/MultiDeviceAppDev/AdaptiveCapabilities/README_zh.md b/MultiDeviceAppDev/AdaptiveCapabilities/README_zh.md index 8d55bbac287fe4545c38875244c8129b6083e92b..649f0f45f29e01fef264958e89186a4cd750c19b 100644 --- a/MultiDeviceAppDev/AdaptiveCapabilities/README_zh.md +++ b/MultiDeviceAppDev/AdaptiveCapabilities/README_zh.md @@ -32,6 +32,6 @@ 2.本示例为Stage模型,从API version 9开始支持。 -3.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 4.本示例着重介绍了一多的自适应布局能力,未引入断点能力,建议查看相关能力在IDE提供的MatePadPro预览器中运行和查看效果。 \ No newline at end of file diff --git a/MultiDeviceAppDev/AdaptiveCapabilities/package.json b/MultiDeviceAppDev/AdaptiveCapabilities/package.json index fcad2c1b2e13eb44e165b34e47cf762e7db2f59f..5e5384cfda5328cba091f6c24cef5f2884e82071 100644 --- a/MultiDeviceAppDev/AdaptiveCapabilities/package.json +++ b/MultiDeviceAppDev/AdaptiveCapabilities/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } diff --git a/MultiDeviceAppDev/JsAdaptiveCapabilities/.gitignore b/MultiDeviceAppDev/JsAdaptiveCapabilities/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/MultiDeviceAppDev/JsAdaptiveCapabilities/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/MultiDeviceAppDev/JsAdaptiveCapabilities/README_zh.md b/MultiDeviceAppDev/JsAdaptiveCapabilities/README_zh.md index 5569177a6db5014a7e2262a3e0b963e2b41bb075..4fb766f0c83feada8d8d17721e2a607401d326f2 100644 --- a/MultiDeviceAppDev/JsAdaptiveCapabilities/README_zh.md +++ b/MultiDeviceAppDev/JsAdaptiveCapabilities/README_zh.md @@ -36,6 +36,6 @@ 2.本示例为FA模型,从API version 8开始支持。 -3.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 4.本示例着重介绍了一多的自适应布局能力,未引入断点能力,建议查看相关能力在IDE提供的MatePadPro预览器中运行和查看效果。 \ No newline at end of file diff --git a/MultiDeviceAppDev/JsAdaptiveCapabilities/entry/package.json b/MultiDeviceAppDev/JsAdaptiveCapabilities/entry/package.json index 992c771b9e6be8904ce4204f075df58a9b0902cc..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/MultiDeviceAppDev/JsAdaptiveCapabilities/entry/package.json +++ b/MultiDeviceAppDev/JsAdaptiveCapabilities/entry/package.json @@ -1,14 +1,14 @@ { - "license":"ISC", - "devDependencies":{}, - "name":"entry", - "ohos":{ - "org":"huawei", - "directoryLevel":"module", - "buildTool":"hvigor" - }, - "description":"example description", - "repository":{}, - "version":"1.0.0", - "dependencies":{} + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "ohos": { + "org": "huawei", + "directoryLevel": "module", + "buildTool": "hvigor" + }, + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} } \ No newline at end of file diff --git a/MultiDeviceAppDev/JsAdaptiveCapabilities/package.json b/MultiDeviceAppDev/JsAdaptiveCapabilities/package.json index 95bb764612c6d0b3456bc3dff0fef7a4676800c8..8a465e39e112a7fb4b1c7d6545597e34934bce53 100644 --- a/MultiDeviceAppDev/JsAdaptiveCapabilities/package.json +++ b/MultiDeviceAppDev/JsAdaptiveCapabilities/package.json @@ -1,18 +1,18 @@ { - "license":"ISC", - "devDependencies":{}, - "name":"jsadaptivecapabilities", - "ohos":{ - "org":"huawei", - "directoryLevel":"project", - "buildTool":"hvigor" + "license": "ISC", + "devDependencies": {}, + "name": "jsadaptivecapabilities", + "ohos": { + "org": "huawei", + "directoryLevel": "project", + "buildTool": "hvigor" }, - "description":"example description", - "repository":{}, - "version":"1.0.0", - "dependencies":{ - "@ohos/hypium":"1.0.1", - "@ohos/hvigor-ohos-plugin":"1.1.6", - "@ohos/hvigor":"1.1.6" + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": { + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/Network/UploadDownload/entry/package.json b/Network/UploadDownload/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..c7685ac4e7c0d79df04c96744f0d8f22cb4a9025 100644 --- a/Network/UploadDownload/entry/package.json +++ b/Network/UploadDownload/entry/package.json @@ -1,14 +1,14 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "entry", - "ohos": { - "org": "huawei", - "directoryLevel": "module", - "buildTool": "hvigor" - }, - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "ohos": { + "org": "huawei", + "directoryLevel": "module", + "buildTool": "hvigor" + }, + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} } diff --git a/Network/UploadDownload/entry/src/main/ets/MainAbility/pages/Index.ets b/Network/UploadDownload/entry/src/main/ets/MainAbility/pages/Index.ets index 5734a8b414a1a24da68a6fc63bc12b778245f395..c3680b8191a4dd3b9711bb507d226c3d1361d673 100644 --- a/Network/UploadDownload/entry/src/main/ets/MainAbility/pages/Index.ets +++ b/Network/UploadDownload/entry/src/main/ets/MainAbility/pages/Index.ets @@ -19,7 +19,6 @@ import resourceManager from '@ohos.resourceManager' import featureAbility from '@ohos.ability.featureAbility' import logger from '../model/Logger' import { TitleBar } from '../common/TitleBar' -import { UploadDownSource } from "../model/DataSource" const TAG: string = 'Index' @@ -29,8 +28,8 @@ struct Index { @State receivedSize: number = 0 @State totalSize: number = 0 @State message: string = '' - @State files: UploadDownSource = new UploadDownSource([]) - @State uploads: UploadDownSource = new UploadDownSource([]) + @State files: Array = [] + @State uploads: Array = [] private downloadConfig = { url: '', filePath: '' @@ -65,10 +64,10 @@ struct Index { let splitFiles = tempFiles[i].split('//')[1].split('/') logger.info(TAG, `splitFiles = ${JSON.stringify(splitFiles)}`) if (splitFiles.indexOf('upload') === -1) { - this.files.pushData(tempFiles[i]) + this.files.push(tempFiles[i]) } } - logger.info(TAG, `files = ${JSON.stringify(this.files['uploadDownData'])}`) + logger.info(TAG, `files = ${JSON.stringify(this.files)}`) } else { logger.info(TAG, `error: ${JSON.stringify(err)}`) httpRequest.destroy() @@ -85,7 +84,7 @@ struct Index { .fontSize(25) .alignSelf(ItemAlign.Start) .margin({ top: 20, left: 10 }) - LazyForEach(this.files, (item, index) => { + ForEach(this.files, (item, index) => { Divider() .margin({ top: 20 }) Row() { @@ -121,11 +120,8 @@ struct Index { }) downloadTask.on('complete', async () => { - await this.files['uploadDownData'].splice(index, 1) - await this.files.notifyDataReload() - await this.uploads['uploadDownData'].push(item) - await this.uploads.notifyDataReload() - + await this.files.splice(index, 1) + await this.uploads.push(item) AlertDialog.show({ message: `${item}${downloadSuccess}`, confirm: { @@ -161,7 +157,7 @@ struct Index { } .width('100%') - if (index === this.files['uploadDownData'].length - 1) { + if (index === this.files.length - 1) { Divider() .margin({ top: 20 }) } @@ -182,7 +178,7 @@ struct Index { } .constraintSize({ maxHeight: '87%' }) - if (this.receivedSize !== 0 && this.totalSize !== 0 && this.files['uploadDownData'].length > 0) { + if (this.receivedSize !== 0 && this.totalSize !== 0 && this.files.length > 0) { Row() { Text($r('app.string.download_progress')) .fontSize(25) diff --git a/Network/UploadDownload/entry/src/main/ets/MainAbility/pages/Upload.ets b/Network/UploadDownload/entry/src/main/ets/MainAbility/pages/Upload.ets index 80bc2f5e7b38789aa70f22619f9c817193126733..90cbf8277575f8777213ef4e812a99af1ce2d909 100644 --- a/Network/UploadDownload/entry/src/main/ets/MainAbility/pages/Upload.ets +++ b/Network/UploadDownload/entry/src/main/ets/MainAbility/pages/Upload.ets @@ -17,9 +17,8 @@ import request from '@ohos.request' import logger from '../model/Logger' import { TitleBar } from '../common/TitleBar' import { UploadFile } from '../model/UploadFile' -import { UploadConfigs } from '../model/UploadConfigs' +import { UploadConfigs } from '../model/UploadConfigs' import { UploadRequestData } from '../model/UploadRequestData' -import { UploadDownSource } from "../model/DataSource" const TAG: string = 'Upload' @@ -30,7 +29,7 @@ struct Upload { private uploadConfig: UploadConfigs = new UploadConfigs() @State uploadedSize: number = 0 @State totalSize: number = 0 - @State uploads: UploadDownSource = router.getParams()['uploads'] + @State uploads: Array = router.getParams()['uploads'] @State isDialog: boolean = false @State selectIndex: number = -1 handlerClickButton = () => { @@ -46,7 +45,7 @@ struct Upload { .fontSize(25) .alignSelf(ItemAlign.Start) .margin({ top: 20, left: 10 }) - LazyForEach(this.uploads, (item, index) => { + ForEach(this.uploads, (item, index) => { Divider() .margin({ top: 20 }) Row() { @@ -121,7 +120,7 @@ struct Upload { .width('100%') .margin({ top: 10, left: 10 }) - if (index === this.uploads['uploadDownData'].length - 1) { + if (index === this.uploads.length - 1) { Divider() .margin({ top: 20 }) } @@ -131,7 +130,7 @@ struct Upload { } .constraintSize({ maxHeight: '87%' }) - if (this.uploadedSize !== 0 && this.totalSize !== 0 && this.uploads['uploadDownData'].length > 0) { + if (this.uploadedSize !== 0 && this.totalSize !== 0 && this.uploads.length > 0) { Row() { Text($r('app.string.upload_progress')) .fontSize(25) diff --git a/Network/UploadDownload/package.json b/Network/UploadDownload/package.json index 7f69c1ec10879f468bd6dcaa980c2301a119c38a..b8ef18e8599ef89336eeed1cb5003634852051ff 100644 --- a/Network/UploadDownload/package.json +++ b/Network/UploadDownload/package.json @@ -1,19 +1,19 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "uploaddownload", - "ohos": { - "org": "huawei", - "directoryLevel": "project", - "buildTool": "hvigor" - }, - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "1.1.6", - "hypium": "^1.0.0", - "@ohos/hvigor": "1.1.6", - "@ohos/hypium": "1.0.1" - } -} + "license":"ISC", + "devDependencies":{}, + "name":"uploaddownload", + "ohos":{ + "org":"huawei", + "directoryLevel":"project", + "buildTool":"hvigor" + }, + "description":"example description", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/hypium":"1.0.1", + "@ohos/hvigor-ohos-plugin":"1.1.6", + "hypium":"^1.0.0", + "@ohos/hvigor":"1.1.6" + } +} \ No newline at end of file diff --git a/Notification/CommonEvent/entry/src/main/ets/MainAbility/pages/index.ets b/Notification/CommonEvent/entry/src/main/ets/MainAbility/pages/index.ets index e21e886ff4374371bdb3e293952a286ebbe6b7c8..9a0fccfc27dc108d22feac07f196227c4115e7fa 100644 --- a/Notification/CommonEvent/entry/src/main/ets/MainAbility/pages/index.ets +++ b/Notification/CommonEvent/entry/src/main/ets/MainAbility/pages/index.ets @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {PublishEventView} from '../common/publishEvent' -import {SubscribeEventView} from '../common/subscribeEvent' +import { PublishEventView } from '../common/publishEvent' +import { SubscribeEventView } from '../common/subscribeEvent' @Entry @Component @@ -36,7 +36,7 @@ struct Index { Line() .width("100%").height(2) .backgroundColor("#D5D5D5") - .margin({ top: 15}) + .margin({ top: 15 }) PublishEventView() diff --git a/Preset/DistributedMusicPlayer/entry/src/main/ets/pages/Index.ets b/Preset/DistributedMusicPlayer/entry/src/main/ets/pages/Index.ets index 61b90a8559754fad186b38f2dc3699783f2f0573..f697bd104c5f24372a97d463f8157a6d8cf7da41 100644 --- a/Preset/DistributedMusicPlayer/entry/src/main/ets/pages/Index.ets +++ b/Preset/DistributedMusicPlayer/entry/src/main/ets/pages/Index.ets @@ -203,13 +203,24 @@ struct Index { } getShownTimer(ms) { - let seconds = Math.floor(ms / ONE_THOUSAND) - let sec = seconds % SIXTY let minStr: string let secStr: string + let seconds = Math.floor(ms / ONE_THOUSAND) + let sec = seconds % SIXTY + Logger.info(TAG, `getShownTimer sec = ${sec}`) let min = (seconds - sec) / SIXTY - sec < 10 ? secStr = '0' + sec : '' + sec - min < 10 ? minStr = '0' + min : '' + min + Logger.info(TAG, `getShownTimer min = ${min}`) + if (sec < 10) { + secStr = '0' + sec + } else { + secStr = sec.toString(10) + } + if (min < 10) { + minStr = '0' + min + } else { + minStr = min.toString(10) + } + Logger.warn(TAG, `getShownTimer = ${minStr}:${secStr}`) return minStr + ':' + secStr } @@ -287,7 +298,7 @@ struct Index { PlayerModel.pause() this.imageArrays[2] = $r('app.media.ic_play') } else { - PlayerModel.preLoad(0, () => { + PlayerModel.preLoad(PlayerModel.index, () => { PlayerModel.play(-1, true) this.imageArrays[2] = $r('app.media.ic_pause') }) diff --git a/ResourcesSchedule/BackgroundTaskManager/entry/src/main/ets/MainAbility/pages/Index.ets b/ResourcesSchedule/BackgroundTaskManager/entry/src/main/ets/MainAbility/pages/Index.ets index c6a77d567e210fb148e0f8703bdc2fe5ea82b11b..b55969d0459a68e56a46b089c88ce260a1218245 100644 --- a/ResourcesSchedule/BackgroundTaskManager/entry/src/main/ets/MainAbility/pages/Index.ets +++ b/ResourcesSchedule/BackgroundTaskManager/entry/src/main/ets/MainAbility/pages/Index.ets @@ -39,18 +39,18 @@ struct Index { Image($r('app.media.file')) .width('100%') .height('30%') - .margin({top:30}) + .margin({ top: 30 }) .objectFit(ImageFit.Contain) Text($r('app.string.fileName')) .fontSize(30) Button() { Text($r('app.string.download')) - .fontSize(20) + .fontSize(20) } .margin({ top: 60 }) .type(ButtonType.Capsule) .backgroundColor('#0D9FFB') - .size({width:'60%'}) + .size({ width: '60%' }) .onClick(() => { Logger.info(TAG, 'ServiceAbility Start') startServiceAbility() diff --git a/ResourcesSchedule/BackgroundTaskManager/entry/src/main/ets/ServiceAbility/service.ts b/ResourcesSchedule/BackgroundTaskManager/entry/src/main/ets/ServiceAbility/service.ts index 6598759f1a8c440f2eb9ae92c6fd7297cb8e1721..df9c3d6c1d368cd9a9405b1a08ffe94d57bda2b0 100644 --- a/ResourcesSchedule/BackgroundTaskManager/entry/src/main/ets/ServiceAbility/service.ts +++ b/ResourcesSchedule/BackgroundTaskManager/entry/src/main/ets/ServiceAbility/service.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2022 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 wantAgent from '@ohos.wantAgent' import backgroundTaskManager from '@ohos.backgroundTaskManager' import featureAbility from '@ohos.ability.featureAbility' @@ -9,67 +24,67 @@ let num: number = 0 let timerID: number = 0 let notificationRequest = { - content: { - contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: '文件名', - text: '' - } - }, - id: 1 + content: { + contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: '文件名', + text: '' + } + }, + id: 1 } function callback(err, data) { - if (err) { - Logger.error(TAG, `Operation failed Cause: ${err}`) - return - } - if (timerID !== 0) { - clearInterval(timerID) + if (err) { + Logger.error(TAG, `Operation failed Cause: ${err}`) + return + } + if (timerID !== 0) { + clearInterval(timerID) + } + Logger.info(TAG, `Operation startBackgroundRunning succeeded`) + timerID = setInterval(() => { + notificationRequest.content.normal.text = `${num}%` + Notification.publish(notificationRequest).then(() => { + Logger.info(TAG, `==========================>publishCallback=======================>`); + }) + num += 5 + if (num > 20) { + clearInterval(timerID) } - Logger.info(TAG, `Operation startBackgroundRunning succeeded`) - timerID = setInterval(() => { - notificationRequest.content.normal.text = `${num}%` - Notification.publish(notificationRequest).then(() => { - Logger.info(TAG, `==========================>publishCallback=======================>`); - }) - num += 5 - if (num > 20) { - clearInterval(timerID) - } - }, 5000) + }, 5000) } function startContinuousTask() { - Logger.info(TAG, `startBackground use new api`) - let wantAgentInfo = { - wants: [ - { - bundleName: "ohos.samples.backgroundtaskmanager", - abilityName: "ohos.samples.backgroundtaskmanager.MainAbility" - } - ], - operationType: wantAgent.OperationType.START_ABILITIES, - requestCode: 0, - wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] - }; + Logger.info(TAG, `startBackground use new api`) + let wantAgentInfo = { + wants: [ + { + bundleName: "ohos.samples.backgroundtaskmanager", + abilityName: "ohos.samples.backgroundtaskmanager.MainAbility" + } + ], + operationType: wantAgent.OperationType.START_ABILITIES, + requestCode: 0, + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; - wantAgent.getWantAgent(wantAgentInfo).then((data) => { - Logger.info(TAG, `startBackground begin`) - backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(), backgroundTaskManager.BackgroundMode.DATA_TRANSFER, data, callback) - }) + wantAgent.getWantAgent(wantAgentInfo).then((data) => { + Logger.info(TAG, `startBackground begin`) + backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(), backgroundTaskManager.BackgroundMode.DATA_TRANSFER, data, callback) + }) } export default { - onStart() { - Logger.info(TAG, 'ServiceAbility onStart') - startContinuousTask() - }, - onStop() { - Logger.info(TAG, 'ServiceAbility onStop') - backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()) - }, - onCommand(want, startId) { - Logger.info(TAG, 'ServiceAbility onCommand') - } + onStart() { + Logger.info(TAG, 'ServiceAbility onStart') + startContinuousTask() + }, + onStop() { + Logger.info(TAG, 'ServiceAbility onStop') + backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()) + }, + onCommand(want, startId) { + Logger.info(TAG, 'ServiceAbility onCommand') + } } \ No newline at end of file diff --git a/Telephony/Contact/entry/src/main/ets/MainAbility/component/ContactInfo.ets b/Telephony/Contact/entry/src/main/ets/MainAbility/component/ContactInfo.ets index 881d481f05bcef3d50ca78dcba6f6fcb344dbc97..9bf188916522801e54c91f245721294636923de5 100644 --- a/Telephony/Contact/entry/src/main/ets/MainAbility/component/ContactInfo.ets +++ b/Telephony/Contact/entry/src/main/ets/MainAbility/component/ContactInfo.ets @@ -15,6 +15,7 @@ import router from '@ohos.router' import contact from '@ohos.contact' +import resourceManager from '@ohos.resourceManager'; import Logger from '../data/Logger' const TAG: string = 'ContactInfo' @@ -22,9 +23,9 @@ const TAG: string = 'ContactInfo' @Preview @Component export struct ContactInfo { - @State phone: string | Resource = '' - @State email: string | Resource = '' - @State address: string | Resource = '' + @State phone: string = '' + @State email: string = '' + @State address: string = '' private contact: contact.Contact build() { @@ -185,17 +186,29 @@ export struct ContactInfo { try { this.phone = this.contact.phoneNumbers[0].phoneNumber } catch (err) { - this.phone = $r('app.string.not_fill') + resourceManager.getResourceManager((error, msg) => { + msg.getString($r('app.string.not_fill').id).then(value => { + this.phone = value + }) + }) } try { this.email = this.contact.emails[0].email } catch (err) { - this.email = $r('app.string.not_fill') + resourceManager.getResourceManager((error, msg) => { + msg.getString($r('app.string.not_fill').id).then(value => { + this.email = value + }) + }) } try { this.address = this.contact.postalAddresses[0].postalAddress } catch (err) { - this.address = $r('app.string.not_fill') + resourceManager.getResourceManager((error, msg) => { + msg.getString($r('app.string.not_fill').id).then(value => { + this.address = value + }) + }) } } } \ No newline at end of file diff --git a/Telephony/MobileNetwork/entry/src/main/ets/Application/AbilityStage.ts b/Telephony/MobileNetwork/entry/src/main/ets/Application/AbilityStage.ts index 809ccc5abc925924a81023bd36a14e32515a8b7b..6e24bab18187b9b0a375692434223b0f60461609 100644 --- a/Telephony/MobileNetwork/entry/src/main/ets/Application/AbilityStage.ts +++ b/Telephony/MobileNetwork/entry/src/main/ets/Application/AbilityStage.ts @@ -19,7 +19,7 @@ import AbilityStage from '@ohos.application.AbilityStage' const TAG: string = '[AbilityStage]' export default class MyAbilityStage extends AbilityStage { - onCreate() { - Logger.info(TAG, `[Demo] MyAbilityStage onCreate`) - } + onCreate() { + Logger.info(TAG, `[Demo] MyAbilityStage onCreate`) + } } \ No newline at end of file diff --git a/Telephony/MobileNetwork/entry/src/main/ets/MainAbility/MainAbility.ts b/Telephony/MobileNetwork/entry/src/main/ets/MainAbility/MainAbility.ts index f2aafcbe8019d2f0530418e717d627a7d991c8d2..5966390b7c11c705d3775c06ee158c59623c5d6e 100644 --- a/Telephony/MobileNetwork/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/Telephony/MobileNetwork/entry/src/main/ets/MainAbility/MainAbility.ts @@ -16,38 +16,38 @@ import Logger from '../model/Logger' import Ability from '@ohos.application.Ability' -const TAG: string = '[MainAbility]' +const TAG:string = '[MainAbility]' export default class MainAbility extends Ability { - onCreate(want, launchParam) { - Logger.info(TAG, `[Demo] MainAbility onCreate`) - globalThis.abilityWant = want - globalThis.context = this.context - } - - onDestroy() { - Logger.info(TAG, `[Demo] MainAbility onDestroy`) - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - Logger.info(TAG, `[Demo] MainAbility onWindowStageCreate`) - - windowStage.setUIContent(this.context, 'pages/Index', null) - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - Logger.info(TAG, `[Demo] MainAbility onWindowStageDestroy`) - } - - onForeground() { - // Ability has brought to foreground - Logger.info(TAG, `[Demo] MainAbility onForeground`) - } - - onBackground() { - // Ability has back to background - Logger.info(TAG, `[Demo] MainAbility onBackground`) - } + onCreate(want, launchParam) { + Logger.info(TAG, `[Demo] MainAbility onCreate`) + globalThis.abilityWant = want + globalThis.context = this.context + } + + onDestroy() { + Logger.info(TAG, `[Demo] MainAbility onDestroy`) + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + Logger.info(TAG, `[Demo] MainAbility onWindowStageCreate`) + + windowStage.setUIContent(this.context, 'pages/Index', null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + Logger.info(TAG, `[Demo] MainAbility onWindowStageDestroy`) + } + + onForeground() { + // Ability has brought to foreground + Logger.info(TAG, `[Demo] MainAbility onForeground`) + } + + onBackground() { + // Ability has back to background + Logger.info(TAG, `[Demo] MainAbility onBackground`) + } }; diff --git a/Telephony/MobileNetwork/entry/src/main/ets/model/Logger.ts b/Telephony/MobileNetwork/entry/src/main/ets/model/Logger.ts index 554025733475238d51190e9c27e335cbbbac7d6e..c00b8013e45814ef764c55360c072a7ee95698c8 100644 --- a/Telephony/MobileNetwork/entry/src/main/ets/model/Logger.ts +++ b/Telephony/MobileNetwork/entry/src/main/ets/model/Logger.ts @@ -16,34 +16,34 @@ import hilog from '@ohos.hilog' export 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: any[]) { - hilog.debug(this.domain, this.prefix, this.format, args) - } - - info(...args: any[]) { - hilog.info(this.domain, this.prefix, this.format, args) - } - - warn(...args: any[]) { - hilog.warn(this.domain, this.prefix, this.format, args) - } - - error(...args: any[]) { - hilog.error(this.domain, this.prefix, this.format, args) - } - - fatal(...args: any[]) { - hilog.fatal(this.domain, this.prefix, this.format, args) - } + private domain: number + private prefix: string + private format: string = `%{public}s, %{public}s` + + constructor(prefix: string) { + this.prefix = prefix + this.domain = 0xFF00 + } + + debug(...args: any[]) { + hilog.debug(this.domain, this.prefix, this.format, args) + } + + info(...args: any[]) { + hilog.info(this.domain, this.prefix, this.format, args) + } + + warn(...args: any[]) { + hilog.warn(this.domain, this.prefix, this.format, args) + } + + error(...args: any[]) { + hilog.error(this.domain, this.prefix, this.format, args) + } + + fatal(...args: any[]) { + hilog.fatal(this.domain, this.prefix, this.format, args) + } } export default new Logger('[MobileNetwork]') \ No newline at end of file diff --git a/Telephony/MobileNetwork/package.json b/Telephony/MobileNetwork/package.json index 504228df6b5717370edd9c691fca20cd0fa3a334..a3510f0cde264731d7bb9ca18ad37a3802b34275 100644 --- a/Telephony/MobileNetwork/package.json +++ b/Telephony/MobileNetwork/package.json @@ -1,18 +1,18 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "mobilenetwork", - "ohos": { - "org": "huawei", - "directoryLevel": "project", - "buildTool": "hvigor" + "license":"ISC", + "devDependencies":{}, + "name":"mobilenetwork", + "ohos":{ + "org":"huawei", + "directoryLevel":"project", + "buildTool":"hvigor" }, - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hvigor": "1.1.6" + "description":"example description", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/hypium":"1.0.1", + "@ohos/hvigor-ohos-plugin":"1.1.6", + "@ohos/hvigor":"1.1.6" } -} +} \ No newline at end of file diff --git a/Telephony/MobileNetwork/screenshots/device/index.png b/Telephony/MobileNetwork/screenshots/device/index.png index 1b26b62b4c5ce4c53ec8ab6cd59b00b7c8da39d2..00220fb2afdb5a5d2197bc3aa41e8ede7b26ba7b 100644 Binary files a/Telephony/MobileNetwork/screenshots/device/index.png and b/Telephony/MobileNetwork/screenshots/device/index.png differ diff --git a/UI/AtomicLayout/.gitignore b/UI/AtomicLayout/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/AtomicLayout/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/AtomicLayout/README_zh.md b/UI/AtomicLayout/README_zh.md index 7af3f31867f33322f7793a09e8acca61010642c8..f5bac2ed1dbe0cf59ad726f2b067ffde3e45a5cc 100644 --- a/UI/AtomicLayout/README_zh.md +++ b/UI/AtomicLayout/README_zh.md @@ -32,4 +32,4 @@ 2.本示例支持在标准系统使用。 -3.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/app.js b/UI/AtomicLayout/entry/src/main/js/default/app.js index 8e47afff13e928a74fdcc01a108e4422404b9ac9..50007322f38c5c4328aa0e7386255727629eb48d 100644 --- a/UI/AtomicLayout/entry/src/main/js/default/app.js +++ b/UI/AtomicLayout/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } }; diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.hml b/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.hml index 43cea8b30fc78cca9b3649eff96054133d9c87c9..ec243cb0beda85b1bc0c10f8b5fec73527253047 100644 --- a/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.hml +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.hml @@ -14,11 +14,11 @@ -->
-
- A -
-
- - -
+
+ A +
+
+ + +
\ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.js b/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.js index e6fc0affd2efccbd805620f9021e13a9e24143d2..aa1e7d3cc152dfcd4f4f10c8cdcc19c3eef43c52 100644 --- a/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.js +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/fixed/index.js @@ -14,16 +14,16 @@ */ export default { - data: { - "height": "300px", - "width": "300px" - }, - onClickReturn() { - this.height = "300px" - this.width = "300px" - }, - onClickRefresh() { - this.height = "100px" - this.width = "200px" - } + data: { + "height": "300px", + "width": "300px" + }, + onClickReturn() { + this.height = "300px" + this.width = "300px" + }, + onClickRefresh() { + this.height = "100px" + this.width = "200px" + } } \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.hml b/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.hml index 7bb8007b8b52a902f1aad588e3493a35171f6491..7a4c0937f844a6f315c5e0884d7261bc0e1cc540 100644 --- a/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.hml +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.hml @@ -14,13 +14,13 @@ -->
-
- A - B - C -
-
- - -
+
+ A + B + C +
+
+ + +
\ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.js b/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.js index 6b22dfdbd7a981b14dd0e46287e27e93ac1c564f..e4afa57050c48119bd59e6e922dd604115ead9d7 100644 --- a/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.js +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/hide/index.js @@ -14,13 +14,13 @@ */ export default { - data: { - height: "200px", - }, - onClickReturn() { - this.height = "200px" - }, - onClickRefresh() { - this.height = "500px" - } + data: { + height: "200px", + }, + onClickReturn() { + this.height = "200px" + }, + onClickRefresh() { + this.height = "500px" + } } \ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.hml b/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.hml index a9aeeee806d459a69d4a472d13cafba55163f362..260cfc5b997a80cbee32dd448afcebaa2530a4f3 100644 --- a/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.hml +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.hml @@ -14,7 +14,7 @@ -->
- - - + + +
\ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.js b/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.js index 98965c67f08458ef6563143064f0b8b734992cbf..05cdbf2d38e3f6b6fa12d0a4affcdafbe4281912 100644 --- a/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.js +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/index/index.js @@ -16,10 +16,10 @@ import router from '@ohos.router'; export default { - data: {}, - onchange(type) { - router.push({ - url: 'pages/' + type + '/index' - }) - } + data: {}, + onchange(type) { + router.push({ + url: 'pages/' + type + '/index' + }) + } } diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.hml b/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.hml index 7bb8007b8b52a902f1aad588e3493a35171f6491..7a4c0937f844a6f315c5e0884d7261bc0e1cc540 100644 --- a/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.hml +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.hml @@ -14,13 +14,13 @@ -->
-
- A - B - C -
-
- - -
+
+ A + B + C +
+
+ + +
\ No newline at end of file diff --git a/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.js b/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.js index 6b22dfdbd7a981b14dd0e46287e27e93ac1c564f..e4afa57050c48119bd59e6e922dd604115ead9d7 100644 --- a/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.js +++ b/UI/AtomicLayout/entry/src/main/js/default/pages/percentage/index.js @@ -14,13 +14,13 @@ */ export default { - data: { - height: "200px", - }, - onClickReturn() { - this.height = "200px" - }, - onClickRefresh() { - this.height = "500px" - } + data: { + height: "200px", + }, + onClickReturn() { + this.height = "200px" + }, + onClickRefresh() { + this.height = "500px" + } } \ No newline at end of file diff --git a/UI/AtomicLayout/package.json b/UI/AtomicLayout/package.json index 3c6c841a55116b6362b16144e66925cd525ef5c3..e8b4f8ec968063df29705205d35cc9c30673cafe 100644 --- a/UI/AtomicLayout/package.json +++ b/UI/AtomicLayout/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/UI/Badge/.gitignore b/UI/Badge/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/Badge/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/Badge/README_zh.md b/UI/Badge/README_zh.md index 85e1aab155c30ac332fae094bd3f8fc5e2b930de..3a001151ab0de9dffaec69a89ed3b871eda535bb 100644 --- a/UI/Badge/README_zh.md +++ b/UI/Badge/README_zh.md @@ -26,4 +26,4 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 diff --git a/UI/Badge/entry/src/main/js/default/app.js b/UI/Badge/entry/src/main/js/default/app.js index 8e47afff13e928a74fdcc01a108e4422404b9ac9..50007322f38c5c4328aa0e7386255727629eb48d 100644 --- a/UI/Badge/entry/src/main/js/default/app.js +++ b/UI/Badge/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } }; diff --git a/UI/Badge/entry/src/main/js/default/pages/index/index.css b/UI/Badge/entry/src/main/js/default/pages/index/index.css index 55c4e304a640aa280300faa1c9e2b7be8530453b..69707d45025b2c0735eddaeaa1b1b20a0c62aaef 100644 --- a/UI/Badge/entry/src/main/js/default/pages/index/index.css +++ b/UI/Badge/entry/src/main/js/default/pages/index/index.css @@ -82,6 +82,7 @@ height: 100%; justify-content: center; } + .container { width: 35%; height: 100%; @@ -91,6 +92,7 @@ margin-right: 12px; margin-left: 12px; } + .item { height: 50px; width: 100%; @@ -99,6 +101,7 @@ margin-bottom: 2px; background-color: white; } + .badge { position: absolute; height: 100%; diff --git a/UI/Badge/entry/src/main/js/default/pages/index/index.hml b/UI/Badge/entry/src/main/js/default/pages/index/index.hml index 98a3c1462c7316a5539b81cd90401915a31dfe0e..470dca45b729b9d9f41169aa3abfc3dd0c525388 100644 --- a/UI/Badge/entry/src/main/js/default/pages/index/index.hml +++ b/UI/Badge/entry/src/main/js/default/pages/index/index.hml @@ -13,18 +13,18 @@ limitations under the License. -->
-
-
- -
- {{ $item.contacts }} - {{ $item.message }} -
- - - -
+
+
+ +
+ {{ $item.contacts }} + {{ $item.message }} +
+ + +
+
\ No newline at end of file diff --git a/UI/Badge/entry/src/main/js/default/pages/index/index.js b/UI/Badge/entry/src/main/js/default/pages/index/index.js index 10257b51b2ad34ed61d3d12b8cfb56e1ce19549a..215768b01a99c7db8ee60fc9dac684b0ab0d850f 100644 --- a/UI/Badge/entry/src/main/js/default/pages/index/index.js +++ b/UI/Badge/entry/src/main/js/default/pages/index/index.js @@ -14,49 +14,49 @@ */ export default { - data: { - array: [ - { - imgPath: '/common/images/Image1.jpg', - contacts: "", - message: "", - visibility: "", - count: "", - maxCount: "" - }, - { - imgPath: '/common/images/Image2.jpg', - contacts: '', - message: '', - visibility: "", - count: "100", - maxCount: "99" - }, - { - imgPath: '/common/images/Image3.jpg', - contacts: '', - message: '', - visibility: "", - count: "35", - maxCount: "99" - } - ], - badgeConfig: { - badgeColor: "#FFFF0F0F", - textColor: "#ffffff", - } - }, - onInit() { - for (var arr in this.array) { - this.array[arr].contacts = this.$t('strings.contacts'); - this.array[arr].message = this.$t('strings.message'); - this.array[arr].visibility = "visible" - } - }, - badgeInvalidation(id) { - var idx = JSON.stringify(id) - console.log(idx) - this.array[idx].visibility = "hidden"; - console.log(this.array[idx].visibility) + data: { + array: [ + { + imgPath: '/common/images/Image1.jpg', + contacts: "", + message: "", + visibility: "", + count: "", + maxCount: "" + }, + { + imgPath: '/common/images/Image2.jpg', + contacts: '', + message: '', + visibility: "", + count: "100", + maxCount: "99" + }, + { + imgPath: '/common/images/Image3.jpg', + contacts: '', + message: '', + visibility: "", + count: "35", + maxCount: "99" + } + ], + badgeConfig: { + badgeColor: "#FFFF0F0F", + textColor: "#ffffff", } + }, + onInit() { + for (var arr in this.array) { + this.array[arr].contacts = this.$t('strings.contacts'); + this.array[arr].message = this.$t('strings.message'); + this.array[arr].visibility = "visible" + } + }, + badgeInvalidation(id) { + var idx = JSON.stringify(id) + console.log(idx) + this.array[idx].visibility = "hidden"; + console.log(this.array[idx].visibility) + } } \ No newline at end of file diff --git a/UI/Badge/package.json b/UI/Badge/package.json index 43ec0e1dd361bb93b5e27e9a905f537d7272eb6f..137ee4c65f1a92e328a1ae14d3259de980acb1cb 100644 --- a/UI/Badge/package.json +++ b/UI/Badge/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } diff --git a/UI/International/.gitignore b/UI/International/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/International/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/International/README_zh.md b/UI/International/README_zh.md index df51a5854361b097d7d7ea50aa4df52a14e99dd1..61d98b67b9ebc2f57c85a1d1f1fcf140433460d9 100644 --- a/UI/International/README_zh.md +++ b/UI/International/README_zh.md @@ -30,4 +30,4 @@ TextClock:TextClock组件通过文本将当前系统时间显示在设备上 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/UI/International/entry/src/main/js/default/app.js b/UI/International/entry/src/main/js/default/app.js index 58d12b7b501fbf46db906a86187aaf18dfb1f677..6d4065abcfbd0a337fbe6453e432981e7c70e9a6 100644 --- a/UI/International/entry/src/main/js/default/app.js +++ b/UI/International/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/UI/International/entry/src/main/js/default/i18n/zh-CN.json b/UI/International/entry/src/main/js/default/i18n/zh-CN.json index 92e779de83458f88832b1fe8d20cf8560235fb3c..a63cd6b66c103967c85c4fe760534ff78bc55ecb 100644 --- a/UI/International/entry/src/main/js/default/i18n/zh-CN.json +++ b/UI/International/entry/src/main/js/default/i18n/zh-CN.json @@ -5,5 +5,4 @@ "cn": "中文国际化", "ja": "日文国际化" } - } \ No newline at end of file diff --git a/UI/International/entry/src/main/js/default/pages/index/index.hml b/UI/International/entry/src/main/js/default/pages/index/index.hml index 7b3479ba8465d97e965ad4fb2bc74ccf4eb4a35e..291e84cd3cb18a4f6403e5a39376bbdd732e3591 100644 --- a/UI/International/entry/src/main/js/default/pages/index/index.hml +++ b/UI/International/entry/src/main/js/default/pages/index/index.hml @@ -14,12 +14,12 @@ -->
- - {{ dateTime }} - - {{ result1 }} - - {{ result }} - - {{ result2 }} + + {{ dateTime }} + + {{ result1 }} + + {{ result }} + + {{ result2 }}
diff --git a/UI/International/entry/src/main/js/default/pages/index/index.js b/UI/International/entry/src/main/js/default/pages/index/index.js index a1fd3dd037f6982855b4eeaec9806d4e4928fd8e..fb383b186cd3a305670cff9a705706b4aa845be8 100644 --- a/UI/International/entry/src/main/js/default/pages/index/index.js +++ b/UI/International/entry/src/main/js/default/pages/index/index.js @@ -16,31 +16,31 @@ import Intl from '@ohos.intl'; export default { - data: { - result: '', - result1: '', - result2: '', - dataDate: null, - dateTime: '' - }, - onInit() { - var datet = new Date() - this.dateTime = datet.getFullYear() + '-' + (datet.getMonth() + 1) + '-' + datet.getDate() - this.dataDate = new Date(datet.getFullYear(), datet.getMonth(), datet.getDate(), datet.getHours(), - datet.getMinutes(), datet.getSeconds()) - }, - cn() { - var dateFmt = new Intl.DateTimeFormat('zh-CN') - this.result = dateFmt.format(this.dataDate) - }, - en() { - var dateFmt1 = new Intl.DateTimeFormat('en-GB') - this.result1 = dateFmt1.format(this.dataDate) - }, - ja() { - var dateFmt2 = new Intl.DateTimeFormat('ja-JP') - this.result2 = dateFmt2.format(this.dataDate) - } + data: { + result: '', + result1: '', + result2: '', + dataDate: null, + dateTime: '' + }, + onInit() { + var datet = new Date() + this.dateTime = datet.getFullYear() + '-' + (datet.getMonth() + 1) + '-' + datet.getDate() + this.dataDate = new Date(datet.getFullYear(), datet.getMonth(), datet.getDate(), datet.getHours(), + datet.getMinutes(), datet.getSeconds()) + }, + cn() { + var dateFmt = new Intl.DateTimeFormat('zh-CN') + this.result = dateFmt.format(this.dataDate) + }, + en() { + var dateFmt1 = new Intl.DateTimeFormat('en-GB') + this.result1 = dateFmt1.format(this.dataDate) + }, + ja() { + var dateFmt2 = new Intl.DateTimeFormat('ja-JP') + this.result2 = dateFmt2.format(this.dataDate) + } } diff --git a/UI/International/package.json b/UI/International/package.json index 6f0716b89d67e5e4e9d668134aef37df04e5f3ab..43d0b1222ec9c4574a591c32b039d3d75ddddabf 100644 --- a/UI/International/package.json +++ b/UI/International/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/UI/JSComponments/.gitignore b/UI/JSComponments/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JSComponments/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JSComponments/README_zh.md b/UI/JSComponments/README_zh.md index c4391798d370684e74310900be6dff97a55f5d83..d4285568d444a75edcd137cfa3fbcf5fe60b85e4 100644 --- a/UI/JSComponments/README_zh.md +++ b/UI/JSComponments/README_zh.md @@ -22,4 +22,4 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/UI/JSComponments/entry/src/main/js/MainAbility/app.js b/UI/JSComponments/entry/src/main/js/MainAbility/app.js index 8e47afff13e928a74fdcc01a108e4422404b9ac9..50007322f38c5c4328aa0e7386255727629eb48d 100644 --- a/UI/JSComponments/entry/src/main/js/MainAbility/app.js +++ b/UI/JSComponments/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } }; diff --git a/UI/JSComponments/entry/src/main/js/MainAbility/pages/comp/comp.hml b/UI/JSComponments/entry/src/main/js/MainAbility/pages/comp/comp.hml index d8ee5b99732058a228216b01d9d0f43896c868f9..6048bb3efcf0c3dd217ce520734104fc1ff4a6f9 100644 --- a/UI/JSComponments/entry/src/main/js/MainAbility/pages/comp/comp.hml +++ b/UI/JSComponments/entry/src/main/js/MainAbility/pages/comp/comp.hml @@ -14,12 +14,12 @@ -->
- {{ title }} - - - Click here to view hidden text - - - hello worldshow - + {{ title }} + + + Click here to view hidden text + + + hello worldshow +
\ No newline at end of file diff --git a/UI/JSComponments/entry/src/main/js/MainAbility/pages/comp/comp.js b/UI/JSComponments/entry/src/main/js/MainAbility/pages/comp/comp.js index 65c31d2eb558016ab984478d3bdbf423291cb1a5..4893d9c0783f8c549e77854acc6aa7d3ca3eed0c 100644 --- a/UI/JSComponments/entry/src/main/js/MainAbility/pages/comp/comp.js +++ b/UI/JSComponments/entry/src/main/js/MainAbility/pages/comp/comp.js @@ -14,21 +14,21 @@ */ export default { - props: { - title: { - default: 'title', - }, - showObject: {}, - }, - data() { - return { - display: this.showObject, - }; - }, - childClicked() { - this.$emit('eventType1', { - text: 'Get Child Component Parameter' - }); - this.show = !this.show; + props: { + title: { + default: 'title', }, + showObject: {}, + }, + data() { + return { + display: this.showObject, + }; + }, + childClicked() { + this.$emit('eventType1', { + text: 'Get Child Component Parameter' + }); + this.show = !this.show; + }, } \ No newline at end of file diff --git a/UI/JSComponments/entry/src/main/js/MainAbility/pages/details/details.hml b/UI/JSComponments/entry/src/main/js/MainAbility/pages/details/details.hml index ddd5391627940d895722f82b25e3ac61865e4bf0..82a8844f4de2cec38608bf87f0333739be8df2e6 100644 --- a/UI/JSComponments/entry/src/main/js/MainAbility/pages/details/details.hml +++ b/UI/JSComponments/entry/src/main/js/MainAbility/pages/details/details.hml @@ -14,8 +14,8 @@ -->
- - This is the detail page. - - + + This is the detail page. + +
\ No newline at end of file diff --git a/UI/JSComponments/entry/src/main/js/MainAbility/pages/details/details.js b/UI/JSComponments/entry/src/main/js/MainAbility/pages/details/details.js index ecec2055b6a621c0fd1ba6325dc1123d97dbb6c6..c0261a40944f00bb3264c5464a1023db821b1fa5 100644 --- a/UI/JSComponments/entry/src/main/js/MainAbility/pages/details/details.js +++ b/UI/JSComponments/entry/src/main/js/MainAbility/pages/details/details.js @@ -16,10 +16,10 @@ import router from '@ohos.router'; export default { - data: { - title: 'World' - }, - launch: function () { - router.back(); - } + data: { + title: 'World' + }, + launch: function () { + router.back(); + } } diff --git a/UI/JSComponments/entry/src/main/js/MainAbility/pages/index/index.hml b/UI/JSComponments/entry/src/main/js/MainAbility/pages/index/index.hml index 510a9d39527dcc4af00dc3c9280baa05cc794778..5ac80210cd97683616518fbd3a52991046a092c2 100644 --- a/UI/JSComponments/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/UI/JSComponments/entry/src/main/js/MainAbility/pages/index/index.hml @@ -15,206 +15,206 @@ - -
- - Case 1:Build Layout + +
+ + Case 1:Build Layout + +
+
+ +
+
+ {{ headTitle }} + + {{ paragraphFirst }} + + {{ paragraphSecond }} + + + Comment + +
+ + + Done + +
+
+ {{ inputValue }} + + + Delete + +
+
+
+ +
+
+
+ +
+ + Case 2:Add Interaction + +
+
+ + + + +
+ + Case 3:Add an External Container + +
+
+ +
+
+ + + + Image Show -
- - -
-
- {{ headTitle }} - - {{ paragraphFirst }} - - {{ paragraphSecond }} - - - Comment - -
- - - Done - -
-
- {{ inputValue }} - - - Delete - -
-
-
- -
-
-
- -
- - Case 2:Add Interaction - -
-
- - - - -
- - Case 3:Add an External Container - -
-
- -
-
- - - - Image Show - - - - - - -
-
- - - {{ $item.value0 }} - - - - {{ $item.value1 }} - - - - {{ $item.value2 }} - - - - {{ $item.value3 }} - - - -
-
-
- -
- - Case 4:Add Static Animation - -
-
- -
- - hello - - - hello - - - hello + + + + + +
+
+ + + {{ $item.value0 }} -
-
- -
- - Case 5:Add Continuous Animation + + + {{ $item.value1 }} -
-
- -
- - continuous animation + + + {{ $item.value2 }} -
- - color - -
-
- - opacity - -
- -
-
- -
- - Case 6:Add Gesture Event + + + {{ $item.value3 }} -
-
- -
-
- {{ onClick }} - -
-
- {{ touchstart }} - -
-
- {{ touchmove }} - -
-
- {{ touchend }} - -
-
- {{ onLongPress }} - -
-
-
- -
- - Case 7:Add Page Routing - -
-
- -
- - This is the index page. - - -
-
- -
- - Case 8:Add Custom Component - -
-
- -
- - Parent Component:{{ text }} - - -
-
+ + +
+
+
+ +
+ + Case 4:Add Static Animation + +
+
+ +
+ + hello + + + hello + + + hello + +
+
+ +
+ + Case 5:Add Continuous Animation + +
+
+ +
+ + continuous animation + +
+ + color + +
+
+ + opacity + +
+ +
+
+ +
+ + Case 6:Add Gesture Event + +
+
+ +
+
+ {{ onClick }} + +
+
+ {{ touchstart }} + +
+
+ {{ touchmove }} + +
+
+ {{ touchend }} + +
+
+ {{ onLongPress }} + +
+
+
+ +
+ + Case 7:Add Page Routing + +
+
+ +
+ + This is the index page. + + +
+
+ +
+ + Case 8:Add Custom Component + +
+
+ +
+ + Parent Component:{{ text }} + + +
+
\ No newline at end of file diff --git a/UI/JSComponments/entry/src/main/js/MainAbility/pages/index/index.js b/UI/JSComponments/entry/src/main/js/MainAbility/pages/index/index.js index cc499d3a38f401f710174fdde127155c173d4429..b0e54d48c13c55dc042160bcbbf8e7010a38d596 100644 --- a/UI/JSComponments/entry/src/main/js/MainAbility/pages/index/index.js +++ b/UI/JSComponments/entry/src/main/js/MainAbility/pages/index/index.js @@ -16,106 +16,106 @@ import router from '@ohos.router'; export default { - data: { - inputValue: '', - commentText: false, - likeImage: '/common/unlike.png', - isPressed: false, - total: 20, - headTitle: 'Capture the Beauty in This Moment', - paragraphFirst: 'Capture the beauty of light during the transition and fusion of ice and water. At the instant of movement and stillness, softness and rigidity, force and beauty, condensing moving moments.', - paragraphSecond: 'Reflecting the purity of nature, the innovative design upgrades your visual entertainment and ergonomic comfort. Effortlessly capture what you see and let it speak for what you feel.', - middleImage: '/common/common.png', - textList: [{ - value0: 'JS FA' - }, { - value1: 'JS AA' - }, { - value2: 'Java FA' - }, { - value3: 'Java AA' - }], - tabImage: '/common/ice.png', - colorParam: '', - opacityParam: '', - touchstart: 'touchstart', - touchmove: 'touchmove', - touchend: 'touchend', - touchcancel: 'touchcancel', - onClick: 'onclick', - onLongPress: 'onlongpress', - up: 'up', - down: 'down', - text: 'start', - showState: false - }, - textClicked(e) { - this.text = e.detail.text; - }, - focusUp: function () { - this.up = 'up focused'; - }, - blurUp: function () { - this.up = 'up'; - }, - keyUp: function () { - this.up = 'up keyed'; - }, - focusDown: function () { - this.down = 'down focused'; - }, - blurDown: function () { - this.down = 'down'; - }, - keyDown: function () { - this.down = 'down keyed'; - }, - touchEnd: function () { - this.touchend = 'ended'; - }, - touchMove: function () { - this.touchmove = 'moved'; - }, - touchStart: function () { - this.touchstart = 'touched'; - }, - longPress: function () { - this.onLongPress = 'longpressed'; - }, - click: function () { - this.onClick = 'clicked'; - }, - showAnimation: function () { - this.colorParam = ''; - this.opacityParam = ''; - this.colorParam = 'animation-color'; - this.opacityParam = 'animation-opacity'; - }, - update() { - this.commentText = !this.commentText; - }, - delete() { - this.inputValue = '' - this.commentText = !this.commentText; - }, - updateValue(e) { - this.inputValue = e.text; - }, - likeClick() { - var temp; - if (!this.isPressed) { - temp = this.total + 1; - this.likeImage = '/common/like.png'; - } else { - temp = this.total - 1; - this.likeImage = '/common/unlike.png'; - } - this.total = temp; - this.isPressed = !this.isPressed; - }, - launch: function () { - router.push({ - url: 'pages/details/details', - }); + data: { + inputValue: '', + commentText: false, + likeImage: '/common/unlike.png', + isPressed: false, + total: 20, + headTitle: 'Capture the Beauty in This Moment', + paragraphFirst: 'Capture the beauty of light during the transition and fusion of ice and water. At the instant of movement and stillness, softness and rigidity, force and beauty, condensing moving moments.', + paragraphSecond: 'Reflecting the purity of nature, the innovative design upgrades your visual entertainment and ergonomic comfort. Effortlessly capture what you see and let it speak for what you feel.', + middleImage: '/common/common.png', + textList: [{ + value0: 'JS FA' + }, { + value1: 'JS AA' + }, { + value2: 'Java FA' + }, { + value3: 'Java AA' + }], + tabImage: '/common/ice.png', + colorParam: '', + opacityParam: '', + touchstart: 'touchstart', + touchmove: 'touchmove', + touchend: 'touchend', + touchcancel: 'touchcancel', + onClick: 'onclick', + onLongPress: 'onlongpress', + up: 'up', + down: 'down', + text: 'start', + showState: false + }, + textClicked(e) { + this.text = e.detail.text; + }, + focusUp: function () { + this.up = 'up focused'; + }, + blurUp: function () { + this.up = 'up'; + }, + keyUp: function () { + this.up = 'up keyed'; + }, + focusDown: function () { + this.down = 'down focused'; + }, + blurDown: function () { + this.down = 'down'; + }, + keyDown: function () { + this.down = 'down keyed'; + }, + touchEnd: function () { + this.touchend = 'ended'; + }, + touchMove: function () { + this.touchmove = 'moved'; + }, + touchStart: function () { + this.touchstart = 'touched'; + }, + longPress: function () { + this.onLongPress = 'longpressed'; + }, + click: function () { + this.onClick = 'clicked'; + }, + showAnimation: function () { + this.colorParam = ''; + this.opacityParam = ''; + this.colorParam = 'animation-color'; + this.opacityParam = 'animation-opacity'; + }, + update() { + this.commentText = !this.commentText; + }, + delete() { + this.inputValue = '' + this.commentText = !this.commentText; + }, + updateValue(e) { + this.inputValue = e.text; + }, + likeClick() { + var temp; + if (!this.isPressed) { + temp = this.total + 1; + this.likeImage = '/common/like.png'; + } else { + temp = this.total - 1; + this.likeImage = '/common/unlike.png'; } + this.total = temp; + this.isPressed = !this.isPressed; + }, + launch: function () { + router.push({ + url: 'pages/details/details', + }); + } } \ No newline at end of file diff --git a/UI/JSComponments/package.json b/UI/JSComponments/package.json index 02f5a336341ca59f1cbec064a1e7bc1b00bddf78..1d823ce9da38ad684aba40bb0318d19922c0f7cf 100644 --- a/UI/JSComponments/package.json +++ b/UI/JSComponments/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "^1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } diff --git a/UI/JSUICustomComponent/entry/src/main/js/default/pages/index/index.hml b/UI/JSUICustomComponent/entry/src/main/js/default/pages/index/index.hml index a95dab97f4210bfe66da298c85bc9d4eb5ae51aa..83def44f245b94b196c2ad8fc98930b36b09c04e 100644 --- a/UI/JSUICustomComponent/entry/src/main/js/default/pages/index/index.hml +++ b/UI/JSUICustomComponent/entry/src/main/js/default/pages/index/index.hml @@ -1,3 +1,4 @@ +
-
- -
- {{ text }} +
+ +
+ {{ text }}
\ No newline at end of file diff --git a/UI/JsAdaptivePortalList/entry/src/main/js/MainAbility/pages/index/index.hml b/UI/JsAdaptivePortalList/entry/src/main/js/MainAbility/pages/index/index.hml index 755df01d922ec72c98f6871193413cca7afc9b5d..905c9257d6792093abd1173ab9141f3c486b178e 100644 --- a/UI/JsAdaptivePortalList/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/UI/JsAdaptivePortalList/entry/src/main/js/MainAbility/pages/index/index.hml @@ -15,57 +15,57 @@
-
- +
+ +
+
+
+ + +
-
-
- - - -
- - -
- {{ $t('strings.title') }} - - - -
- -
- {{ $t('strings.item_name') }} - {{ $t('strings.item_description') }} -
-
- {{ $t('strings.item_right_text') }} - -
-
-
-
-
-
- {{ $t('strings.second_page') }} -
-
- {{ $t('strings.third_page') }} + + +
+ {{ $t('strings.title') }} + + + +
+ +
+ {{ $t('strings.item_name') }} + {{ $t('strings.item_description') }}
-
- {{ $t('strings.fourth_page') }} +
+ {{ $t('strings.item_right_text') }} +
-
- {{ $t('strings.fifth_page') }} -
- - -
-
- -
+
+
+
+
+
+ {{ $t('strings.second_page') }} +
+
+ {{ $t('strings.third_page') }} +
+
+ {{ $t('strings.fourth_page') }} +
+
+ {{ $t('strings.fifth_page') }} +
+
+
+
+
+ +
\ No newline at end of file diff --git a/UI/JsAdaptivePortalList/entry/src/main/js/MainAbility/pages/index/index.js b/UI/JsAdaptivePortalList/entry/src/main/js/MainAbility/pages/index/index.js index 2b22f51febd00e7741cfd6f39b8343fd1125299b..73baa5d4e8341fac507ed354b5b75f81fe4b8f87 100644 --- a/UI/JsAdaptivePortalList/entry/src/main/js/MainAbility/pages/index/index.js +++ b/UI/JsAdaptivePortalList/entry/src/main/js/MainAbility/pages/index/index.js @@ -16,30 +16,30 @@ import mediaquery from '@ohos.mediaquery'; export default { - data: { - list_data: Array(16).fill().map((_, index) => ({ - id: "item_" + index - })), - tabBars: [ - { - icon: "icon_person_blue.png", text: "页签" - }, - { - icon: "icon_person_gray.png", text: "页签" - }, - { - icon: "icon_person_gray.png", text: "页签" - }, - { - icon: "icon_person_gray.png", text: "页签" - }, - ], - menu_tabs_index: 0, - isTabletLandscape: false - }, - onInit() { - mediaquery.matchMediaSync('screen and (min-aspect-ratio: 1.5) or (orientation: landscape)').on("change", (data) => { - this.isTabletLandscape = data.matches - }) - } + data: { + list_data: Array(16).fill().map((_, index) => ({ + id: "item_" + index + })), + tabBars: [ + { + icon: "icon_person_blue.png", text: "页签" + }, + { + icon: "icon_person_gray.png", text: "页签" + }, + { + icon: "icon_person_gray.png", text: "页签" + }, + { + icon: "icon_person_gray.png", text: "页签" + }, + ], + menu_tabs_index: 0, + isTabletLandscape: false + }, + onInit() { + mediaquery.matchMediaSync('screen and (min-aspect-ratio: 1.5) or (orientation: landscape)').on("change", (data) => { + this.isTabletLandscape = data.matches + }) + } } \ No newline at end of file diff --git a/UI/JsAdaptivePortalList/package.json b/UI/JsAdaptivePortalList/package.json index d8a911bd20c5ffab6c1e3f3f2d0adadc4b5f5c89..ed01f6a14889a1ef2e1cf0642f235ce50397fed7 100644 --- a/UI/JsAdaptivePortalList/package.json +++ b/UI/JsAdaptivePortalList/package.json @@ -8,8 +8,8 @@ }, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/UI/JsAdaptivePortalPage/.gitignore b/UI/JsAdaptivePortalPage/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JsAdaptivePortalPage/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JsAdaptivePortalPage/README_zh.md b/UI/JsAdaptivePortalPage/README_zh.md index 9b8779f9a6bdc78f9ac4f72cca75b6034f13e62c..e0600efc0d83194e25510c265b9160c10261cdd0 100644 --- a/UI/JsAdaptivePortalPage/README_zh.md +++ b/UI/JsAdaptivePortalPage/README_zh.md @@ -30,4 +30,4 @@ 1.本示例仅支持在大型系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/UI/JsAdaptivePortalPage/entry/package.json b/UI/JsAdaptivePortalPage/entry/package.json index db08bbf9d7439623fcfa4093ab7f013633c62d48..29732ffea047ab4e9d897d4cc7092f5e7fe3493f 100644 --- a/UI/JsAdaptivePortalPage/entry/package.json +++ b/UI/JsAdaptivePortalPage/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} \ No newline at end of file +} diff --git a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/app.js b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/app.js index c158442201abb1888ae8fb1d57f150c5ec26c36b..524b4481da6fb0a7ab96a7ce0db2e2d1e79b9bd6 100644 --- a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/app.js +++ b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/app.js @@ -13,10 +13,10 @@ * limitations under the License. */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } }; diff --git a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-card-item.css b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-card-item.css index 7bffbb4b401524f671eeb7b1e11e68818f6c8b0a..ce47261890859ed7f49779045b084cf009f2a0c3 100644 --- a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-card-item.css +++ b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-card-item.css @@ -25,7 +25,7 @@ .img-hmqs-three { width: 48px; height: 48px; - background-image:url('/common/images/item.png'); + background-image: url('/common/images/item.png'); background-size: contain; background-repeat: no-repeat; } diff --git a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-card-item.hml b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-card-item.hml index 54b83193f00b752c97a766063aa5056f5fde124c..37e47fed3d245b3b0c15f40c71c5566ccc60b057 100644 --- a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-card-item.hml +++ b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-card-item.hml @@ -14,12 +14,12 @@ -->
- -
- {{ title }} -
- - {{ author }} -
+ +
+ {{ title }} +
+ + {{ author }}
+
\ No newline at end of file diff --git a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-group-header.hml b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-group-header.hml index 10309345686b860e5a1e33f68e4dfd59351ba904..c9c5a1da92a99a6920e9845cc17d97d3aea702b4 100644 --- a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-group-header.hml +++ b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-group-header.hml @@ -14,11 +14,11 @@ -->
-
- {{ $t('strings.txt-content-title')}} -
-
- {{ $t('strings.txt-content-more') }} - -
+
+ {{ $t('strings.txt-content-title') }} +
+
+ {{ $t('strings.txt-content-more') }} + +
\ No newline at end of file diff --git a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-tabbar.css b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-tabbar.css index c8debbd21076def237c5b164928311dcaf529f49..9614f64f57113eca92941e9a88789594ec0b50fb 100644 --- a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-tabbar.css +++ b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-tabbar.css @@ -45,9 +45,11 @@ width: 100%; height: 20%; } + .img-tab-bar-bottom { margin-bottom: 2px; } + .txt-tab-bar-bottom { font-size: 10px; text-align: center; diff --git a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-tabbar.hml b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-tabbar.hml index 35ebf5dabba7ee3b4f71cf4c09cf3667e660f962..c30e59456bd6537660226f095747ce3e2313b7fd 100644 --- a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-tabbar.hml +++ b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/common/template-tabbar.hml @@ -14,8 +14,8 @@ -->
-
- -
- {{ text }} +
+ +
+ {{ text }}
\ No newline at end of file diff --git a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/pages/index/index.hml b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/pages/index/index.hml index 2ba1ee2018282a40dcc69401c68f400ffa6012da..06b4c9261c3e4b4c21b6a34b2fb9803e3b8d16a0 100644 --- a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/pages/index/index.hml @@ -18,185 +18,185 @@
-
-
- -
+
+
+
- - -
- - - - - {{ $item }} - - - - -
-
-
- - {{ $item.title }} -
-
- - - -
- -
- {{ $item.title }} -
-
-
-
+
+ + +
+ + + + + {{ $item }} + + + + +
+
+
+ + {{ $item.title }} +
+
+ + + +
+ +
+ {{ $item.title }} +
+
+
+
- - - - -
- - - - - - - - - -
-
-
+ + + + +
+ + + + + + + + + +
+
+
- - - - -
- - - - - - - - - -
-
-
+ + + + +
+ + + + + + + + + +
+
+
- - - - -
- - - - - - - - - -
-
-
-
-
-
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
- {{ $t('strings.txt-show') }} -
-
-
+ + + + +
+ + + + + + + + + +
+
+
+
+
+
+
+ {{ $t('strings.txt-show') }}
- {{ $t('strings.txt-show') }} + {{ $t('strings.txt-show') }}
- {{ $t('strings.txt-show') }} + {{ $t('strings.txt-show') }}
- {{ $t('strings.txt-show') }} + {{ $t('strings.txt-show') }}
- {{ $t('strings.txt-show') }} + {{ $t('strings.txt-show') }}
-
-
-
- -
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+ + +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+ {{ $t('strings.txt-show') }} +
+
+
+
+ +
\ No newline at end of file diff --git a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/pages/index/index.js b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/pages/index/index.js index ee23e81157d2c42b7e81daa25ef689171e2e7f82..7e7e9d91b3f53ad113fb3d52a23838baace7df59 100644 --- a/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/pages/index/index.js +++ b/UI/JsAdaptivePortalPage/entry/src/main/js/MainAbility/pages/index/index.js @@ -16,40 +16,40 @@ import mediaquery from '@ohos.mediaquery'; export default { - data: { - subTabList: ["子页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签"], - listOne: Array(5).fill(0).map((_, index) => ({ - uri: "", title: "item", id: "item_" + index - })), - listTwo: Array(16).fill(0).map((_, index) => ({ - uri: "", title: "item " + index, id: "item_" + index - })), - listThree: Array(16).fill(0).map((_, index) => ({ - msg1: "The End Of The World", msg2: "Justin Timberland", id: "item_" + index - })), - tabBars: [ - { - icon: "icon_person_blue.png", text: "页签" - }, - { - icon: "icon_person_gray.png", text: "页签" - }, - { - icon: "icon_person_gray.png", text: "页签" - }, - { - icon: "icon_person_gray.png", text: "页签" - }, - { - icon: "icon_person_gray.png", text: "页签" - }, - ], - isTablet: false, - menu_tabs_index: 0 - }, - onInit() { - mediaquery.matchMediaSync('screen and (min-aspect-ratio: 1.5) or (orientation: landscape)').on("change", (data) => { - this.isTablet = data.matches - }) - } + data: { + subTabList: ["子页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签", "页签"], + listOne: Array(5).fill(0).map((_, index) => ({ + uri: "", title: "item", id: "item_" + index + })), + listTwo: Array(16).fill(0).map((_, index) => ({ + uri: "", title: "item " + index, id: "item_" + index + })), + listThree: Array(16).fill(0).map((_, index) => ({ + msg1: "The End Of The World", msg2: "Justin Timberland", id: "item_" + index + })), + tabBars: [ + { + icon: "icon_person_blue.png", text: "页签" + }, + { + icon: "icon_person_gray.png", text: "页签" + }, + { + icon: "icon_person_gray.png", text: "页签" + }, + { + icon: "icon_person_gray.png", text: "页签" + }, + { + icon: "icon_person_gray.png", text: "页签" + }, + ], + isTablet: false, + menu_tabs_index: 0 + }, + onInit() { + mediaquery.matchMediaSync('screen and (min-aspect-ratio: 1.5) or (orientation: landscape)').on("change", (data) => { + this.isTablet = data.matches + }) + } } \ No newline at end of file diff --git a/UI/JsAdaptivePortalPage/package.json b/UI/JsAdaptivePortalPage/package.json index 56a1392890690dbbccb6e1047496442e716bd781..c207eead3ae082930a2c60d578536d7ad141429b 100644 --- a/UI/JsAdaptivePortalPage/package.json +++ b/UI/JsAdaptivePortalPage/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/UI/JsAdaptiveServiceWidget/.gitignore b/UI/JsAdaptiveServiceWidget/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JsAdaptiveServiceWidget/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JsAdaptiveServiceWidget/README_zh.md b/UI/JsAdaptiveServiceWidget/README_zh.md index c457602ad685815433dba67f4ee46da165783ac3..58d4a4c7042cf56a6fc20ae9d770301f52b9dba6 100644 --- a/UI/JsAdaptiveServiceWidget/README_zh.md +++ b/UI/JsAdaptiveServiceWidget/README_zh.md @@ -22,4 +22,4 @@ Ability开发:Ability开发概述。 1.本示例支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/FormAbility/Logger.js b/UI/JsAdaptiveServiceWidget/entry/src/main/js/FormAbility/Logger.js index db05150694d08f434482e404ac0e035526e43c7f..962b6f3d95a586618b1e01f85584c69d4ec72984 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/FormAbility/Logger.js +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/FormAbility/Logger.js @@ -13,30 +13,28 @@ * limitations under the License. */ -// - class Logger { - prefix = '' + prefix = '' - constructor(prefix) { - this.prefix = prefix - } + constructor(prefix) { + this.prefix = prefix + } - debug(...args) { - console.debug(this.prefix + args) - } + debug(...args) { + console.debug(this.prefix + args) + } - info(...args) { - console.info(this.prefix + args) - } + info(...args) { + console.info(this.prefix + args) + } - warn(...args) { - console.warn(this.prefix + args) - } + warn(...args) { + console.warn(this.prefix + args) + } - error(...args) { - console.error(this.prefix + args) - } + error(...args) { + console.error(this.prefix + args) + } } export default new Logger('[JsAdaptiveServiceWidget]') \ No newline at end of file diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/FormAbility/form.js b/UI/JsAdaptiveServiceWidget/entry/src/main/js/FormAbility/form.js index e0f250f2d6351c670b9990225ad0d8728814b371..c7d472dbd5b996f7cd2ffe36859056517dae60b8 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/FormAbility/form.js +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/FormAbility/form.js @@ -1,3 +1,17 @@ +/* + * 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 dataStorage from '@ohos.data.storage'; import formBindingData from '@ohos.application.formBindingData'; @@ -5,176 +19,175 @@ import formInfo from '@ohos.application.formInfo'; import formProvider from '@ohos.application.formProvider'; import Logger from './Logger' - const DATA_STORAGE_PATH = "/data/storage/el2/base/haps/form_store"; const FORM_PARAM_IDENTITY_KEY = "ohos.extra.param.key.form_identity"; const FORM_PARAM_NAME_KEY = "ohos.extra.param.key.form_name"; const FORM_PARAM_TEMPORARY_KEY = "ohos.extra.param.key.form_temporary"; function getTemperature(formId, count) { - const DECIMAL = 10; - const parsedFormId = parseInt(formId, DECIMAL); - const BASE_TEMP_MOD = 20; - const baseTemperature = parsedFormId % BASE_TEMP_MOD; - const RANGE_TEMP_MOD = 20; - return baseTemperature + Math.abs(count % RANGE_TEMP_MOD - RANGE_TEMP_MOD / 2); + const DECIMAL = 10; + const parsedFormId = parseInt(formId, DECIMAL); + const BASE_TEMP_MOD = 20; + const baseTemperature = parsedFormId % BASE_TEMP_MOD; + const RANGE_TEMP_MOD = 20; + return baseTemperature + Math.abs(count % RANGE_TEMP_MOD - RANGE_TEMP_MOD / 2); } function padZero(num) { - // trans num to string and pad 0 - if (num < 10) { - return `0${num}`; - } else { - return num.toString(); - } + // trans num to string and pad 0 + if (num < 10) { + return `0${num}`; + } else { + return num.toString(); + } } function getTime() { - const date = new Date(); - const hours = padZero(date.getHours()); - const minutes = padZero(date.getMinutes()); - const seconds = padZero(date.getSeconds()); - return `${hours}:${minutes}:${seconds}` + const date = new Date(); + const hours = padZero(date.getHours()); + const minutes = padZero(date.getMinutes()); + const seconds = padZero(date.getSeconds()); + return `${hours}:${minutes}:${seconds}` } async function storeFormInfo(formId, formName, tempFlag) { - let formInfo = { - "formName": formName, - "tempFlag": tempFlag, - "updateCount": 0 - }; - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // put form info - await storage.put(formId, JSON.stringify(formInfo)); - Logger.info(`storeFormInfo, put form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to storeFormInfo, err: ${JSON.stringify(err)}`); - } + let formInfo = { + "formName": formName, + "tempFlag": tempFlag, + "updateCount": 0 + }; + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // put form info + await storage.put(formId, JSON.stringify(formInfo)); + Logger.info(`storeFormInfo, put form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to storeFormInfo, err: ${JSON.stringify(err)}`); + } } async function updateTempFormInfo(formId) { - let formInfoDefault = { - "formName": "", - "tempFlag": false, - "updateCount": 0 - }; - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // get form info - const data = await storage.get(formId, JSON.stringify(formInfoDefault)); - Logger.info(`updateTempFormInfo, get form info successfully, formId: ${formId}`); - const formInfo = JSON.parse(data.toString()); - if (!formInfo.tempFlag) { - Logger.info(`updateTempFormInfo, formId: ${formId} is not temporary.`); - return; - } - - formInfo.tempFlag = false; - // update form info - await storage.put(formId, JSON.stringify(formInfo)); - Logger.info(`updateTempFormInfo, update form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to updateTempFormInfo, err: ${JSON.stringify(err)}`); + let formInfoDefault = { + "formName": "", + "tempFlag": false, + "updateCount": 0 + }; + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // get form info + const data = await storage.get(formId, JSON.stringify(formInfoDefault)); + Logger.info(`updateTempFormInfo, get form info successfully, formId: ${formId}`); + const formInfo = JSON.parse(data.toString()); + if (!formInfo.tempFlag) { + Logger.info(`updateTempFormInfo, formId: ${formId} is not temporary.`); + return; } + + formInfo.tempFlag = false; + // update form info + await storage.put(formId, JSON.stringify(formInfo)); + Logger.info(`updateTempFormInfo, update form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to updateTempFormInfo, err: ${JSON.stringify(err)}`); + } } async function updateForm(formId) { - let formInfoDefault = { - "formName": "", - "tempFlag": false, - "updateCount": 0 + let formInfoDefault = { + "formName": "", + "tempFlag": false, + "updateCount": 0 + }; + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // get form info + const data = await storage.get(formId, JSON.stringify(formInfoDefault)); + Logger.info(`updateForm, get form info successfully, formId: ${formId}`); + const formInfo = JSON.parse(data.toString()); + formInfo.updateCount = formInfo.updateCount + 1; + + let obj = { + "temperature": getTemperature(formId, formInfo.updateCount).toString(), + "time": getTime() }; - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // get form info - const data = await storage.get(formId, JSON.stringify(formInfoDefault)); - Logger.info(`updateForm, get form info successfully, formId: ${formId}`); - const formInfo = JSON.parse(data.toString()); - formInfo.updateCount = formInfo.updateCount + 1; - - let obj = { - "temperature": getTemperature(formId, formInfo.updateCount).toString(), - "time": getTime() - }; - let formData = formBindingData.createFormBindingData(obj); - formProvider.updateForm(formId, formData).catch((err) => { - Logger.error(`updateForm, err: ${JSON.stringify(err)}`); - }); - - // update form info - await storage.put(formId, JSON.stringify(formInfo)); - Logger.info(`updateForm, update form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to updateForm, err: ${JSON.stringify(err)}`); - } + let formData = formBindingData.createFormBindingData(obj); + formProvider.updateForm(formId, formData).catch((err) => { + Logger.error(`updateForm, err: ${JSON.stringify(err)}`); + }); + + // update form info + await storage.put(formId, JSON.stringify(formInfo)); + Logger.info(`updateForm, update form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to updateForm, err: ${JSON.stringify(err)}`); + } } async function deleteFormInfo(formId) { - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // del form info - await storage.delete(formId); - Logger.info(`deleteFormInfo, del form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to deleteFormInfo, err: ${JSON.stringify(err)}`); - } + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // del form info + await storage.delete(formId); + Logger.info(`deleteFormInfo, del form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to deleteFormInfo, err: ${JSON.stringify(err)}`); + } } export default { - onCreate(want) { - Logger.info(`FormAbility onCreate, want: ${JSON.stringify(want)}`); - // Called to return a FormBindingData object. - - let formId = want.parameters[FORM_PARAM_IDENTITY_KEY]; - let formName = want.parameters[FORM_PARAM_NAME_KEY]; - let tempFlag = want.parameters[FORM_PARAM_TEMPORARY_KEY]; - storeFormInfo(formId, formName, tempFlag); - - let obj = { - "temperature": getTemperature(formId, 0).toString(), - "time": getTime() - }; - let formData = {}; - return formBindingData.createFormBindingData(formData); - }, - - onCastToNormal(formId) { - // Called when the form provider is notified that a temporary form is successfully - // converted to a normal form. - Logger.info(`FormAbility onCastToNormal, formId: ${formId}`); - updateTempFormInfo(formId); - }, - - onUpdate(formId) { - // Called to notify the form provider to update a specified form. - Logger.info(`FormAbility onUpdate, formId: ${formId}`); - updateForm(formId); - }, - - onVisibilityChange(newStatus) { - // Called when the form provider receives form events from the system. - Logger.info(`FormAbility onVisibilityChange`); - }, - - onEvent(formId, message) { - // Called when a specified message event defined by the form provider is triggered. - Logger.info(`FormAbility onEvent, formId = ${formId}, message: ${JSON.stringify(message)}`); - }, - - onDestroy(formId) { - // Called to notify the form provider that a specified form has been destroyed. - Logger.info(`FormAbility onDestroy, formId = ${formId}`); - deleteFormInfo(formId); - }, - - onAcquireFormState(want) { - // Called to return a {@link FormState} object. - Logger.info(`FormAbility onAcquireFormState`); - return formInfo.FormState.READY; - } + onCreate(want) { + Logger.info(`FormAbility onCreate, want: ${JSON.stringify(want)}`); + // Called to return a FormBindingData object. + + let formId = want.parameters[FORM_PARAM_IDENTITY_KEY]; + let formName = want.parameters[FORM_PARAM_NAME_KEY]; + let tempFlag = want.parameters[FORM_PARAM_TEMPORARY_KEY]; + storeFormInfo(formId, formName, tempFlag); + + let obj = { + "temperature": getTemperature(formId, 0).toString(), + "time": getTime() + }; + let formData = {}; + return formBindingData.createFormBindingData(formData); + }, + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + Logger.info(`FormAbility onCastToNormal, formId: ${formId}`); + updateTempFormInfo(formId); + }, + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + Logger.info(`FormAbility onUpdate, formId: ${formId}`); + updateForm(formId); + }, + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + Logger.info(`FormAbility onVisibilityChange`); + }, + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + Logger.info(`FormAbility onEvent, formId = ${formId}, message: ${JSON.stringify(message)}`); + }, + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + Logger.info(`FormAbility onDestroy, formId = ${formId}`); + deleteFormInfo(formId); + }, + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + Logger.info(`FormAbility onAcquireFormState`); + return formInfo.FormState.READY; + } } \ No newline at end of file diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/app.js b/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/app.js index 6d060ffe5682c19fc83e2274a9e62cbc40a655f8..6d4065abcfbd0a337fbe6453e432981e7c70e9a6 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/app.js +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/app.js @@ -1,8 +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"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.css b/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.css index dcd80e57a8c212dca79c71dacbcf5e2e84a1f742..3b173216d31e2f63f73159a154603a799327b937 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.css +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.css @@ -39,7 +39,7 @@ margin-right: 6.7%; } -.body{ +.body { margin-top: 10%; margin-bottom: 1%; margin-left: 6.7%; diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.hml b/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.hml index 1c44274662cec9ee0d57b358797b82df37e5b6b2..d9a2a04344475083f6b1de131f62ed6b9a29f95c 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.hml @@ -14,10 +14,10 @@ -->
-
- {{ $t('strings.title') }} -
-
- {{ text }} -
+
+ {{ $t('strings.title') }} +
+
+ {{ text }} +
diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.js b/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.js index 456819aff124de563a5b968cfdcb18ca7d0291df..9d81b589bc17f32723504a943f0d6902c7425ffc 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.js +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/MainAbility/pages/index/index.js @@ -14,10 +14,10 @@ */ export default { - data: { - text: "" - }, - onInit() { - this.text = this.$t('strings.text'); - } + data: { + text: "" + }, + onInit() { + this.text = this.$t('strings.text'); + } } diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/complex/pages/index/index.hml b/UI/JsAdaptiveServiceWidget/entry/src/main/js/complex/pages/index/index.hml index 36297fce921c029e5cd7b4ff43e9aa3ac233d444..27aa25fec6db8088e52013d9718fbe6e23781b94 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/complex/pages/index/index.hml +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/complex/pages/index/index.hml @@ -14,41 +14,41 @@ -->
-
- - {{ title }} +
+ + {{ title }} +
+
+
+ {{ $item.name }} + {{ $item.num }} +
+ {{ $item.float }} + {{ $item.per }} +
-
-
- {{ $item.name }} - {{ $item.num }} -
- {{ $item.float }} - {{ $item.per }} -
-
+
+
+
+ {{ fundText }} + {{ timeText }} + {{ timeText }}
-
-
- {{ fundText }} - {{ timeText }} - {{ timeText }} -
-
-
-
- {{ $item.name }} - {{ $item.coded }} -
- {{ $item.perFront }} - {{ $item.perAfter }} -
+
+
+
+ {{ $item.name }} + {{ $item.coded }}
+ {{ $item.perFront }} + {{ $item.perAfter }} +
-
-
- - {{ $item.text }} -
+
+
+
+ + {{ $item.text }}
+
\ No newline at end of file diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/grid/pages/index/index.css b/UI/JsAdaptiveServiceWidget/entry/src/main/js/grid/pages/index/index.css index 4cf68faa1c91972069c20e54289069a4b7f1848b..a498a7f3911bb37463b2adf502b22f489ebb871f 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/grid/pages/index/index.css +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/grid/pages/index/index.css @@ -74,6 +74,7 @@ align-items: flex-end; align-content: flex-end; } + .stack-right { margin-left: 5%; justify-content: flex-end; diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/grid/pages/index/index.hml b/UI/JsAdaptiveServiceWidget/entry/src/main/js/grid/pages/index/index.hml index 4f2fa11cde251c26a7fb140cb44ff1d3f3dbbddf..5f0618820d49b865be07a950dddefcd2a854e83d 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/grid/pages/index/index.hml +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/grid/pages/index/index.hml @@ -14,28 +14,28 @@ -->
-
- - {{ $t('strings.title') }} -
-
- - - 0.33 - - - - 0.33 - -
-
- - - 0.33 - - - - 0.33 - -
+
+ + {{ $t('strings.title') }} +
+
+ + + 0.33 + + + + 0.33 + +
+
+ + + 0.33 + + + + 0.33 + +
\ No newline at end of file diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/imgText/pages/index/index.hml b/UI/JsAdaptiveServiceWidget/entry/src/main/js/imgText/pages/index/index.hml index 4523b3c5c33f8ad208deaf7ccb0443d6022c3175..e6fc60922d0ffc7b5c804d6bcec835ab557b078b 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/imgText/pages/index/index.hml +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/imgText/pages/index/index.hml @@ -14,19 +14,19 @@ -->
- -
- -
-
- {{title}} -
-
-
-
- - {{ $item.title }} - {{ $item.detail }} -
+ +
+
+
+ {{ title }} +
+
+
+
+ + {{ $item.title }} + {{ $item.detail }} +
+
\ No newline at end of file diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/immersive/pages/index/index.hml b/UI/JsAdaptiveServiceWidget/entry/src/main/js/immersive/pages/index/index.hml index d15d47279b4597b051ebdca2ca9bc1fc2137006e..4ce2593b3b47ff9e9c951c1bcb636c4f641c2943 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/immersive/pages/index/index.hml +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/immersive/pages/index/index.hml @@ -14,10 +14,10 @@ -->
-
- -
-
- -
+
+ +
+
+ +
\ No newline at end of file diff --git a/UI/JsAdaptiveServiceWidget/entry/src/main/js/text/pages/index/index.hml b/UI/JsAdaptiveServiceWidget/entry/src/main/js/text/pages/index/index.hml index 434ea8fb8863ff58a3e41dfc3136cd35e66fed82..1c23ccaad3979f990661a18342423ea48988f554 100644 --- a/UI/JsAdaptiveServiceWidget/entry/src/main/js/text/pages/index/index.hml +++ b/UI/JsAdaptiveServiceWidget/entry/src/main/js/text/pages/index/index.hml @@ -14,14 +14,14 @@ -->
-
-
- {{ $item.name }} - {{ $item.exponent }} -
-
- {{ $item.coded }} - {{ $item.per }} -
+
+
+ {{ $item.name }} + {{ $item.exponent }}
+
+ {{ $item.coded }} + {{ $item.per }} +
+
\ No newline at end of file diff --git a/UI/JsAdaptiveServiceWidget/package.json b/UI/JsAdaptiveServiceWidget/package.json index 45f295749165b1bb3b68030fb4195e8c8e79df2d..ce0caaf36da9d8d60db531c85d1cff6ca3762da7 100644 --- a/UI/JsAdaptiveServiceWidget/package.json +++ b/UI/JsAdaptiveServiceWidget/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } diff --git a/UI/JsAnimation/.gitignore b/UI/JsAnimation/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JsAnimation/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JsAnimation/README_zh.md b/UI/JsAnimation/README_zh.md index 1e81fa3d8ba52ebd4da4e455323a2891ac219110..d9b57e179ca8c36779bd30b1eadc6aee11766ab3 100644 --- a/UI/JsAnimation/README_zh.md +++ b/UI/JsAnimation/README_zh.md @@ -22,4 +22,4 @@ 1.本示例仅支持在大型系统上运行,且参考内存 ≥ 1GiB。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/UI/JsAnimation/package.json b/UI/JsAnimation/package.json index e9b2e36988b0659f95270cd33d94c7e97bd6304e..b6dc6701393450c911172eefdce700889e42472f 100644 --- a/UI/JsAnimation/package.json +++ b/UI/JsAnimation/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } diff --git a/UI/JsAnimationStyle/.gitignore b/UI/JsAnimationStyle/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JsAnimationStyle/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JsAnimationStyle/README_zh.md b/UI/JsAnimationStyle/README_zh.md index c1e0f8d3926432f88c1e4546920866bae0871d8f..9c44120837b49f4c8d9bc70e285468dce9280360 100644 --- a/UI/JsAnimationStyle/README_zh.md +++ b/UI/JsAnimationStyle/README_zh.md @@ -32,5 +32,5 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/app.js b/UI/JsAnimationStyle/entry/src/main/js/default/app.js index 8e47afff13e928a74fdcc01a108e4422404b9ac9..50007322f38c5c4328aa0e7386255727629eb48d 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/app.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } }; diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.css index b9308ce621726f4f0f22b84cea92ccc8414f310a..0f438433da8a47c41666e757b8d31e3952f1e54f 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.css @@ -26,20 +26,21 @@ background-color: #f76160; width: 100px; height: 100px; - animation-name:compositeAnimation ; + animation-name: compositeAnimation; animation-duration: 4s; animation-delay: 0s; animation-iteration-count: infinite; animation-timing-function: linear; } -@keyframes compositeAnimation -{ + +@keyframes compositeAnimation { from { background-color: #f76160; - transform:translate(100px,100px) rotate(0deg) scale(1.0); + transform: translate(100px, 100px) rotate(0deg) scale(1.0); } + to { background-color: #09ba07; - transform:translate(200px,200px) rotate(180deg) scale(1.5); + transform: translate(200px, 200px) rotate(180deg) scale(1.5); } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.hml index dd10b0876116d0699a74cf3b7f19af06bd1bc549..ebe2bd346b884dfcfad8c6ea55927ae6afc312e2 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.hml @@ -14,7 +14,7 @@ -->
- - {{ $t('strings.compositeAnimation') }} - + + {{ $t('strings.compositeAnimation') }} +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.js index 699c71d0bd509bec4cc9828057b643d152aa8758..7859b5b081442bccda2947dba16f74ea5a7bd311 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/compositeanimation/compositeanimation.js @@ -14,8 +14,7 @@ */ export default { - data: { - }, - onInit() { - } + data: {}, + onInit() { + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.css index 25abd2fe5cfe7a495e85646d9b1de8f359d5fe98..678cddeb27513e2611812995e39686d214ec3980 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.css @@ -19,7 +19,7 @@ flex-direction: column; justify-content: center; align-items: center; - padding:10px; + padding: 10px; } .translate_style { @@ -37,13 +37,13 @@ animation-timing-function: linear; } -@keyframes translate_animation -{ +@keyframes translate_animation { from { - transform:translate(0px) ; + transform: translate(0px); } + to { - transform:translate(150px) ; + transform: translate(150px); } } @@ -62,13 +62,13 @@ animation-timing-function: linear; } -@keyframes rotate_animation -{ +@keyframes rotate_animation { from { - transform:rotate(0deg); + transform: rotate(0deg); } + to { - transform:rotate(180deg); + transform: rotate(180deg); } } @@ -87,13 +87,13 @@ animation-timing-function: linear; } -@keyframes scale_animation -{ +@keyframes scale_animation { from { transform: scale(1.0); } + to { - transform:scale(2.0); + transform: scale(2.0); } } @@ -104,20 +104,21 @@ background-color: #f76160; width: 100px; height: 100px; - animation-name:compositeAnimation ; + animation-name: compositeAnimation; animation-duration: 4s; animation-delay: 0s; animation-iteration-count: infinite; animation-timing-function: linear; } -@keyframes compositeAnimation -{ + +@keyframes compositeAnimation { from { background-color: #f76160; - transform:translate(-100px,-100px) rotate(0deg) scale(1.0); + transform: translate(-100px, -100px) rotate(0deg) scale(1.0); } + to { background-color: #09ba07; - transform:translate(200px,100px) rotate(180deg) scale(1.5); + transform: translate(200px, 100px) rotate(180deg) scale(1.5); } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.hml index 73cffeb81a21cf11ef17f127b8412fd8f44ae117..cc0a6a1e461f03bb70b90a75ab44f386be5aca53 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.hml @@ -14,16 +14,16 @@ -->
- - {{ $t('strings.translate') }} - - - {{ $t('strings.rotate') }} - - - {{ $t('strings.scale') }} - - - {{ $t('strings.compositeAnimation') }} - + + {{ $t('strings.translate') }} + + + {{ $t('strings.rotate') }} + + + {{ $t('strings.scale') }} + + + {{ $t('strings.compositeAnimation') }} +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.js index 03be156b1621a1a609e95f26654c9b74094f3f51..72890be9323a658f12d84b0c5b6dfae44fadee73 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/index/index.js @@ -16,30 +16,30 @@ import router from '@ohos.router' export default { - data: {}, - onInit() { - }, - onClickTranslate() { - router.push({ - url: 'pages/animation/translate/translate' - }) - }, + data: {}, + onInit() { + }, + onClickTranslate() { + router.push({ + url: 'pages/animation/translate/translate' + }) + }, - onClickRotate() { - router.push({ - url: 'pages/animation/rotate/rotate' - }) - }, + onClickRotate() { + router.push({ + url: 'pages/animation/rotate/rotate' + }) + }, - onClickScale() { - router.push({ - url: 'pages/animation/scale/scale' - }) - }, + onClickScale() { + router.push({ + url: 'pages/animation/scale/scale' + }) + }, - onClickComposite() { - router.push({ - url: 'pages/animation/compositeanimation/compositeanimation' - }) - } + onClickComposite() { + router.push({ + url: 'pages/animation/compositeanimation/compositeanimation' + }) + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.css index 0fc7efce276a08e0d9761103ab5e93541c762a92..a1e8d345247ff523fa9b964b37ad46d8dc91112f 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.css @@ -33,12 +33,12 @@ animation-timing-function: linear; } -@keyframes rotate_animation -{ +@keyframes rotate_animation { from { - transform:rotate(0deg); + transform: rotate(0deg); } + to { - transform:rotate(180deg); + transform: rotate(180deg); } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.hml index e8ab77dd0baac005a5d8d8f1b0f521ae1ca2b165..61f9602e5e97eb234ac6780b70e9da1322cde2f1 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.hml @@ -14,7 +14,7 @@ -->
- - {{ $t('strings.rotate') }} - + + {{ $t('strings.rotate') }} +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.js index 699c71d0bd509bec4cc9828057b643d152aa8758..7859b5b081442bccda2947dba16f74ea5a7bd311 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/rotate/rotate.js @@ -14,8 +14,7 @@ */ export default { - data: { - }, - onInit() { - } + data: {}, + onInit() { + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.css index 78321739548f8d60579fa2b6e4448110974793c5..e2beb2d709a4858d055976d090aa3e8c18c7a1a2 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.css @@ -33,12 +33,12 @@ animation-timing-function: linear; } -@keyframes scale_animation -{ +@keyframes scale_animation { from { transform: scale(1.0); } + to { - transform:scale(2.0); + transform: scale(2.0); } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.hml index ed2f6797e9cce7741e1867a3e2f4f1e39060e50c..edcfaa01c898bc94f71d63f583b2e302024865ef 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.hml @@ -14,7 +14,7 @@ -->
- - {{ $t('strings.scale') }} - + + {{ $t('strings.scale') }} +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.js index 699c71d0bd509bec4cc9828057b643d152aa8758..7859b5b081442bccda2947dba16f74ea5a7bd311 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/scale/scale.js @@ -14,8 +14,7 @@ */ export default { - data: { - }, - onInit() { - } + data: {}, + onInit() { + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.css index 9de123358e34bf0e703fcfcb0b3b7edeb18b4060..230c7ac8aec83390a53458b9e1f613b76766270b 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.css @@ -34,12 +34,12 @@ animation-timing-function: linear; } -@keyframes translate_animation -{ +@keyframes translate_animation { from { - transform:translate(0px) ; + transform: translate(0px); } + to { - transform:translate(150px) ; + transform: translate(150px); } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.hml index 9216ca711cc80a2be09f32488fd0e78a6068d1d0..d570447a22766e0cb1e74052a47923b12799cc29 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.hml @@ -14,7 +14,7 @@ -->
- - {{ $t('strings.translate') }} - + + {{ $t('strings.translate') }} +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.js index 699c71d0bd509bec4cc9828057b643d152aa8758..7859b5b081442bccda2947dba16f74ea5a7bd311 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/animation/translate/translate.js @@ -14,8 +14,7 @@ */ export default { - data: { - }, - onInit() { - } + data: {}, + onInit() { + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.css index 13422eed2d8de408f2d6d3f2e12c4d440bb35858..60e4c9ddab6a984adc3dabbc30267e508607a588 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.css @@ -21,7 +21,7 @@ background-color: aliceblue; } -.demo-default{ +.demo-default { font-size: 20px; } @@ -30,7 +30,8 @@ margin-top: 10px; font-size: 20px; } -@font-face{ + +@font-face { font-family: font_bold; src: url("/common/style/SourceHanSansSC-Bold.otf"); } @@ -40,7 +41,8 @@ margin-top: 10px; font-size: 20px; } -@font-face{ + +@font-face { font-family: font_extraLight; src: url("/common/style/SourceHanSansSC-ExtraLight.otf"); } @@ -50,7 +52,8 @@ margin-top: 10px; font-size: 20px; } -@font-face{ + +@font-face { font-family: font_heavy; src: url("/common/style/SourceHanSansSC-Heavy.otf"); } @@ -60,7 +63,8 @@ margin-top: 10px; font-size: 20px; } -@font-face{ + +@font-face { font-family: font_medium; src: url("/common/style/SourceHanSansSC-Medium.otf"); } @@ -70,7 +74,8 @@ margin-top: 10px; font-size: 20px; } -@font-face{ + +@font-face { font-family: font_normal; src: url("/common/style/SourceHanSansSC-Normal.otf"); } @@ -80,7 +85,8 @@ margin-top: 10px; font-size: 20px; } -@font-face{ + +@font-face { font-family: font_regular; src: url("/common/style/SourceHanSansSC-Regular.otf"); } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.hml index 6a8aeb19a55e0c23f41b502e134e77a71f097b12..880615349eef492a3567be1b369c8a144531995e 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.hml @@ -14,11 +14,11 @@ -->
- {{$t('strings.txt_default')}} - {{$t('strings.txt_bold')}} - {{$t('strings.txt_extraLight')}} - {{$t('strings.txt_heavy')}} - {{$t('strings.txt_medium')}} - {{$t('strings.txt_normal')}} - {{$t('strings.txt_regular')}} + {{ $t('strings.txt_default') }} + {{ $t('strings.txt_bold') }} + {{ $t('strings.txt_extraLight') }} + {{ $t('strings.txt_heavy') }} + {{ $t('strings.txt_medium') }} + {{ $t('strings.txt_normal') }} + {{ $t('strings.txt_regular') }}
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.js index 699c71d0bd509bec4cc9828057b643d152aa8758..7859b5b081442bccda2947dba16f74ea5a7bd311 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/customfont/index.js @@ -14,8 +14,7 @@ */ export default { - data: { - }, - onInit() { - } + data: {}, + onInit() { + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.css index 0dab878c3514c33789b3b06abfd1b925972a7fb5..70b577e7f06c6ccc07077dfb6aad6314022595ab 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.css @@ -19,40 +19,41 @@ align-items: center; } -.style_default{ +.style_default { height: 20%; width: 100%; - font-size:10px; + font-size: 10px; text-color: black; padding-left: 10px; - background: linear-gradient(rgb(255,0,0),rgb(0, 255, 0)); + background: linear-gradient(rgb(255, 0, 0), rgb(0, 255, 0)); } -.style_angle{ + +.style_angle { height: 20%; width: 100%; - font-size:10px; + font-size: 10px; text-color: black; padding-left: 10px; margin-top: 2%; - background: linear-gradient(45deg, rgb(255,0,0),rgb(0, 255, 0)); + background: linear-gradient(45deg, rgb(255, 0, 0), rgb(0, 255, 0)); } -.style_right{ +.style_right { height: 20%; width: 100%; - font-size:10px; + font-size: 10px; text-color: black; padding-left: 10px; margin-top: 2%; - background: linear-gradient(to right, rgb(255,0,0) 90px, rgb(0, 0, 255) 60%); + background: linear-gradient(to right, rgb(255, 0, 0) 90px, rgb(0, 0, 255) 60%); } -.style_repeat{ +.style_repeat { height: 20%; width: 100%; - font-size:10px; + font-size: 10px; text-color: black; padding-left: 10px; margin-top: 2%; - background: repeating-linear-gradient(to right, rgba(255, 255, 0, 1) 30px,rgba(0, 0, 255, .5) 60px); + background: repeating-linear-gradient(to right, rgba(255, 255, 0, 1) 30px, rgba(0, 0, 255, .5) 60px); } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.hml index dc580baa33caf3d1f88c9bbef7d058f89b13c0bc..f473aa1ff457b36429147ebda97549e9f64556ae 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.hml @@ -14,19 +14,19 @@ -->
- - {{ $t('strings.default') }} - + + {{ $t('strings.default') }} + - - {{ $t('strings.angle') }} - + + {{ $t('strings.angle') }} + - - {{ $t('strings.right') }} - + + {{ $t('strings.right') }} + - - {{ $t('strings.repeat') }} - + + {{ $t('strings.repeat') }} +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.js index 699c71d0bd509bec4cc9828057b643d152aa8758..7859b5b081442bccda2947dba16f74ea5a7bd311 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/gradient/index.js @@ -14,8 +14,7 @@ */ export default { - data: { - }, - onInit() { - } + data: {}, + onInit() { + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.css index 5d24ce870dca818069d7a8fe54e09ae8f4d6007c..f21db418446c0505153c5c81f82003ff1f07f681 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.css @@ -20,6 +20,7 @@ align-items: center; padding: 10px; } + .btn { width: 60%; height: 50px; diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.hml index c5fe110137bd32ac4c75f98df73ff270e40cd138..eec681d73f92a66e55c924938697612e571fa722 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.hml @@ -14,8 +14,8 @@ -->
- - - - + + + +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.js index d23469de46b5bdbd68c2b2896eabf70284618f56..8167e2a5bfd96db230afb26ce956026c1d9e2b2e 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/index/index.js @@ -16,31 +16,31 @@ import router from '@ohos.router' export default { - data: {}, - onInit() { - }, + data: {}, + onInit() { + }, - onClickAnimationStyle() { - router.push({ - url: 'pages/animation/index/index' - }) - }, + onClickAnimationStyle() { + router.push({ + url: 'pages/animation/index/index' + }) + }, - onClickGradientStyle() { - router.push({ - url: 'pages/gradient/index' - }) - }, + onClickGradientStyle() { + router.push({ + url: 'pages/gradient/index' + }) + }, - onClickTransitionStyle() { - router.push({ - url: 'pages/transitions/index/index' - }) - }, + onClickTransitionStyle() { + router.push({ + url: 'pages/transitions/index/index' + }) + }, - onClickCustomFontStyle() { - router.push({ - url: 'pages/customfont/index' - }) - } + onClickCustomFontStyle() { + router.push({ + url: 'pages/customfont/index' + }) + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.css index fce3ae36db34d1ae6f2281e451b4b14fc78c5ef5..b4cdb9d055104953e7739644f2d8d31cda1e0e1f 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.css @@ -18,6 +18,7 @@ align-items: center; background-color: #EBFFD7; } + .div { height: 100%; flex-direction: column; diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.hml index 513b0dc3f951e10d43fbd22ad778246cef7c1b07..6ad0530f59ac785621072a71afc9804604a62c70 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.hml @@ -14,7 +14,7 @@ -->
-
- {{ $t('strings.detail') }} -
+
+ {{ $t('strings.detail') }} +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.js index 00a5a554a1912f1b1a11908126de2134a71c4943..e950aaa20e0620c3c2c816df059aae1268d7c611 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtargetpage/cardtargetpage.js @@ -16,11 +16,11 @@ import router from '@ohos.router' export default { - data: {}, - onInit() { - }, + data: {}, + onInit() { + }, - jumpBack() { - router.back(); - } + jumpBack() { + router.back(); + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtransition/cardtransition.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtransition/cardtransition.css index 31afc0135288634cad1b2db2fee7daab3535c311..095e3af5dbf68988e9002ba9fc847515be5ff4f4 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtransition/cardtransition.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtransition/cardtransition.css @@ -20,11 +20,13 @@ align-items: center; background-color: #ABDAFF; } + .item { height: 80px; background-color: #FAFAFA; margin-top: 2px; } + .outer { width: 300px; height: 100px; diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtransition/cardtransition.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtransition/cardtransition.hml index b49a715ec7996fc9c4b24a91b4eb22a5957f2fdb..267f0524bc1d9d4b919a4823fb7504ca87e77d35 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtransition/cardtransition.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/cardtransition/cardtransition.hml @@ -14,13 +14,13 @@ -->
-
- {{$t('strings.remove')}} -
- - - {{$item.title}} - - +
+ {{ $t('strings.remove') }} +
+ + + {{ $item.title }} + +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.css index 80d5b38da0a0a1465a6a7cbcd92f06d1dee8af37..257707b2f035f34603c19488f2a406d4173517bd 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.css @@ -41,6 +41,7 @@ transform: translateX(750px); opacity: 0; } + to { transform: translateX(0px); opacity: 1; diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.hml index 1a2e075bbb79013f5d281c27f589a57a1634e0a9..3f515566143006f2845dc373c9742d8786933e81 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.hml @@ -14,7 +14,7 @@ -->
-
- -
+
+ +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.js index 00a5a554a1912f1b1a11908126de2134a71c4943..e950aaa20e0620c3c2c816df059aae1268d7c611 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtarget/customtarget.js @@ -16,11 +16,11 @@ import router from '@ohos.router' export default { - data: {}, - onInit() { - }, + data: {}, + onInit() { + }, - jumpBack() { - router.back(); - } + jumpBack() { + router.back(); + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.css index fd3947b839086867c5099f26f77579eea2d78019..55b3d896aec2c51b4f54e5e45bc30338c99aa414 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.css @@ -33,6 +33,7 @@ transform: translateX(0px); opacity: 1; } + to { transform: translateX(-750px); opacity: 0; diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.hml index fb159cef0b260b1d663a8ea37c6d95c850aca539..cf31bdd511e5d9a15aa0d56ce72ce921f5fc8a59 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.hml @@ -14,5 +14,5 @@ -->
- +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.js index 99c31be277a50cf817226e7a9a18104becc164f5..e7788c17ff387b9a7722d25c07c8423c4709412f 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/customtransition/customtransition.js @@ -16,13 +16,13 @@ import router from '@ohos.router' export default { - data: {}, - onInit() { - }, + data: {}, + onInit() { + }, - onClickCustomTarget() { - router.push({ - url: 'pages/transitions/customtarget/customtarget' - }) - } + onClickCustomTarget() { + router.push({ + url: 'pages/transitions/customtarget/customtarget' + }) + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/index/index.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/index/index.hml index b8f9e8901fe269a95014a3cf132248a00eae853a..e21f7d9a8c574d25856dd4c3521f3990e75018fd 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/index/index.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/index/index.hml @@ -14,7 +14,7 @@ -->
- - - + + +
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/index/index.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/index/index.js index 4969d13c213b410f8a477ab55943fff273067ce0..aa9f759ec76202d026235f642075e08f755fcd5c 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/index/index.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/index/index.js @@ -16,24 +16,24 @@ import router from '@ohos.router' export default { - data: {}, - onInit() { - }, - onClickElement() { - router.push({ - url: 'pages/transitions/sharedelement/sharedelement' - }) - }, + data: {}, + onInit() { + }, + onClickElement() { + router.push({ + url: 'pages/transitions/sharedelement/sharedelement' + }) + }, - onClickCard() { - router.push({ - url: 'pages/transitions/cardtransition/cardtransition' - }) - }, + onClickCard() { + router.push({ + url: 'pages/transitions/cardtransition/cardtransition' + }) + }, - onClickCustomTransition() { - router.push({ - url: 'pages/transitions/customtransition/customtransition' - }) - } + onClickCustomTransition() { + router.push({ + url: 'pages/transitions/customtransition/customtransition' + }) + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.css index e3b311ad177ebfc142707beb9f4956d3bee4e30c..f387db350c8511740f3bef1970fc8377f0e11b8c 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.css @@ -31,13 +31,15 @@ shared-transition-name: shared-transition; shared-transition-timing-function: friction; } + @keyframes shared-transition { from { opacity: 0; - transform:translate(20px) ; + transform: translate(20px); } + to { opacity: 1; - transform:translate(100px) ; + transform: translate(100px); } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.hml index 1e89d5893ac0f2b5a757f665216c485f34c487f0..85b3fcae5421a391b7c5efd8b5a22266dd85eaa6 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.hml @@ -14,5 +14,6 @@ -->
- {{ $t('strings.sharedjump') }} + {{ + $t('strings.sharedjump') }}
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.js index 3599c6e45d76556474392721e220f2878c826836..bf9bc810f432c35a438c9e48ffad8fe79651e287 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedelement/sharedelement.js @@ -16,13 +16,13 @@ import router from '@ohos.router' export default { - data: {}, - onInit() { - }, + data: {}, + onInit() { + }, - jumpSharedTargetPage() { - router.push({ - url: 'pages/transitions/sharedtargetpage/sharedtargetpage', - }); - } + jumpSharedTargetPage() { + router.push({ + url: 'pages/transitions/sharedtargetpage/sharedtargetpage', + }); + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.css b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.css index 580ed254de53e2d9bf4521d2681426931dd6f3a1..4f582854e5a4232d6430fc2629ad132b8f253115 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.css +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.css @@ -30,13 +30,15 @@ shared-transition-name: shared-transition; shared-transition-timing-function: friction; } + @keyframes shared-transition { from { opacity: 1; - transform:translate(20px) ; + transform: translate(20px); } + to { opacity: 0; - transform:translate(100px) ; + transform: translate(100px); } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.hml b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.hml index 11faef5e1c09df35d61ffe5d00060fd7c848d1a3..64dd5757f2039c96d9e70061fa78995a6e2e6b74 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.hml +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.hml @@ -14,5 +14,6 @@ -->
- {{ $t('strings.sharedpaget') }} + {{ + $t('strings.sharedpaget') }}
\ No newline at end of file diff --git a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.js b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.js index 00a5a554a1912f1b1a11908126de2134a71c4943..e950aaa20e0620c3c2c816df059aae1268d7c611 100644 --- a/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.js +++ b/UI/JsAnimationStyle/entry/src/main/js/default/pages/transitions/sharedtargetpage/sharedtargetpage.js @@ -16,11 +16,11 @@ import router from '@ohos.router' export default { - data: {}, - onInit() { - }, + data: {}, + onInit() { + }, - jumpBack() { - router.back(); - } + jumpBack() { + router.back(); + } } \ No newline at end of file diff --git a/UI/JsAnimationStyle/package.json b/UI/JsAnimationStyle/package.json index 3c6c841a55116b6362b16144e66925cd525ef5c3..e8b4f8ec968063df29705205d35cc9c30673cafe 100644 --- a/UI/JsAnimationStyle/package.json +++ b/UI/JsAnimationStyle/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/UI/JsAnimator/.gitignore b/UI/JsAnimator/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JsAnimator/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JsAnimator/README_zh.md b/UI/JsAnimator/README_zh.md index 2442026c2756ce558e772a9779353537a6015b90..7c65c79279c8012a5b298bfda1a80f6c37a02d22 100644 --- a/UI/JsAnimator/README_zh.md +++ b/UI/JsAnimator/README_zh.md @@ -29,4 +29,4 @@ 2.@ohos.animator库目前仅支持类web方式调用,ets暂不支持。 -3.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/UI/JsAnimator/entry/src/main/js/MainAbility/app.js b/UI/JsAnimator/entry/src/main/js/MainAbility/app.js index e3a0891c0350ac6dec03b34963b6e570653355f2..e2e723dcb860a851fb8d1aa1e1a3e1dfa735110c 100644 --- a/UI/JsAnimator/entry/src/main/js/MainAbility/app.js +++ b/UI/JsAnimator/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/UI/JsAnimator/entry/src/main/js/MainAbility/pages/index/index.css b/UI/JsAnimator/entry/src/main/js/MainAbility/pages/index/index.css index 81233c12b6b1e4daa0f9af64a32ddabd38179aaf..aa9665e4d088adc69459de4c798c8b0206e5e45f 100644 --- a/UI/JsAnimator/entry/src/main/js/MainAbility/pages/index/index.css +++ b/UI/JsAnimator/entry/src/main/js/MainAbility/pages/index/index.css @@ -14,76 +14,76 @@ */ .container { - flex-direction: column; - width: 100%; - height: 100%; - opacity: 0.75; - background-color: #F2F3F5; + flex-direction: column; + width: 100%; + height: 100%; + opacity: 0.75; + background-color: #F2F3F5; } .title { - align-items: center; - font-size: 30fp; - text-align: center; - width: 100%; - height: 8%; - background-color: deepskyblue; + align-items: center; + font-size: 30fp; + text-align: center; + width: 100%; + height: 8%; + background-color: deepskyblue; } .sunAnimation { - display: flex; - flex-direction: column; - justify-content: flex-end; - left: 0px; - top: 0px; - width: 100%; - height: 40%; + display: flex; + flex-direction: column; + justify-content: flex-end; + left: 0px; + top: 0px; + width: 100%; + height: 40%; } .moonAnimation { - display: flex; - flex-direction: column; - justify-content: flex-start; - left: 0px; - top: 0px; - width: 100%; - height: 40%; + display: flex; + flex-direction: column; + justify-content: flex-start; + left: 0px; + top: 0px; + width: 100%; + height: 40%; } .image-sun { - width: 160px; - height: 120vp; - object-fit: contain; + width: 160px; + height: 120vp; + object-fit: contain; } .image-moon { - width: 120px; - height: 120vp; - object-fit: contain; + width: 120px; + height: 120vp; + object-fit: contain; } .divider { - height: 2%; + height: 2%; } .div-button { - height: 15%; - width: 100%; - flex-direction: row; - justify-content: space-around; - align-items: center; + height: 15%; + width: 100%; + flex-direction: row; + justify-content: space-around; + align-items: center; } .button { - height: 100%; - width: 150px; + height: 100%; + width: 150px; } .image-button { - object-fit: contain; + object-fit: contain; } .button-reverse { - height: 100%; - width: 135px; + height: 100%; + width: 135px; } diff --git a/UI/JsAnimator/package.json b/UI/JsAnimator/package.json index e99223849d54473fe4342bed45d9d2a8a9d56cef..a3a7d0b10236f9df760f0c8ff426b18a014c4d53 100644 --- a/UI/JsAnimator/package.json +++ b/UI/JsAnimator/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "^1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } diff --git a/UI/JsBasicComponents/.gitignore b/UI/JsBasicComponents/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JsBasicComponents/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JsBrightness/.gitignore b/UI/JsBrightness/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JsBrightness/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JsBrightness/README_zh.md b/UI/JsBrightness/README_zh.md index 1b9e0055e9824deeeb0b8462eda2e29150c0fe14..cb4205e232aaf0aaf4d6ee23c7146f307ae359ee 100644 --- a/UI/JsBrightness/README_zh.md +++ b/UI/JsBrightness/README_zh.md @@ -22,5 +22,5 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 diff --git a/UI/JsBrightness/entry/src/main/js/default/app.js b/UI/JsBrightness/entry/src/main/js/default/app.js index 58d12b7b501fbf46db906a86187aaf18dfb1f677..6d4065abcfbd0a337fbe6453e432981e7c70e9a6 100644 --- a/UI/JsBrightness/entry/src/main/js/default/app.js +++ b/UI/JsBrightness/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/UI/JsBrightness/entry/src/main/js/default/pages/index/index.hml b/UI/JsBrightness/entry/src/main/js/default/pages/index/index.hml index f5428ebc10717f8a039f01a24b8ff12f53189601..9dd0e24a1ef71c7f8a5c85a5e8080e8cf6eea954 100644 --- a/UI/JsBrightness/entry/src/main/js/default/pages/index/index.hml +++ b/UI/JsBrightness/entry/src/main/js/default/pages/index/index.hml @@ -14,10 +14,10 @@ -->
- {{ $t('strings.tip') }} -
- {{ $t('strings.dark') }} - - {{ $t('strings.bright') }} -
+ {{ $t('strings.tip') }} +
+ {{ $t('strings.dark') }} + + {{ $t('strings.bright') }} +
\ No newline at end of file diff --git a/UI/JsBrightness/entry/src/main/js/default/pages/index/index.js b/UI/JsBrightness/entry/src/main/js/default/pages/index/index.js index c20db2c0e93ba97d61b89e9d7aafecc03323b6f7..c504d7647d18a9c864994cb7992049fb85f7408a 100644 --- a/UI/JsBrightness/entry/src/main/js/default/pages/index/index.js +++ b/UI/JsBrightness/entry/src/main/js/default/pages/index/index.js @@ -16,13 +16,13 @@ import brightness from '@ohos.brightness'; export default { - data: { - defaultValue: 125 - }, - onInit() { - brightness.setValue(this.defaultValue); - }, - brightness(e) { - brightness.setValue(e.value); - } + data: { + defaultValue: 125 + }, + onInit() { + brightness.setValue(this.defaultValue); + }, + brightness(e) { + brightness.setValue(e.value); + } } \ No newline at end of file diff --git a/UI/JsBrightness/package.json b/UI/JsBrightness/package.json index 5fe0a3efae138fbc1a892c77ca9c4073ba82341e..64b02ffde03949bed82a15f141bb3e07cd54384a 100644 --- a/UI/JsBrightness/package.json +++ b/UI/JsBrightness/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor": "1.1.3", - "@ohos/hvigor-ohos-plugin": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor": "1.1.6", + "@ohos/hvigor-ohos-plugin": "1.1.6" } } diff --git a/UI/JsCanvas/.gitignore b/UI/JsCanvas/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JsCanvas/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JsCanvas/README_zh.md b/UI/JsCanvas/README_zh.md index 49444944d2052b128d6fc563f3c2578f178dabc6..3fd77cf42b07ff6fc7a73af458779c6b3b673f98 100644 --- a/UI/JsCanvas/README_zh.md +++ b/UI/JsCanvas/README_zh.md @@ -40,4 +40,4 @@ Canvas:提供画布组件,用于自定义绘制图形。 1.本示例仅支持标准系统运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/UI/JsCanvas/entry/src/main/js/default/app.js b/UI/JsCanvas/entry/src/main/js/default/app.js index 8e47afff13e928a74fdcc01a108e4422404b9ac9..50007322f38c5c4328aa0e7386255727629eb48d 100644 --- a/UI/JsCanvas/entry/src/main/js/default/app.js +++ b/UI/JsCanvas/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } }; diff --git a/UI/JsCanvas/entry/src/main/js/default/pages/index/index.hml b/UI/JsCanvas/entry/src/main/js/default/pages/index/index.hml index ec7fc6f4e2608a32c942e186d882dcd3f1efa5dd..dcc366037c7e72721ff7813f92bb66d31331f92b 100644 --- a/UI/JsCanvas/entry/src/main/js/default/pages/index/index.hml +++ b/UI/JsCanvas/entry/src/main/js/default/pages/index/index.hml @@ -13,29 +13,32 @@ limitations under the License. -->
-
+
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
+
+ + +
+
+ + + +
+
+ + +
+
+ + + + +
+
+ + +
-
+
diff --git a/UI/JsCanvas/entry/src/main/js/default/pages/index/index.js b/UI/JsCanvas/entry/src/main/js/default/pages/index/index.js index 197645a9f7fd7332abaca54adf2679679432cb8a..e883045d4011414585ca62831e0f73d112fb97cd 100644 --- a/UI/JsCanvas/entry/src/main/js/default/pages/index/index.js +++ b/UI/JsCanvas/entry/src/main/js/default/pages/index/index.js @@ -14,128 +14,128 @@ */ export default { - data: { - ctx: null - }, - onShow() { - const cav = this.$refs.canvas; - this.ctx = cav.getContext('2d'); - }, - imageClick() { - this.ctx.clearRect(0, 0, 300, 300); - var ctx1 = this.$element('drawImage').getContext('2d'); - var img = new Image(); - img.src = 'common/images/like_yellow.png'; - img.onload = function () { - console.log('Image load success'); - ctx1.drawImage(img, 50, 50, 200, 200); - }; - img.onerror = function () { - console.log('Image load fail'); - }; - }, - handleClick() { - this.ctx.beginPath(); - this.ctx.arc(150, 150, 50, 0, 6.28); - this.ctx.stroke(); - }, - strokeClick() { - this.ctx.beginPath(); - this.ctx.font = '25px sans-serif'; - this.ctx.strokeText("Hello World!", 80, 60); - this.ctx.stroke(); - }, - closeClick() { - this.ctx.beginPath(); - this.ctx.lineJoin = 'miter'; - this.ctx.moveTo(150, 200); - this.ctx.lineTo(120, 150); - this.ctx.lineTo(150, 100); - this.ctx.lineTo(180, 150); + data: { + ctx: null + }, + onShow() { + const cav = this.$refs.canvas; + this.ctx = cav.getContext('2d'); + }, + imageClick() { + this.ctx.clearRect(0, 0, 300, 300); + var ctx1 = this.$element('drawImage').getContext('2d'); + var img = new Image(); + img.src = 'common/images/like_yellow.png'; + img.onload = function () { + console.log('Image load success'); + ctx1.drawImage(img, 50, 50, 200, 200); + }; + img.onerror = function () { + console.log('Image load fail'); + }; + }, + handleClick() { + this.ctx.beginPath(); + this.ctx.arc(150, 150, 50, 0, 6.28); + this.ctx.stroke(); + }, + strokeClick() { + this.ctx.beginPath(); + this.ctx.font = '25px sans-serif'; + this.ctx.strokeText("Hello World!", 80, 60); + this.ctx.stroke(); + }, + closeClick() { + this.ctx.beginPath(); + this.ctx.lineJoin = 'miter'; + this.ctx.moveTo(150, 200); + this.ctx.lineTo(120, 150); + this.ctx.lineTo(150, 100); + this.ctx.lineTo(180, 150); - this.ctx.closePath(); - this.ctx.stroke(); - }, - bezierCurve() { - this.ctx.beginPath(); - this.ctx.moveTo(10, 10); - this.ctx.bezierCurveTo(90, 100, 200, 100, 290, 10); - this.ctx.stroke(); - }, - clearRect() { - this.ctx.fillStyle = '#000000' - this.ctx.clearRect(0, 0, 300, 300); - }, - textBase() { - this.ctx.beginPath(); - this.ctx.moveTo(0, 220); - this.ctx.lineTo(300, 220); + this.ctx.closePath(); + this.ctx.stroke(); + }, + bezierCurve() { + this.ctx.beginPath(); + this.ctx.moveTo(10, 10); + this.ctx.bezierCurveTo(90, 100, 200, 100, 290, 10); + this.ctx.stroke(); + }, + clearRect() { + this.ctx.fillStyle = '#000000' + this.ctx.clearRect(0, 0, 300, 300); + }, + textBase() { + this.ctx.beginPath(); + this.ctx.moveTo(0, 220); + this.ctx.lineTo(300, 220); - this.ctx.stroke(); + this.ctx.stroke(); - this.ctx.font = '20px sans-serif'; - this.ctx.strokeStyle = '#100f0f'; - this.ctx.textBaseline = 'top'; - this.ctx.fillText('Top', 10, 220); - this.ctx.textBaseline = 'bottom'; - this.ctx.fillText('Bottom', 55, 220); - this.ctx.textBaseline = 'middle'; - this.ctx.fillText('Middle', 125, 220); - this.ctx.textBaseline = 'alphabetic'; - this.ctx.fillText('Alphabetic', 195, 220); - }, - offScreen() { - var offscreen = new OffscreenCanvas(360, 500); - var offCanvas2 = offscreen.getContext("2d"); - var img = new Image(); - img.src = 'common/images/ai.png'; - offCanvas2.drawImage(img, 0, 0, 100, 100); - offCanvas2.filter = 'blur(5px)'; - offCanvas2.drawImage(img, 100, 0, 100, 100); + this.ctx.font = '20px sans-serif'; + this.ctx.strokeStyle = '#100f0f'; + this.ctx.textBaseline = 'top'; + this.ctx.fillText('Top', 10, 220); + this.ctx.textBaseline = 'bottom'; + this.ctx.fillText('Bottom', 55, 220); + this.ctx.textBaseline = 'middle'; + this.ctx.fillText('Middle', 125, 220); + this.ctx.textBaseline = 'alphabetic'; + this.ctx.fillText('Alphabetic', 195, 220); + }, + offScreen() { + var offscreen = new OffscreenCanvas(360, 500); + var offCanvas2 = offscreen.getContext("2d"); + var img = new Image(); + img.src = 'common/images/ai.png'; + offCanvas2.drawImage(img, 0, 0, 100, 100); + offCanvas2.filter = 'blur(5px)'; + offCanvas2.drawImage(img, 100, 0, 100, 100); - offCanvas2.filter = 'grayscale(50%)'; - offCanvas2.drawImage(img, 200, 0, 100, 100); + offCanvas2.filter = 'grayscale(50%)'; + offCanvas2.drawImage(img, 200, 0, 100, 100); - offCanvas2.filter = 'hue-rotate(90deg)'; - offCanvas2.drawImage(img, 0, 100, 100, 100); + offCanvas2.filter = 'hue-rotate(90deg)'; + offCanvas2.drawImage(img, 0, 100, 100, 100); - offCanvas2.filter = 'invert(100%)'; - offCanvas2.drawImage(img, 100, 100, 100, 100); + offCanvas2.filter = 'invert(100%)'; + offCanvas2.drawImage(img, 100, 100, 100, 100); - offCanvas2.filter = 'drop-shadow(8px 8px 10px green)'; - offCanvas2.drawImage(img, 200, 100, 100, 100); + offCanvas2.filter = 'drop-shadow(8px 8px 10px green)'; + offCanvas2.drawImage(img, 200, 100, 100, 100); - offCanvas2.filter = 'brightness(0.4)'; - offCanvas2.drawImage(img, 0, 200, 100, 100); + offCanvas2.filter = 'brightness(0.4)'; + offCanvas2.drawImage(img, 0, 200, 100, 100); - offCanvas2.filter = 'opacity(25%)'; - offCanvas2.drawImage(img, 100, 200, 100, 100); + offCanvas2.filter = 'opacity(25%)'; + offCanvas2.drawImage(img, 100, 200, 100, 100); - offCanvas2.filter = 'saturate(30%)'; - offCanvas2.drawImage(img, 200, 200, 100, 100); + offCanvas2.filter = 'saturate(30%)'; + offCanvas2.drawImage(img, 200, 200, 100, 100); - offCanvas2.filter = 'sepia(60%)'; - offCanvas2.drawImage(img, 0, 300, 100, 100); + offCanvas2.filter = 'sepia(60%)'; + offCanvas2.drawImage(img, 0, 300, 100, 100); - offCanvas2.filter = 'contrast(200%)'; - offCanvas2.drawImage(img, 100, 300, 100, 100); - var bitmap = offscreen.transferToImageBitmap(); - this.ctx.transferFromImageBitmap(bitmap); - }, - linearGradient() { - var gradient = this.ctx.createLinearGradient(50, 0, 300, 100); - gradient.addColorStop(0.0, 'red'); - gradient.addColorStop(0.5, 'white'); - gradient.addColorStop(1.0, 'green'); - this.ctx.fillStyle = gradient; - this.ctx.fillRect(0, 0, 500, 500); - }, - radialGradient() { - var gradient = this.ctx.createRadialGradient(150, 150, 50, 150, 150, 150); - gradient.addColorStop(0.0, 'red'); - gradient.addColorStop(0.5, 'white'); - gradient.addColorStop(1.0, 'green'); - this.ctx.fillStyle = gradient; - this.ctx.fillRect(0, 0, 500, 500); - } + offCanvas2.filter = 'contrast(200%)'; + offCanvas2.drawImage(img, 100, 300, 100, 100); + var bitmap = offscreen.transferToImageBitmap(); + this.ctx.transferFromImageBitmap(bitmap); + }, + linearGradient() { + var gradient = this.ctx.createLinearGradient(50, 0, 300, 100); + gradient.addColorStop(0.0, 'red'); + gradient.addColorStop(0.5, 'white'); + gradient.addColorStop(1.0, 'green'); + this.ctx.fillStyle = gradient; + this.ctx.fillRect(0, 0, 500, 500); + }, + radialGradient() { + var gradient = this.ctx.createRadialGradient(150, 150, 50, 150, 150, 150); + gradient.addColorStop(0.0, 'red'); + gradient.addColorStop(0.5, 'white'); + gradient.addColorStop(1.0, 'green'); + this.ctx.fillStyle = gradient; + this.ctx.fillRect(0, 0, 500, 500); + } } diff --git a/UI/JsCanvas/package.json b/UI/JsCanvas/package.json index de25679ecaa0599fa43661d95025e05c51cc85d0..83b997dd363e1b30084a8c933fe85e9a0853639f 100644 --- a/UI/JsCanvas/package.json +++ b/UI/JsCanvas/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/UI/JsDevice/.gitignore b/UI/JsDevice/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JsDevice/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JsDevice/README_zh.md b/UI/JsDevice/README_zh.md index fd4235144f9ba2a8e3ebaa0dd1b41d6010ab4392..fd87b0dda12f5cbf4a84185ceb7ee6c43e13110f 100644 --- a/UI/JsDevice/README_zh.md +++ b/UI/JsDevice/README_zh.md @@ -24,4 +24,4 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 diff --git a/UI/JsDevice/entry/src/main/js/default/app.js b/UI/JsDevice/entry/src/main/js/default/app.js index 58d12b7b501fbf46db906a86187aaf18dfb1f677..6d4065abcfbd0a337fbe6453e432981e7c70e9a6 100644 --- a/UI/JsDevice/entry/src/main/js/default/app.js +++ b/UI/JsDevice/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/UI/JsDevice/entry/src/main/js/default/common/common.css b/UI/JsDevice/entry/src/main/js/default/common/common.css index b32bf06f264b5976a02790881add5632686b4593..c82f2c6fd710cf78ea3a1adaab6c1430d9a25457 100644 --- a/UI/JsDevice/entry/src/main/js/default/common/common.css +++ b/UI/JsDevice/entry/src/main/js/default/common/common.css @@ -20,7 +20,7 @@ align-items: center; } -.title-box{ +.title-box { flex-direction: row; width: 100%; height: 90px; diff --git a/UI/JsDevice/entry/src/main/js/default/pages/batteryInfo/batteryInfo.hml b/UI/JsDevice/entry/src/main/js/default/pages/batteryInfo/batteryInfo.hml index 9a20e637c34504668817e77765037ef72bcd47bd..646028d68cdf5d542ba337ab5f34bbae10d9aff4 100644 --- a/UI/JsDevice/entry/src/main/js/default/pages/batteryInfo/batteryInfo.hml +++ b/UI/JsDevice/entry/src/main/js/default/pages/batteryInfo/batteryInfo.hml @@ -14,14 +14,14 @@ -->
-
- {{ $t('strings.batteryInfo_title') }} -
- {{ $t('strings.batterySOC') }}: {{ batterySOC }} - {{ $t('strings.chargingStatus') }}: {{ chargingStatus }} - {{ $t('strings.healthStatus') }}: {{ healthStatus }} - {{ $t('strings.pluggedType') }}: {{ pluggedType }} - {{ $t('strings.voltage') }}: {{ voltage }} - {{ $t('strings.technology') }}: {{ technology }} - {{ $t('strings.batteryTemperature') }}: {{ batteryTemperature }} +
+ {{ $t('strings.batteryInfo_title') }} +
+ {{ $t('strings.batterySOC') }}: {{ batterySOC }} + {{ $t('strings.chargingStatus') }}: {{ chargingStatus }} + {{ $t('strings.healthStatus') }}: {{ healthStatus }} + {{ $t('strings.pluggedType') }}: {{ pluggedType }} + {{ $t('strings.voltage') }}: {{ voltage }} + {{ $t('strings.technology') }}: {{ technology }} + {{ $t('strings.batteryTemperature') }}: {{ batteryTemperature }}
diff --git a/UI/JsDevice/entry/src/main/js/default/pages/batteryInfo/batteryInfo.js b/UI/JsDevice/entry/src/main/js/default/pages/batteryInfo/batteryInfo.js index 76139d85a61a3747ff057087b1252d6af50819de..1418ed5feb18fba958e438237772d7ad621ad50f 100644 --- a/UI/JsDevice/entry/src/main/js/default/pages/batteryInfo/batteryInfo.js +++ b/UI/JsDevice/entry/src/main/js/default/pages/batteryInfo/batteryInfo.js @@ -17,79 +17,79 @@ import router from '@ohos.router'; import batteryInfo from '@ohos.batteryInfo'; export default { - data: { - batterySOC: '', - chargingStatus: '', - healthStatus: '', - pluggedType: '', - voltage: '', - technology: '', - batteryTemperature: '' - }, - onInit() { - this.batteryInfo(); - }, - batteryInfo() { - this.batterySOC = batteryInfo.batterySOC; - switch (batteryInfo.chargingStatus) { - case 0: - this.chargingStatus = this.$t('strings.none'); - break; - case 1: - this.chargingStatus = this.$t('strings.enable'); - break; - case 2: - this.chargingStatus = this.$t('strings.disable'); - break; - case 3: - this.chargingStatus = this.$t('strings.full'); - break; - default: - break; - } - switch (batteryInfo.healthStatus) { - case 0: - this.healthStatus = this.$t('strings.unknown'); - break; - case 1: - this.healthStatus = this.$t('strings.good'); - break; - case 2: - this.healthStatus = this.$t('strings.overheat'); - break; - case 3: - this.healthStatus = this.$t('strings.overVoltage'); - break; - case 4: - this.healthStatus = this.$t('strings.cold'); - break; - case 5: - this.healthStatus = this.$t('strings.dead'); - break; - default: - break; - } - switch (batteryInfo.pluggedType) { - case 0: - this.pluggedType = this.$t('strings.none'); - break; - case 1: - this.pluggedType = this.$t('strings.ac'); - break; - case 2: - this.pluggedType = this.$t('strings.usb'); - break; - case 3: - this.pluggedType = this.$t('strings.wireless'); - break; - default: - break; - } - this.voltage = batteryInfo.voltage; - this.technology = batteryInfo.technology; - this.batteryTemperature = batteryInfo.batteryTemperature; - }, - back() { - router.back(); + data: { + batterySOC: '', + chargingStatus: '', + healthStatus: '', + pluggedType: '', + voltage: '', + technology: '', + batteryTemperature: '' + }, + onInit() { + this.batteryInfo(); + }, + batteryInfo() { + this.batterySOC = batteryInfo.batterySOC; + switch (batteryInfo.chargingStatus) { + case 0: + this.chargingStatus = this.$t('strings.none'); + break; + case 1: + this.chargingStatus = this.$t('strings.enable'); + break; + case 2: + this.chargingStatus = this.$t('strings.disable'); + break; + case 3: + this.chargingStatus = this.$t('strings.full'); + break; + default: + break; } + switch (batteryInfo.healthStatus) { + case 0: + this.healthStatus = this.$t('strings.unknown'); + break; + case 1: + this.healthStatus = this.$t('strings.good'); + break; + case 2: + this.healthStatus = this.$t('strings.overheat'); + break; + case 3: + this.healthStatus = this.$t('strings.overVoltage'); + break; + case 4: + this.healthStatus = this.$t('strings.cold'); + break; + case 5: + this.healthStatus = this.$t('strings.dead'); + break; + default: + break; + } + switch (batteryInfo.pluggedType) { + case 0: + this.pluggedType = this.$t('strings.none'); + break; + case 1: + this.pluggedType = this.$t('strings.ac'); + break; + case 2: + this.pluggedType = this.$t('strings.usb'); + break; + case 3: + this.pluggedType = this.$t('strings.wireless'); + break; + default: + break; + } + this.voltage = batteryInfo.voltage; + this.technology = batteryInfo.technology; + this.batteryTemperature = batteryInfo.batteryTemperature; + }, + back() { + router.back(); + } } diff --git a/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.hml b/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.hml index 2d1e1039aa08ded90ec561ec4cbb4c804830875d..ceb752fe6ed3a895280b5f868f5a74c015e81feb 100644 --- a/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.hml +++ b/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.hml @@ -14,20 +14,20 @@ -->
-
- {{ $t('strings.deviceInfo_title') }} -
- {{ $t('strings.serial') }}: {{ serial }} - {{ $t('strings.bootloaderVersion') }}: {{ bootloaderVersion }} - {{ $t('strings.securityPatchTag') }}: {{ securityPatchTag }} - {{ $t('strings.displayVersion') }}: {{ displayVersion }} - {{ $t('strings.osReleaseType') }}: {{ osReleaseType }} - {{ $t('strings.osFullName') }}: {{ osFullName }} - {{ $t('strings.majorVersion') }}: {{ majorVersion }} - {{ $t('strings.seniorVersion') }}: {{ seniorVersion }} - {{ $t('strings.featureVersion') }}: {{ featureVersion }} - {{ $t('strings.buildVersion') }}: {{ buildVersion }} - {{ $t('strings.sdkApiVersion') }}: {{ sdkApiVersion }} - {{ $t('strings.firstApiVersion') }}: {{ firstApiVersion }} - {{ $t('strings.versionId') }}: {{ versionId }} +
+ {{ $t('strings.deviceInfo_title') }} +
+ {{ $t('strings.serial') }}: {{ serial }} + {{ $t('strings.bootloaderVersion') }}: {{ bootloaderVersion }} + {{ $t('strings.securityPatchTag') }}: {{ securityPatchTag }} + {{ $t('strings.displayVersion') }}: {{ displayVersion }} + {{ $t('strings.osReleaseType') }}: {{ osReleaseType }} + {{ $t('strings.osFullName') }}: {{ osFullName }} + {{ $t('strings.majorVersion') }}: {{ majorVersion }} + {{ $t('strings.seniorVersion') }}: {{ seniorVersion }} + {{ $t('strings.featureVersion') }}: {{ featureVersion }} + {{ $t('strings.buildVersion') }}: {{ buildVersion }} + {{ $t('strings.sdkApiVersion') }}: {{ sdkApiVersion }} + {{ $t('strings.firstApiVersion') }}: {{ firstApiVersion }} + {{ $t('strings.versionId') }}: {{ versionId }}
diff --git a/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.js b/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.js index db71ef788a1cdf016d4ed6128d439b4fc91ac929..0d72dcf9174f86586a841d079cd10f63db4326da 100644 --- a/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.js +++ b/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.js @@ -17,42 +17,42 @@ import router from '@ohos.router' import deviceInfo from '@ohos.deviceInfo'; export default { - data: { - serial: '', - bootloaderVersion: '', - abiList: '', - securityPatchTag: '', - displayVersion: '', - osReleaseType: '', - osFullName: '', - majorVersion: '', - seniorVersion: '', - featureVersion: '', - buildVersion: '', - sdkApiVersion: '', - firstApiVersion: '', - versionId: '', - data1: '' - }, - onInit() { - this.deviceInfo(); - }, - deviceInfo() { - this.serial = deviceInfo.serial; - this.bootloaderVersion = deviceInfo.bootloaderVersion; - this.securityPatchTag = deviceInfo.securityPatchTag; - this.displayVersion = deviceInfo.displayVersion; - this.osReleaseType = deviceInfo.osReleaseType; - this.osFullName = deviceInfo.osFullName; - this.majorVersion = deviceInfo.majorVersion; - this.seniorVersion = deviceInfo.seniorVersion; - this.featureVersion = deviceInfo.featureVersion; - this.buildVersion = deviceInfo.buildVersion; - this.sdkApiVersion = deviceInfo.sdkApiVersion; - this.firstApiVersion = deviceInfo.firstApiVersion; - this.versionId = deviceInfo.versionId; - }, - back() { - router.back(); - } + data: { + serial: '', + bootloaderVersion: '', + abiList: '', + securityPatchTag: '', + displayVersion: '', + osReleaseType: '', + osFullName: '', + majorVersion: '', + seniorVersion: '', + featureVersion: '', + buildVersion: '', + sdkApiVersion: '', + firstApiVersion: '', + versionId: '', + data1: '' + }, + onInit() { + this.deviceInfo(); + }, + deviceInfo() { + this.serial = deviceInfo.serial; + this.bootloaderVersion = deviceInfo.bootloaderVersion; + this.securityPatchTag = deviceInfo.securityPatchTag; + this.displayVersion = deviceInfo.displayVersion; + this.osReleaseType = deviceInfo.osReleaseType; + this.osFullName = deviceInfo.osFullName; + this.majorVersion = deviceInfo.majorVersion; + this.seniorVersion = deviceInfo.seniorVersion; + this.featureVersion = deviceInfo.featureVersion; + this.buildVersion = deviceInfo.buildVersion; + this.sdkApiVersion = deviceInfo.sdkApiVersion; + this.firstApiVersion = deviceInfo.firstApiVersion; + this.versionId = deviceInfo.versionId; + }, + back() { + router.back(); + } } \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/js/default/pages/index/index.css b/UI/JsDevice/entry/src/main/js/default/pages/index/index.css index 01a3d082ca511983ede0e7267b2e92b2d8ebe63e..c11dda5a0d3d4872948bb9c6f072b0be70dc48bb 100644 --- a/UI/JsDevice/entry/src/main/js/default/pages/index/index.css +++ b/UI/JsDevice/entry/src/main/js/default/pages/index/index.css @@ -1,3 +1,18 @@ +/* + * 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; diff --git a/UI/JsDevice/entry/src/main/js/default/pages/index/index.hml b/UI/JsDevice/entry/src/main/js/default/pages/index/index.hml index ac8f48b3ead3eafb5cbefb3587b5d7237b6c2a0e..4b6bb32d9fcf580710aefa410623b4ecb66c9be9 100644 --- a/UI/JsDevice/entry/src/main/js/default/pages/index/index.hml +++ b/UI/JsDevice/entry/src/main/js/default/pages/index/index.hml @@ -1,5 +1,20 @@ +/* + * 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. + */ +
- - - + + +
diff --git a/UI/JsDevice/entry/src/main/js/default/pages/index/index.js b/UI/JsDevice/entry/src/main/js/default/pages/index/index.js index d748a7a2c700da1c83d583ab76bbaf77df3fcd64..119a9a4369c8233ee0dae1881dd7c45637eec175 100644 --- a/UI/JsDevice/entry/src/main/js/default/pages/index/index.js +++ b/UI/JsDevice/entry/src/main/js/default/pages/index/index.js @@ -1,19 +1,34 @@ +/* + * 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 '@ohos.router' export default { - deviceInfo() { - router.push({ - url: 'pages/deviceInfo/deviceInfo' - }) - }, - systemProperties() { - router.push({ - url: 'pages/systemProperties/systemProperties' - }) - }, - batteryInfo() { - router.push({ - url: 'pages/batteryInfo/batteryInfo' - }) - } + deviceInfo() { + router.push({ + url: 'pages/deviceInfo/deviceInfo' + }) + }, + systemProperties() { + router.push({ + url: 'pages/systemProperties/systemProperties' + }) + }, + batteryInfo() { + router.push({ + url: 'pages/batteryInfo/batteryInfo' + }) + } } \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.css b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.css index fe2ae24f6e6a1f137ccbb865b8e811e18801ba65..fa5656187496f8c75d1bb3f1b5a628b82930e261 100644 --- a/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.css +++ b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.css @@ -23,6 +23,7 @@ margin: 20px; padding: 20px; } + .button-row { flex-direction: row; align-items: center; diff --git a/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.hml b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.hml index e00bf588f63b61a5b40fe2334aa39139eb3bcdaa..76c113b1b900333f756651ed68cf86341575f593 100644 --- a/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.hml +++ b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.hml @@ -14,23 +14,23 @@ -->
-
- {{ $t('strings.systemProperties_title') }} -
- {{ $t('strings.results') }}: {{ results }} -
- - -
-
- - -
-
- - -
-
- -
+
+ {{ $t('strings.systemProperties_title') }} +
+ {{ $t('strings.results') }}: {{ results }} +
+ + +
+
+ + +
+
+ + +
+
+ +
diff --git a/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.js b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.js index 66266ddd352382c59e8382c124a822e5d1ac5a58..1b64ef7c64ce5dc1326155dc3153f299528bde84 100644 --- a/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.js +++ b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.js @@ -19,110 +19,110 @@ import systemParameter from '@ohos.systemParameter'; let self = null export default { - data: { - results: '' - }, - onInit() { - self = this - }, - setKey() { - try { - var promise = systemParameter.set("test.parameter.key", "testValue"); - promise.then(function (data) { - self.results = "setKey pass"; - console.log("set test.parameter.key success" + data); - }).catch(function (err) { - self.results = "set test.parameter.key error" + err.code; - console.log("set test.parameter.key error" + err.code); - }); - } catch (e) { - self.results = "set unexpected error:" + e; - console.log("set unexpected error:" + e); - } - }, - getKey() { - try { - var promise = systemParameter.get("test.parameter.key", "default"); - promise.then(function (data) { - self.results = "getKey pass"; - console.log("get test.parameter.key success:" + JSON.stringify(data)); - }).catch(function (err) { - self.results = "get test.parameter.key error:" + err.code; - console.log("get test.parameter.key error:" + err.code); - }); - } catch (e) { - self.results = "get unexpected error:" + e; - console.log("get unexpected error:" + e); - } - }, - setSync() { - try { - systemParameter.setSync("test.parameter.key", "testValue"); - this.results = "setSync pass"; - } catch (e) { - this.results = "setSync unexpected error:" + e; - console.log("setSync unexpected error:" + e); - } - }, - getSync() { - try { - var getSync = systemParameter.getSync("test.parameter.key", "default"); - console.log("getSync test.parameter.key value success:" + JSON.stringify(getSync)); - this.results = "getSync pass"; - } catch (e) { - this.results = "getSync unexpected error:" + e; - console.log("getSync unexpected error"); - } - }, - setASyncCallback() { - try { - systemParameter.set("test.parameter.key", "testValue", function (err, data) { - if (err == undefined) { - self.results = "setASyncCallback pass" - console.log("set test.parameter.key value success:" + data); - } else { - self.results = "set test.parameter.key value err:" + err.code; - console.log("set test.parameter.key value err:" + err.code); - } - }); - } catch (e) { - self.results = "set unexpected error:" + e; - console.log("set unexpected error:" + e); + data: { + results: '' + }, + onInit() { + self = this + }, + setKey() { + try { + var promise = systemParameter.set("test.parameter.key", "testValue"); + promise.then(function (data) { + self.results = "setKey pass"; + console.log("set test.parameter.key success" + data); + }).catch(function (err) { + self.results = "set test.parameter.key error" + err.code; + console.log("set test.parameter.key error" + err.code); + }); + } catch (e) { + self.results = "set unexpected error:" + e; + console.log("set unexpected error:" + e); + } + }, + getKey() { + try { + var promise = systemParameter.get("test.parameter.key", "default"); + promise.then(function (data) { + self.results = "getKey pass"; + console.log("get test.parameter.key success:" + JSON.stringify(data)); + }).catch(function (err) { + self.results = "get test.parameter.key error:" + err.code; + console.log("get test.parameter.key error:" + err.code); + }); + } catch (e) { + self.results = "get unexpected error:" + e; + console.log("get unexpected error:" + e); + } + }, + setSync() { + try { + systemParameter.setSync("test.parameter.key", "testValue"); + this.results = "setSync pass"; + } catch (e) { + this.results = "setSync unexpected error:" + e; + console.log("setSync unexpected error:" + e); + } + }, + getSync() { + try { + var getSync = systemParameter.getSync("test.parameter.key", "default"); + console.log("getSync test.parameter.key value success:" + JSON.stringify(getSync)); + this.results = "getSync pass"; + } catch (e) { + this.results = "getSync unexpected error:" + e; + console.log("getSync unexpected error"); + } + }, + setASyncCallback() { + try { + systemParameter.set("test.parameter.key", "testValue", function (err, data) { + if (err == undefined) { + self.results = "setASyncCallback pass" + console.log("set test.parameter.key value success:" + data); + } else { + self.results = "set test.parameter.key value err:" + err.code; + console.log("set test.parameter.key value err:" + err.code); } - }, - getAsyncCallback() { - try { - systemParameter.get("test.parameter.key", function (err, data) { - if (err == undefined) { - self.results = "getAsyncCallback pass"; - console.log("get test.parameter.key value success:" + data); - } else { - self.results = "get test.parameter.key value err:" + err.code; - console.log("get test.parameter.key value err:" + err.code); - } - }); - } catch (e) { - self.results = "getSync unexpected error:" + e; - console.log("getSync unexpected error:" + e); + }); + } catch (e) { + self.results = "set unexpected error:" + e; + console.log("set unexpected error:" + e); + } + }, + getAsyncCallback() { + try { + systemParameter.get("test.parameter.key", function (err, data) { + if (err == undefined) { + self.results = "getAsyncCallback pass"; + console.log("get test.parameter.key value success:" + data); + } else { + self.results = "get test.parameter.key value err:" + err.code; + console.log("get test.parameter.key value err:" + err.code); } - }, - getDefAsyncCallback() { - try { - systemParameter.get("test.parameter.key", "default", function (err, data) { - if (err == undefined) { - self.results = "getDefAsyncCallback pass"; - console.log("get test.parameter.key value success:" + data); - } else { - self.results = "get test.parameter.key value err:" + err.code; - console.log("get test.parameter.key value err:" + err.code); - } - }); - } catch (e) { - self.results = "get test.parameter.key value err:" + e; - console.log("get test.parameter.key value err:" + e); + }); + } catch (e) { + self.results = "getSync unexpected error:" + e; + console.log("getSync unexpected error:" + e); + } + }, + getDefAsyncCallback() { + try { + systemParameter.get("test.parameter.key", "default", function (err, data) { + if (err == undefined) { + self.results = "getDefAsyncCallback pass"; + console.log("get test.parameter.key value success:" + data); + } else { + self.results = "get test.parameter.key value err:" + err.code; + console.log("get test.parameter.key value err:" + err.code); } - }, - back() { - router.back(); + }); + } catch (e) { + self.results = "get test.parameter.key value err:" + e; + console.log("get test.parameter.key value err:" + e); } + }, + back() { + router.back(); + } } \ No newline at end of file diff --git a/UI/JsDevice/package.json b/UI/JsDevice/package.json index 49e4c09475669e2c892af1cdf27039c5309497c7..1d823ce9da38ad684aba40bb0318d19922c0f7cf 100644 --- a/UI/JsDevice/package.json +++ b/UI/JsDevice/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } diff --git a/UI/JsDialog/.gitignore b/UI/JsDialog/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/JsDialog/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/JsDialog/README_zh.md b/UI/JsDialog/README_zh.md index 442dfa92d76eae4e257ba6279884e53d6267e720..34dd42c264991f0bf4f3aa6bbb6d7f2b9589adae 100644 --- a/UI/JsDialog/README_zh.md +++ b/UI/JsDialog/README_zh.md @@ -24,4 +24,4 @@ JS中支持用户自定义弹窗,组件作为容器组件,用户可 1.本示例支持标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 diff --git a/UI/JsDialog/entry/src/main/js/default/app.js b/UI/JsDialog/entry/src/main/js/default/app.js index 58d12b7b501fbf46db906a86187aaf18dfb1f677..6d4065abcfbd0a337fbe6453e432981e7c70e9a6 100644 --- a/UI/JsDialog/entry/src/main/js/default/app.js +++ b/UI/JsDialog/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/UI/JsDialog/entry/src/main/js/default/pages/index/index.hml b/UI/JsDialog/entry/src/main/js/default/pages/index/index.hml index 05882115df2d8622e21efb8e5afa0a31dbbe7373..5711cf039e4136de7ba37fd4448dfc3b6479a712 100644 --- a/UI/JsDialog/entry/src/main/js/default/pages/index/index.hml +++ b/UI/JsDialog/entry/src/main/js/default/pages/index/index.hml @@ -14,62 +14,62 @@ -->
-
- {{ $t('strings.title') }} - {{ $t('strings.add') }} -
- - - -
-
-
- {{ $t('strings.name') }} - {{ $item.name }} -
-
- {{ $t('strings.phone') }} - {{ $item.phone }} -
-
- {{ $t('strings.delete') }} - -
-
-
- - - {{ $t('strings.tips') }} - -
- -
- {{ $t('strings.delete_tips') }} -
- - - -
-
-
- -
-
- {{ $t('strings.name') }} - {{ name }} +
+ {{ $t('strings.title') }} + {{ $t('strings.add') }} +
+ + + +
+
+
+ {{ $t('strings.name') }} + {{ $item.name }}
-
- {{ $t('strings.phone') }} - {{ phone }} -
-
- - - +
+ {{ $t('strings.phone') }} + {{ $item.phone }}
+
+ {{ $t('strings.delete') }} +
-
+ + + + + {{ $t('strings.tips') }} + + + +
+ {{ $t('strings.delete_tips') }} +
+ + + +
+
+
+ +
+
+ {{ $t('strings.name') }} + {{ name }} +
+
+ {{ $t('strings.phone') }} + {{ phone }} +
+
+ + + +
+
+
diff --git a/UI/JsDialog/entry/src/main/js/default/pages/index/index.js b/UI/JsDialog/entry/src/main/js/default/pages/index/index.js index a50135089f43b4968ddc3c8257848bfbb4e1f21f..a48ed056f180796da61b31b5ad24adc46a222b8a 100644 --- a/UI/JsDialog/entry/src/main/js/default/pages/index/index.js +++ b/UI/JsDialog/entry/src/main/js/default/pages/index/index.js @@ -14,48 +14,48 @@ */ export default { - data: { - listItem: [], - showTips: true, - name: '', - phone: '17700000000', - num: 0, - deleteItem: null - }, - onclick: function () { - this.name = this.$t('strings.contact') + this.num - this.$element('showDialog').show(); - }, - showDeleteDialog: function (object) { - console.info('delete:' + JSON.stringify(object)) - this.deleteItem = object - this.$element('deleteDialog').show(); - }, - cancelDeleteDialog: function () { - this.deleteItem = null - this.$element('deleteDialog').close(); - }, - cancelDialog: function () { - this.$element('showDialog').close(); - }, - onConfirm: function () { - this.num += 1 - this.listItem.push({ - 'name': this.name, 'phone': this.phone - }) - this.showTips = false - this.$element('showDialog').close(); - }, - onDeleteSure: function () { - var index = this.listItem.indexOf(this.deleteItem) - console.info('index=' + index) - this.listItem.splice(index, 1) - if (this.listItem.length === 0) { - this.num = 0 - this.showTips = true - } - this.$element('deleteDialog').close(); + data: { + listItem: [], + showTips: true, + name: '', + phone: '17700000000', + num: 0, + deleteItem: null + }, + onclick: function () { + this.name = this.$t('strings.contact') + this.num + this.$element('showDialog').show(); + }, + showDeleteDialog: function (object) { + console.info('delete:' + JSON.stringify(object)) + this.deleteItem = object + this.$element('deleteDialog').show(); + }, + cancelDeleteDialog: function () { + this.deleteItem = null + this.$element('deleteDialog').close(); + }, + cancelDialog: function () { + this.$element('showDialog').close(); + }, + onConfirm: function () { + this.num += 1 + this.listItem.push({ + 'name': this.name, 'phone': this.phone + }) + this.showTips = false + this.$element('showDialog').close(); + }, + onDeleteSure: function () { + var index = this.listItem.indexOf(this.deleteItem) + console.info('index=' + index) + this.listItem.splice(index, 1) + if (this.listItem.length === 0) { + this.num = 0 + this.showTips = true } + this.$element('deleteDialog').close(); + } } diff --git a/UI/JsDialog/package.json b/UI/JsDialog/package.json index 65f0952380f72121a9ceae99d30363b602e5094f..5b989f73f9201820d444959a3265eceebbfb0d5d 100644 --- a/UI/JsDialog/package.json +++ b/UI/JsDialog/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/UI/chart/.gitignore b/UI/chart/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/UI/chart/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/UI/chart/README_zh.md b/UI/chart/README_zh.md index ea2202a516fc8d07ae223eccf45a89c06f136987..02957c446ad439efebc468458fb56793af16a9e3 100644 --- a/UI/chart/README_zh.md +++ b/UI/chart/README_zh.md @@ -24,6 +24,6 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行 diff --git a/UI/chart/entry/package.json b/UI/chart/entry/package.json index 459f5f8dcc042c375df256a5ea921752f18e782c..48ec2fafedd2f00943b4ddeaa293c8f00b60ffe6 100644 --- a/UI/chart/entry/package.json +++ b/UI/chart/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} \ No newline at end of file +} diff --git a/UI/chart/entry/src/main/js/default/app.js b/UI/chart/entry/src/main/js/default/app.js index 8e47afff13e928a74fdcc01a108e4422404b9ac9..50007322f38c5c4328aa0e7386255727629eb48d 100644 --- a/UI/chart/entry/src/main/js/default/app.js +++ b/UI/chart/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } }; diff --git a/UI/chart/entry/src/main/js/default/pages/bar/index.css b/UI/chart/entry/src/main/js/default/pages/bar/index.css index 00e94fc6c57c9cee569466a4e6a996175cbb6dcb..44f7f2bf2e39204e2f35226d932fd7ce4e0b17f6 100644 --- a/UI/chart/entry/src/main/js/default/pages/bar/index.css +++ b/UI/chart/entry/src/main/js/default/pages/bar/index.css @@ -13,7 +13,7 @@ * limitations under the License. */ - @import '../../common/common.css'; +@import '../../common/common.css'; .data-bar { width: 95%; diff --git a/UI/chart/entry/src/main/js/default/pages/bar/index.hml b/UI/chart/entry/src/main/js/default/pages/bar/index.hml index 4c3aae497abdf2bc0292eb9dbcc8ae7732e87f47..bc69598351cd7009b8d708c46aeeb0ecd921d328 100644 --- a/UI/chart/entry/src/main/js/default/pages/bar/index.hml +++ b/UI/chart/entry/src/main/js/default/pages/bar/index.hml @@ -14,5 +14,5 @@ -->
- +
\ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/bar/index.js b/UI/chart/entry/src/main/js/default/pages/bar/index.js index 82c60cc98325b70a9d7bc7192a3052667a313fc1..7d5f806d56b14d9f81121b20436bacd3b60d407f 100644 --- a/UI/chart/entry/src/main/js/default/pages/bar/index.js +++ b/UI/chart/entry/src/main/js/default/pages/bar/index.js @@ -14,34 +14,34 @@ */ export default { - data: { - barData: [ - { - fillColor: '#f07826', - data: [763, 550, 551, 554, 731], - }, - { - fillColor: '#cce9ff', - data: [535, 776, 615, 444, 694], - }, - { - fillColor: '#ff88bb', - data: [673, 500, 574, 483, 702], - }, - ], - barOps: { - xAxis: { - min: 0, - max: 20, - display: true, - axisTick: 5, - }, - yAxis: { - min: 0, - max: 1000, - display: true, - axisTick: 10, - }, - }, - } + data: { + barData: [ + { + fillColor: '#f07826', + data: [763, 550, 551, 554, 731], + }, + { + fillColor: '#cce9ff', + data: [535, 776, 615, 444, 694], + }, + { + fillColor: '#ff88bb', + data: [673, 500, 574, 483, 702], + }, + ], + barOps: { + xAxis: { + min: 0, + max: 20, + display: true, + axisTick: 5, + }, + yAxis: { + min: 0, + max: 1000, + display: true, + axisTick: 10, + }, + }, + } } \ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/guage/index.css b/UI/chart/entry/src/main/js/default/pages/guage/index.css index 20b1bb1e544b842d5206c4dcd75ba188d78df75d..ec56340e3a37d129e78e09a2c98ef2e8552ffffa 100644 --- a/UI/chart/entry/src/main/js/default/pages/guage/index.css +++ b/UI/chart/entry/src/main/js/default/pages/guage/index.css @@ -13,7 +13,7 @@ * limitations under the License. */ - @import '../../common/common.css'; +@import '../../common/common.css'; .gauge-region { height: 200px; diff --git a/UI/chart/entry/src/main/js/default/pages/guage/index.hml b/UI/chart/entry/src/main/js/default/pages/guage/index.hml index 498cc88cc963ec3747aeb8fd6d8064c3e0be2324..8b9c0bf82f870e1ed59afa86cfc9350a31f69693 100644 --- a/UI/chart/entry/src/main/js/default/pages/guage/index.hml +++ b/UI/chart/entry/src/main/js/default/pages/guage/index.hml @@ -14,7 +14,7 @@ -->
-
- -
+
+ +
\ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/index/index.hml b/UI/chart/entry/src/main/js/default/pages/index/index.hml index 8efdb58172ce362d432587938abb44888646d3d4..ff3976d05fec37341519c267201cdaf9dd33ca26 100644 --- a/UI/chart/entry/src/main/js/default/pages/index/index.hml +++ b/UI/chart/entry/src/main/js/default/pages/index/index.hml @@ -14,10 +14,10 @@ -->
- - - - - - + + + + + +
\ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/index/index.js b/UI/chart/entry/src/main/js/default/pages/index/index.js index 6138068e8aa11e40db33a17654296b1f63eb9ffc..3b6afc025f561779d5f3193112d251d81e0890fb 100644 --- a/UI/chart/entry/src/main/js/default/pages/index/index.js +++ b/UI/chart/entry/src/main/js/default/pages/index/index.js @@ -16,10 +16,10 @@ import router from '@ohos.router'; export default { - data: {}, - onClick(type) { - router.push({ - url: 'pages/' + type +'/index' - }) - } + data: {}, + onClick(type) { + router.push({ + url: 'pages/' + type + '/index' + }) + } } diff --git a/UI/chart/entry/src/main/js/default/pages/line/index.css b/UI/chart/entry/src/main/js/default/pages/line/index.css index 33b306ad5cc3af1a6badf840226b17011a15582d..af994d323184923feb75e290710136dac7265cc2 100644 --- a/UI/chart/entry/src/main/js/default/pages/line/index.css +++ b/UI/chart/entry/src/main/js/default/pages/line/index.css @@ -13,7 +13,7 @@ * limitations under the License. */ - @import '../../common/common.css'; +@import '../../common/common.css'; .chart-data { width: 100%; diff --git a/UI/chart/entry/src/main/js/default/pages/line/index.hml b/UI/chart/entry/src/main/js/default/pages/line/index.hml index 581690989a0ca95bcf05a34f524154454f52257a..4076f96ae4aa03ee250171b838ec810920a4222b 100644 --- a/UI/chart/entry/src/main/js/default/pages/line/index.hml +++ b/UI/chart/entry/src/main/js/default/pages/line/index.hml @@ -14,5 +14,5 @@ -->
- +
\ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/line/index.js b/UI/chart/entry/src/main/js/default/pages/line/index.js index 79f26436fb3dd1b7e9b33bc4739f07452f0c3ae9..1837e5af6328d846075ec7ec3093bb57e83530c7 100644 --- a/UI/chart/entry/src/main/js/default/pages/line/index.js +++ b/UI/chart/entry/src/main/js/default/pages/line/index.js @@ -14,107 +14,107 @@ */ export default { - data: { - lineData: [ - { - strokeColor: '#0081ff', - fillColor: '#cce5ff', - data: [ - { - value: 25, - description: "25", - textLocation: "top", - textColor: '#000000' - }, - { - value: 20, - description: "20", - textLocation: "bottom", - textColor: '#000000' - }, - { - value: 37, - description: "37", - textLocation: "top", - textColor: '#000000' - }, - { - value: 48, - description: "48", - textLocation: "top", - textColor: '#000000' - }, - { - value: 27, - description: "27", - textLocation: "bottom", - textColor: '#000000' - }, - { - value: 80, - description: "80", - textLocation: "top", - textColor: '#000000' - }, - { - value: 20, - description: "20", - textLocation: "bottom", - textColor: '#000000' - }, - { - value: 66, - description: "66", - textLocation: "top", - textColor: '#000000' - }, - { - value: 21, - description: "21", - textLocation: "bottom", - textColor: '#000000' - }, - { - value: 81, - description: "81", - textLocation: "top", - textColor: '#000000' - }, - ], - gradient: true, - } + data: { + lineData: [ + { + strokeColor: '#0081ff', + fillColor: '#cce5ff', + data: [ + { + value: 25, + description: "25", + textLocation: "top", + textColor: '#000000' + }, + { + value: 20, + description: "20", + textLocation: "bottom", + textColor: '#000000' + }, + { + value: 37, + description: "37", + textLocation: "top", + textColor: '#000000' + }, + { + value: 48, + description: "48", + textLocation: "top", + textColor: '#000000' + }, + { + value: 27, + description: "27", + textLocation: "bottom", + textColor: '#000000' + }, + { + value: 80, + description: "80", + textLocation: "top", + textColor: '#000000' + }, + { + value: 20, + description: "20", + textLocation: "bottom", + textColor: '#000000' + }, + { + value: 66, + description: "66", + textLocation: "top", + textColor: '#000000' + }, + { + value: 21, + description: "21", + textLocation: "bottom", + textColor: '#000000' + }, + { + value: 81, + description: "81", + textLocation: "top", + textColor: '#000000' + }, ], - lineOps: { - xAxis: { - min: 0, - max: 10, - axisTick: 10, - display: true, - }, - yAxis: { - min: 0, - max: 100, - axisTick: 20, - display: true, - }, - series: { - lineStyle: { - width: "3px", - smooth: true, - }, - headPoint: { - shape: "circle", - size: 5, - strokeWidth: 5, - fillColor: '#000000', - strokeColor: '#007aff', - display: true, - }, - loop: { - margin: 2, - gradient: true, - } - } + gradient: true, + } + ], + lineOps: { + xAxis: { + min: 0, + max: 10, + axisTick: 10, + display: true, + }, + yAxis: { + min: 0, + max: 100, + axisTick: 20, + display: true, + }, + series: { + lineStyle: { + width: "3px", + smooth: true, }, - } + headPoint: { + shape: "circle", + size: 5, + strokeWidth: 5, + fillColor: '#000000', + strokeColor: '#007aff', + display: true, + }, + loop: { + margin: 2, + gradient: true, + } + } + }, + } } \ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/loading/index.css b/UI/chart/entry/src/main/js/default/pages/loading/index.css index e0928b14fb9036b2b2a604fcaf58737ba4d6e798..778677361a936e3954c78c0e8e459af1bee1d91d 100644 --- a/UI/chart/entry/src/main/js/default/pages/loading/index.css +++ b/UI/chart/entry/src/main/js/default/pages/loading/index.css @@ -13,7 +13,7 @@ * limitations under the License. */ - @import '../../common/common.css'; +@import '../../common/common.css'; .chart-data { width: 200px; diff --git a/UI/chart/entry/src/main/js/default/pages/loading/index.hml b/UI/chart/entry/src/main/js/default/pages/loading/index.hml index a773997edd51e4f5ecbb16fb5bd1c61a31450797..12b30c7d0c71667751551136aaefe48281d281af 100644 --- a/UI/chart/entry/src/main/js/default/pages/loading/index.hml +++ b/UI/chart/entry/src/main/js/default/pages/loading/index.hml @@ -14,5 +14,5 @@ -->
- +
\ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/loading/index.js b/UI/chart/entry/src/main/js/default/pages/loading/index.js index 601b567c3e6c0f7f41989619cc39a6efc99108a6..92047bab9ec3e388650059fb65fd518a7d305554 100644 --- a/UI/chart/entry/src/main/js/default/pages/loading/index.js +++ b/UI/chart/entry/src/main/js/default/pages/loading/index.js @@ -14,9 +14,9 @@ */ export default { - data: { - segment: { - value: 100 - } + data: { + segment: { + value: 100 } + } } \ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/progress/index.css b/UI/chart/entry/src/main/js/default/pages/progress/index.css index e0928b14fb9036b2b2a604fcaf58737ba4d6e798..778677361a936e3954c78c0e8e459af1bee1d91d 100644 --- a/UI/chart/entry/src/main/js/default/pages/progress/index.css +++ b/UI/chart/entry/src/main/js/default/pages/progress/index.css @@ -13,7 +13,7 @@ * limitations under the License. */ - @import '../../common/common.css'; +@import '../../common/common.css'; .chart-data { width: 200px; diff --git a/UI/chart/entry/src/main/js/default/pages/progress/index.hml b/UI/chart/entry/src/main/js/default/pages/progress/index.hml index 34bf424e2e75d5b053ea5ee0b79b84a7aefedb90..60ac1a33fc6776ce2634236f48ef830102dbdf82 100644 --- a/UI/chart/entry/src/main/js/default/pages/progress/index.hml +++ b/UI/chart/entry/src/main/js/default/pages/progress/index.hml @@ -14,5 +14,5 @@ -->
- +
\ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/progress/index.js b/UI/chart/entry/src/main/js/default/pages/progress/index.js index 601b567c3e6c0f7f41989619cc39a6efc99108a6..92047bab9ec3e388650059fb65fd518a7d305554 100644 --- a/UI/chart/entry/src/main/js/default/pages/progress/index.js +++ b/UI/chart/entry/src/main/js/default/pages/progress/index.js @@ -14,9 +14,9 @@ */ export default { - data: { - segment: { - value: 100 - } + data: { + segment: { + value: 100 } + } } \ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/rainbow/index.css b/UI/chart/entry/src/main/js/default/pages/rainbow/index.css index 3855e1e2b426a5ec8198d7e9d9185c0b30055a52..e793cdfee0bacdce90fadbda4ed80b6a481e96c1 100644 --- a/UI/chart/entry/src/main/js/default/pages/rainbow/index.css +++ b/UI/chart/entry/src/main/js/default/pages/rainbow/index.css @@ -13,7 +13,7 @@ * limitations under the License. */ - @import '../../common/common.css'; +@import '../../common/common.css'; .chart-data { width: 170px; diff --git a/UI/chart/entry/src/main/js/default/pages/rainbow/index.hml b/UI/chart/entry/src/main/js/default/pages/rainbow/index.hml index 4b5cb5bed8a680c1f25fa461c00bdf770c0fd1e8..294772da2f826824fbc80f65bb1154608f1decb5 100644 --- a/UI/chart/entry/src/main/js/default/pages/rainbow/index.hml +++ b/UI/chart/entry/src/main/js/default/pages/rainbow/index.hml @@ -14,27 +14,27 @@ -->
- -
-
-
- {{ $t('strings.accounted') }} 40% -
-
-
- {{ $t('strings.accounted') }} 20% -
-
-
- {{ $t('strings.accounted') }} 10% -
-
-
- {{ $t('strings.accounted') }} 15% -
-
-
- {{ $t('strings.accounted') }} 15% -
+ +
+
+
+ {{ $t('strings.accounted') }} 40%
+
+
+ {{ $t('strings.accounted') }} 20% +
+
+
+ {{ $t('strings.accounted') }} 10% +
+
+
+ {{ $t('strings.accounted') }} 15% +
+
+
+ {{ $t('strings.accounted') }} 15% +
+
\ No newline at end of file diff --git a/UI/chart/entry/src/main/js/default/pages/rainbow/index.js b/UI/chart/entry/src/main/js/default/pages/rainbow/index.js index 04614d8e0ba18d922095bd6d602febae4b12fa96..c042d17b1123c0bfe6ab0861029976eddc203a1c 100644 --- a/UI/chart/entry/src/main/js/default/pages/rainbow/index.js +++ b/UI/chart/entry/src/main/js/default/pages/rainbow/index.js @@ -14,33 +14,33 @@ */ export default { - data: { - segment: [ - { - startColor: "#f7ce00", - endColor: "#f99b11", - value: 40 - }, - { - startColor: "#f76223", - endColor: "#f2400a", - value: 20 - }, - { - startColor: "#f772ac", - endColor: "#e65392", - value: 10 - }, - { - startColor: "#a575eb", - endColor: "#a12df7", - value: 15 - }, - { - startColor: "#7b79f7", - endColor: "#4b48f7", - value: 15 - } - ] - } + data: { + segment: [ + { + startColor: "#f7ce00", + endColor: "#f99b11", + value: 40 + }, + { + startColor: "#f76223", + endColor: "#f2400a", + value: 20 + }, + { + startColor: "#f772ac", + endColor: "#e65392", + value: 10 + }, + { + startColor: "#a575eb", + endColor: "#a12df7", + value: 15 + }, + { + startColor: "#7b79f7", + endColor: "#4b48f7", + value: 15 + } + ] + } } \ No newline at end of file diff --git a/UI/chart/package.json b/UI/chart/package.json index 5a670c660bf31fda61855a83bba60704f3fab02a..aac0e27f1b111a0ed6d7e2651b733cbd260d2a34 100644 --- a/UI/chart/package.json +++ b/UI/chart/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/ability/FormAbility/.gitignore b/ability/FormAbility/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/ability/FormAbility/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/ability/FormAbility/README_zh.md b/ability/FormAbility/README_zh.md index a8d84af5282c1f8371ced5653961d96fc7e3f4f6..6296336d9d630f2dd48bf7d3efe9b77e026d3918 100644 --- a/ability/FormAbility/README_zh.md +++ b/ability/FormAbility/README_zh.md @@ -26,4 +26,4 @@ 1.本示例仅支持标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/ability/FormAbility/entry/src/main/ets/FormAbility/form.ts b/ability/FormAbility/entry/src/main/ets/FormAbility/form.ts index 30b83a3700bd47a3dcc7afaa035222b236419fd3..5fb511fa1cb6dd5790a84889c883d51387d0de34 100644 --- a/ability/FormAbility/entry/src/main/ets/FormAbility/form.ts +++ b/ability/FormAbility/entry/src/main/ets/FormAbility/form.ts @@ -25,156 +25,156 @@ const FORM_PARAM_NAME_KEY = "ohos.extra.param.key.form_name"; const FORM_PARAM_TEMPORARY_KEY = "ohos.extra.param.key.form_temporary"; function getTemperature(formId: string, count: number) { - const DECIMAL: number = 10; - const parsedFormId: number = parseInt(formId, DECIMAL); - const BASE_TEMP_MOD: number = 20; - const baseTemperature: number = parsedFormId % BASE_TEMP_MOD; - const RANGE_TEMP_MOD: number = 20; - return baseTemperature + Math.abs(count % RANGE_TEMP_MOD - RANGE_TEMP_MOD / 2); + const DECIMAL: number = 10; + const parsedFormId: number = parseInt(formId, DECIMAL); + const BASE_TEMP_MOD: number = 20; + const baseTemperature: number = parsedFormId % BASE_TEMP_MOD; + const RANGE_TEMP_MOD: number = 20; + return baseTemperature + Math.abs(count % RANGE_TEMP_MOD - RANGE_TEMP_MOD / 2); } function padZero(num: number) { - // trans num to string and pad 0 - if (num < 10) { - return `0${num}`; - } else { - return num.toString(); - } + // trans num to string and pad 0 + if (num < 10) { + return `0${num}`; + } else { + return num.toString(); + } } function getTime() { - const date = new Date(); - const hours = padZero(date.getHours()); - const minutes = padZero(date.getMinutes()); - const seconds = padZero(date.getSeconds()); - return `${hours}:${minutes}:${seconds}` + const date = new Date(); + const hours = padZero(date.getHours()); + const minutes = padZero(date.getMinutes()); + const seconds = padZero(date.getSeconds()); + return `${hours}:${minutes}:${seconds}` } async function storeFormInfo(formId: string, formName: string, tempFlag: boolean) { - let formInfo = { - "formName": formName, - "tempFlag": tempFlag, - "updateCount": 0 - }; - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // put form info - await storage.put(formId, JSON.stringify(formInfo)); - Logger.log(`storeFormInfo, put form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to storeFormInfo, err: ${JSON.stringify(err)}`); - } + let formInfo = { + "formName": formName, + "tempFlag": tempFlag, + "updateCount": 0 + }; + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // put form info + await storage.put(formId, JSON.stringify(formInfo)); + Logger.log(`storeFormInfo, put form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to storeFormInfo, err: ${JSON.stringify(err)}`); + } } async function updateTempFormInfo(formId: string) { - let formInfoDefault = { - "formName": "", - "tempFlag": false, - "updateCount": 0 - }; - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // get form info - const data = await storage.get(formId, JSON.stringify(formInfoDefault)); - Logger.log(`updateTempFormInfo, get form info successfully, formId: ${formId}`); - const formInfo = JSON.parse(data.toString()); - if (!formInfo.tempFlag) { - Logger.log(`updateTempFormInfo, formId: ${formId} is not temporary.`); - return; - } - - formInfo.tempFlag = false; - // update form info - await storage.put(formId, JSON.stringify(formInfo)); - Logger.log(`updateTempFormInfo, update form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to updateTempFormInfo, err: ${JSON.stringify(err)}`); + let formInfoDefault = { + "formName": "", + "tempFlag": false, + "updateCount": 0 + }; + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // get form info + const data = await storage.get(formId, JSON.stringify(formInfoDefault)); + Logger.log(`updateTempFormInfo, get form info successfully, formId: ${formId}`); + const formInfo = JSON.parse(data.toString()); + if (!formInfo.tempFlag) { + Logger.log(`updateTempFormInfo, formId: ${formId} is not temporary.`); + return; } + + formInfo.tempFlag = false; + // update form info + await storage.put(formId, JSON.stringify(formInfo)); + Logger.log(`updateTempFormInfo, update form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to updateTempFormInfo, err: ${JSON.stringify(err)}`); + } } async function updateForm(formId: string) { - let formInfoDefault = { - "formName": "", - "tempFlag": false, - "updateCount": 0 - }; - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // get form info - const data = await storage.get(formId, JSON.stringify(formInfoDefault)); - Logger.log(`updateForm, get form info successfully, formId: ${formId}`); - const formInfo = JSON.parse(data.toString()); - formInfo.updateCount = formInfo.updateCount + 1; + let formInfoDefault = { + "formName": "", + "tempFlag": false, + "updateCount": 0 + }; + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // get form info + const data = await storage.get(formId, JSON.stringify(formInfoDefault)); + Logger.log(`updateForm, get form info successfully, formId: ${formId}`); + const formInfo = JSON.parse(data.toString()); + formInfo.updateCount = formInfo.updateCount + 1; - let obj = { - "temperature": getTemperature(formId, formInfo.updateCount).toString(), - "time": getTime() - }; - let formData = formBindingData.createFormBindingData(obj); - formProvider.updateForm(formId, formData).catch((err) => { - Logger.error(`updateForm, err: ${JSON.stringify(err)}`); - }); + let obj = { + "temperature": getTemperature(formId, formInfo.updateCount).toString(), + "time": getTime() + }; + let formData = formBindingData.createFormBindingData(obj); + formProvider.updateForm(formId, formData).catch((err) => { + Logger.error(`updateForm, err: ${JSON.stringify(err)}`); + }); - // update form info - await storage.put(formId, JSON.stringify(formInfo)); - Logger.log(`updateForm, update form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to updateForm, err: ${JSON.stringify(err)}`); - } + // update form info + await storage.put(formId, JSON.stringify(formInfo)); + Logger.log(`updateForm, update form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to updateForm, err: ${JSON.stringify(err)}`); + } } async function deleteFormInfo(formId: string) { - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // del form info - await storage.delete(formId); - Logger.log(`deleteFormInfo, del form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to deleteFormInfo, err: ${JSON.stringify(err)}`); - } + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // del form info + await storage.delete(formId); + Logger.log(`deleteFormInfo, del form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to deleteFormInfo, err: ${JSON.stringify(err)}`); + } } export default { - onCreate(want) { - Logger.log(`FormAbility onCreate, want: ${JSON.stringify(want)}`); + onCreate(want) { + Logger.log(`FormAbility onCreate, want: ${JSON.stringify(want)}`); - // get form info - let formId = want.parameters[FORM_PARAM_IDENTITY_KEY]; - let formName = want.parameters[FORM_PARAM_NAME_KEY]; - let tempFlag = want.parameters[FORM_PARAM_TEMPORARY_KEY]; - storeFormInfo(formId, formName, tempFlag); + // get form info + let formId = want.parameters[FORM_PARAM_IDENTITY_KEY]; + let formName = want.parameters[FORM_PARAM_NAME_KEY]; + let tempFlag = want.parameters[FORM_PARAM_TEMPORARY_KEY]; + storeFormInfo(formId, formName, tempFlag); - let obj = { - "temperature": getTemperature(formId, 0).toString(), - "time": getTime() - }; - let formData = formBindingData.createFormBindingData(obj); - return formData; - }, - onCastToNormal(formId) { - Logger.log(`FormAbility onCastToNormal, formId: ${formId}`); - updateTempFormInfo(formId); - }, - onUpdate(formId) { - Logger.log(`FormAbility onUpdate, formId: ${formId}`); - updateForm(formId); - }, - onVisibilityChange(newStatus) { - Logger.log(`FormAbility onVisibilityChange`); - }, - onEvent(formId, message) { - Logger.log(`FormAbility onEvent, formId = ${formId}, message: ${JSON.stringify(message)}`); - }, - onDestroy(formId) { - Logger.log(`FormAbility onDestroy, formId = ${formId}`); - deleteFormInfo(formId); - }, - onAcquireFormState(want) { - Logger.log(`FormAbility onAcquireFormState`); - return formInfo.FormState.READY; - }, + let obj = { + "temperature": getTemperature(formId, 0).toString(), + "time": getTime() + }; + let formData = formBindingData.createFormBindingData(obj); + return formData; + }, + onCastToNormal(formId) { + Logger.log(`FormAbility onCastToNormal, formId: ${formId}`); + updateTempFormInfo(formId); + }, + onUpdate(formId) { + Logger.log(`FormAbility onUpdate, formId: ${formId}`); + updateForm(formId); + }, + onVisibilityChange(newStatus) { + Logger.log(`FormAbility onVisibilityChange`); + }, + onEvent(formId, message) { + Logger.log(`FormAbility onEvent, formId = ${formId}, message: ${JSON.stringify(message)}`); + }, + onDestroy(formId) { + Logger.log(`FormAbility onDestroy, formId = ${formId}`); + deleteFormInfo(formId); + }, + onAcquireFormState(want) { + Logger.log(`FormAbility onAcquireFormState`); + return formInfo.FormState.READY; + }, } diff --git a/ability/FormAbility/entry/src/main/ets/model/Logger.ts b/ability/FormAbility/entry/src/main/ets/model/Logger.ts index 28f4cb864c6de0c25abcc899c5fe66c259015896..1708e3bf85e3411db03753b62ee2c868de8bd461 100644 --- a/ability/FormAbility/entry/src/main/ets/model/Logger.ts +++ b/ability/FormAbility/entry/src/main/ets/model/Logger.ts @@ -14,22 +14,28 @@ */ class Logger { - constructor(private prefix: string) {} - public log(...args: any[]) { - console.log(`[${this.prefix}]: ${args.join('')}`) - } - public info(...args: any[]) { - console.info(`[${this.prefix}]: ${args.join('')}`) - } - public debug(...args: any[]) { - console.debug(`[${this.prefix}]: ${args.join('')}`) - } - public warn(...args: any[]) { - console.warn(`[${this.prefix}]: ${args.join('')}`) - } - public error(...args: any[]) { - console.error(`[${this.prefix}]: ${args.join('')}`) - } + constructor(private prefix: string) { + } + + public log(...args: any[]) { + console.log(`[${this.prefix}]: ${args.join('')}`) + } + + public info(...args: any[]) { + console.info(`[${this.prefix}]: ${args.join('')}`) + } + + public debug(...args: any[]) { + console.debug(`[${this.prefix}]: ${args.join('')}`) + } + + public warn(...args: any[]) { + console.warn(`[${this.prefix}]: ${args.join('')}`) + } + + public error(...args: any[]) { + console.error(`[${this.prefix}]: ${args.join('')}`) + } } export default new Logger('eTSFormAbility') diff --git a/ability/FormAbility/entry/src/main/js/widget/pages/index/index.hml b/ability/FormAbility/entry/src/main/js/widget/pages/index/index.hml index 05b5b96a9def87cd21de370fd7f90140434b757d..23930fa5405b9bd5e42e1b3f36a7fa893d2bd6af 100644 --- a/ability/FormAbility/entry/src/main/js/widget/pages/index/index.hml +++ b/ability/FormAbility/entry/src/main/js/widget/pages/index/index.hml @@ -1,11 +1,11 @@
- -
- -
-
- {{ $t('strings.temperature') }}{{temperature}} ℃ - {{ $t('strings.time') }} {{time}} -
-
+ +
+ +
+
+ {{ $t('strings.temperature') }}{{ temperature }} ℃ + {{ $t('strings.time') }} {{ time }} +
+
\ No newline at end of file diff --git a/ability/FormAbility/package.json b/ability/FormAbility/package.json index 4671fd2685a19780cfba8ec292f98a2247222d97..bdbbe79e621cf484aa7aec22a9ed178874f58ee9 100644 --- a/ability/FormAbility/package.json +++ b/ability/FormAbility/package.json @@ -8,8 +8,8 @@ }, "version": "1.0.0", "dependencies": { - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3", - "@ohos/hypium": "1.0.0" + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6", + "@ohos/hypium": "1.0.1" } } diff --git a/ability/FormExtAbility/.gitignore b/ability/FormExtAbility/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/ability/FormExtAbility/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/ability/FormExtAbility/README_zh.md b/ability/FormExtAbility/README_zh.md index 8b4fe71441690c2dbc5e9a2fa60abced4594424c..381e0565c509aab4c3c36a70b399b71f8ae9a4f1 100644 --- a/ability/FormExtAbility/README_zh.md +++ b/ability/FormExtAbility/README_zh.md @@ -27,4 +27,4 @@ Ability:Ability是应用所具备能力的抽象,也是应用程序的重要 2.本示例为Stage模型,从API version 9开始支持。 -3.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/ability/FormExtAbility/entry/src/main/ets/Application/AbilityStage.ts b/ability/FormExtAbility/entry/src/main/ets/Application/AbilityStage.ts index 9c26d446b69e57d9f28afbfbf940a3183e75ffa7..7ce4d8d98fb0fd7d380fb30ef0801fe47466a2c3 100644 --- a/ability/FormExtAbility/entry/src/main/ets/Application/AbilityStage.ts +++ b/ability/FormExtAbility/entry/src/main/ets/Application/AbilityStage.ts @@ -17,7 +17,7 @@ import AbilityStage from "@ohos.application.AbilityStage" import Logger from '../model/Logger'; export default class MyAbilityStage extends AbilityStage { - onCreate() { - Logger.log("[Demo] MyAbilityStage onCreate") - } + onCreate() { + Logger.log("[Demo] MyAbilityStage onCreate") + } } \ No newline at end of file diff --git a/ability/FormExtAbility/entry/src/main/ets/FormAbility/FormAbility.ts b/ability/FormExtAbility/entry/src/main/ets/FormAbility/FormAbility.ts index 5711dd1290460cd8a51e6936dc119f072b76d159..6432ecec3b80641231a73b5faaca49998e482866 100644 --- a/ability/FormExtAbility/entry/src/main/ets/FormAbility/FormAbility.ts +++ b/ability/FormExtAbility/entry/src/main/ets/FormAbility/FormAbility.ts @@ -26,162 +26,162 @@ const FORM_PARAM_NAME_KEY = "ohos.extra.param.key.form_name"; const FORM_PARAM_TEMPORARY_KEY = "ohos.extra.param.key.form_temporary"; function getTemperature(formId: string, count: number) { - const DECIMAL: number = 10; - const parsedFormId: number = parseInt(formId, DECIMAL); - const BASE_TEMP_MOD: number = 20; - const baseTemperature: number = parsedFormId % BASE_TEMP_MOD; - const RANGE_TEMP_MOD: number = 20; - return baseTemperature + Math.abs(count % RANGE_TEMP_MOD - RANGE_TEMP_MOD / 2); + const DECIMAL: number = 10; + const parsedFormId: number = parseInt(formId, DECIMAL); + const BASE_TEMP_MOD: number = 20; + const baseTemperature: number = parsedFormId % BASE_TEMP_MOD; + const RANGE_TEMP_MOD: number = 20; + return baseTemperature + Math.abs(count % RANGE_TEMP_MOD - RANGE_TEMP_MOD / 2); } function padZero(num: number) { - // trans num to string and pad 0 - if (num < 10) { - return `0${num}`; - } else { - return num.toString(); - } + // trans num to string and pad 0 + if (num < 10) { + return `0${num}`; + } else { + return num.toString(); + } } function getTime() { - const date = new Date(); - const hours = padZero(date.getHours()); - const minutes = padZero(date.getMinutes()); - const seconds = padZero(date.getSeconds()); - return `${hours}:${minutes}:${seconds}` + const date = new Date(); + const hours = padZero(date.getHours()); + const minutes = padZero(date.getMinutes()); + const seconds = padZero(date.getSeconds()); + return `${hours}:${minutes}:${seconds}` } async function storeFormInfo(formId: string, formName: string, tempFlag: boolean) { - let formInfo = { - "formName": formName, - "tempFlag": tempFlag, - "updateCount": 0 - }; - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // put form info - await storage.put(formId, JSON.stringify(formInfo)); - Logger.log(`storeFormInfo, put form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to storeFormInfo, err: ${JSON.stringify(err)}`); - } + let formInfo = { + "formName": formName, + "tempFlag": tempFlag, + "updateCount": 0 + }; + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // put form info + await storage.put(formId, JSON.stringify(formInfo)); + Logger.log(`storeFormInfo, put form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to storeFormInfo, err: ${JSON.stringify(err)}`); + } } async function updateTempFormInfo(formId: string) { - let formInfoDefault = { - "formName": "", - "tempFlag": false, - "updateCount": 0 - }; - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // get form info - const data = await storage.get(formId, JSON.stringify(formInfoDefault)); - Logger.log(`updateTempFormInfo, get form info successfully, formId: ${formId}`); - const formInfo = JSON.parse(data.toString()); - if (!formInfo.tempFlag) { - Logger.log(`updateTempFormInfo, formId: ${formId} is not temporary.`); - return; - } - - formInfo.tempFlag = false; - // update form info - await storage.put(formId, JSON.stringify(formInfo)); - Logger.log(`updateTempFormInfo, update form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to updateTempFormInfo, err: ${JSON.stringify(err)}`); + let formInfoDefault = { + "formName": "", + "tempFlag": false, + "updateCount": 0 + }; + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // get form info + const data = await storage.get(formId, JSON.stringify(formInfoDefault)); + Logger.log(`updateTempFormInfo, get form info successfully, formId: ${formId}`); + const formInfo = JSON.parse(data.toString()); + if (!formInfo.tempFlag) { + Logger.log(`updateTempFormInfo, formId: ${formId} is not temporary.`); + return; } + + formInfo.tempFlag = false; + // update form info + await storage.put(formId, JSON.stringify(formInfo)); + Logger.log(`updateTempFormInfo, update form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to updateTempFormInfo, err: ${JSON.stringify(err)}`); + } } async function updateForm(formId: string) { - let formInfoDefault = { - "formName": "", - "tempFlag": false, - "updateCount": 0 + let formInfoDefault = { + "formName": "", + "tempFlag": false, + "updateCount": 0 + }; + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // get form info + const data = await storage.get(formId, JSON.stringify(formInfoDefault)); + Logger.log(`updateForm, get form info successfully, formId: ${formId}`); + const formInfo = JSON.parse(data.toString()); + formInfo.updateCount = formInfo.updateCount + 1; + + let obj = { + "temperature": getTemperature(formId, formInfo.updateCount).toString(), + "time": getTime() }; - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // get form info - const data = await storage.get(formId, JSON.stringify(formInfoDefault)); - Logger.log(`updateForm, get form info successfully, formId: ${formId}`); - const formInfo = JSON.parse(data.toString()); - formInfo.updateCount = formInfo.updateCount + 1; - - let obj = { - "temperature": getTemperature(formId, formInfo.updateCount).toString(), - "time": getTime() - }; - let formData = formBindingData.createFormBindingData(obj); - formProvider.updateForm(formId, formData).catch((err) => { - Logger.error(`updateForm, err: ${JSON.stringify(err)}`); - }); - - // update form info - await storage.put(formId, JSON.stringify(formInfo)); - Logger.log(`updateForm, update form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to updateForm, err: ${JSON.stringify(err)}`); - } + let formData = formBindingData.createFormBindingData(obj); + formProvider.updateForm(formId, formData).catch((err) => { + Logger.error(`updateForm, err: ${JSON.stringify(err)}`); + }); + + // update form info + await storage.put(formId, JSON.stringify(formInfo)); + Logger.log(`updateForm, update form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to updateForm, err: ${JSON.stringify(err)}`); + } } async function deleteFormInfo(formId: string) { - try { - const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); - // del form info - await storage.delete(formId); - Logger.log(`deleteFormInfo, del form info successfully, formId: ${formId}`); - await storage.flush(); - } catch (err) { - Logger.error(`failed to deleteFormInfo, err: ${JSON.stringify(err)}`); - } + try { + const storage = await dataStorage.getStorage(DATA_STORAGE_PATH); + // del form info + await storage.delete(formId); + Logger.log(`deleteFormInfo, del form info successfully, formId: ${formId}`); + await storage.flush(); + } catch (err) { + Logger.error(`failed to deleteFormInfo, err: ${JSON.stringify(err)}`); + } } export default class FormAbility extends FormExtension { - onCreate(want) { - Logger.log(`FormAbility onCreate, want: ${JSON.stringify(want)}`); - - // get form info - let formId = want.parameters[FORM_PARAM_IDENTITY_KEY]; - let formName = want.parameters[FORM_PARAM_NAME_KEY]; - let tempFlag = want.parameters[FORM_PARAM_TEMPORARY_KEY]; - storeFormInfo(formId, formName, tempFlag); - - let obj = { - "temperature": getTemperature(formId, 0).toString(), - "time": getTime() - }; - let formData = formBindingData.createFormBindingData(obj); - return formData; - } - - onCastToNormal(formId) { - Logger.log(`FormAbility onCastToNormal, formId: ${formId}`); - updateTempFormInfo(formId); - } - - onUpdate(formId) { - Logger.log(`FormAbility onUpdate, formId: ${formId}`); - updateForm(formId); - } - - onVisibilityChange(newStatus) { - Logger.log(`FormAbility onVisibilityChange`); - } - - onEvent(formId, message) { - Logger.log(`FormAbility onEvent, formId = ${formId}, message: ${JSON.stringify(message)}`); - } - - onDestroy(formId) { - Logger.log(`FormAbility onDestroy, formId = ${formId}`); - deleteFormInfo(formId); - } - - onAcquireFormState(want) { - Logger.log(`FormAbility onAcquireFormState`); - return formInfo.FormState.READY; - } + onCreate(want) { + Logger.log(`FormAbility onCreate, want: ${JSON.stringify(want)}`); + + // get form info + let formId = want.parameters[FORM_PARAM_IDENTITY_KEY]; + let formName = want.parameters[FORM_PARAM_NAME_KEY]; + let tempFlag = want.parameters[FORM_PARAM_TEMPORARY_KEY]; + storeFormInfo(formId, formName, tempFlag); + + let obj = { + "temperature": getTemperature(formId, 0).toString(), + "time": getTime() + }; + let formData = formBindingData.createFormBindingData(obj); + return formData; + } + + onCastToNormal(formId) { + Logger.log(`FormAbility onCastToNormal, formId: ${formId}`); + updateTempFormInfo(formId); + } + + onUpdate(formId) { + Logger.log(`FormAbility onUpdate, formId: ${formId}`); + updateForm(formId); + } + + onVisibilityChange(newStatus) { + Logger.log(`FormAbility onVisibilityChange`); + } + + onEvent(formId, message) { + Logger.log(`FormAbility onEvent, formId = ${formId}, message: ${JSON.stringify(message)}`); + } + + onDestroy(formId) { + Logger.log(`FormAbility onDestroy, formId = ${formId}`); + deleteFormInfo(formId); + } + + onAcquireFormState(want) { + Logger.log(`FormAbility onAcquireFormState`); + return formInfo.FormState.READY; + } }; \ No newline at end of file diff --git a/ability/FormExtAbility/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/FormExtAbility/entry/src/main/ets/MainAbility/MainAbility.ts index 22a007f3a15ddc71c31f82891b28824ade9c21c1..88b9239b26b31710f7eee8205a688bf923d50154 100644 --- a/ability/FormExtAbility/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/FormExtAbility/entry/src/main/ets/MainAbility/MainAbility.ts @@ -17,34 +17,34 @@ import Ability from '@ohos.application.Ability' import Logger from '../model/Logger'; export default class MainAbility extends Ability { - onCreate(want, launchParam) { - Logger.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - Logger.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - Logger.log("[Demo] MainAbility onWindowStageCreate") - - windowStage.setUIContent(this.context, "pages/index", null) - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - Logger.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - Logger.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - Logger.log("[Demo] MainAbility onBackground") - } + onCreate(want, launchParam) { + Logger.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + Logger.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + Logger.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + Logger.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + Logger.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + Logger.log("[Demo] MainAbility onBackground") + } }; diff --git a/ability/FormExtAbility/entry/src/main/ets/model/Logger.ts b/ability/FormExtAbility/entry/src/main/ets/model/Logger.ts index 11447d0b72d0815dc2afa093dc35b6b06c8001e2..25d2b130fa0046539521d01a6be7cdd6a9807c59 100644 --- a/ability/FormExtAbility/entry/src/main/ets/model/Logger.ts +++ b/ability/FormExtAbility/entry/src/main/ets/model/Logger.ts @@ -14,22 +14,28 @@ */ class Logger { - constructor(private prefix: string) {} - public log(...args: any[]) { - console.log(`[${this.prefix}]: ${args.join('')}`) - } - public info(...args: any[]) { - console.info(`[${this.prefix}]: ${args.join('')}`) - } - public debug(...args: any[]) { - console.debug(`[${this.prefix}]: ${args.join('')}`) - } - public warn(...args: any[]) { - console.warn(`[${this.prefix}]: ${args.join('')}`) - } - public error(...args: any[]) { - console.error(`[${this.prefix}]: ${args.join('')}`) - } + constructor(private prefix: string) { + } + + public log(...args: any[]) { + console.log(`[${this.prefix}]: ${args.join('')}`) + } + + public info(...args: any[]) { + console.info(`[${this.prefix}]: ${args.join('')}`) + } + + public debug(...args: any[]) { + console.debug(`[${this.prefix}]: ${args.join('')}`) + } + + public warn(...args: any[]) { + console.warn(`[${this.prefix}]: ${args.join('')}`) + } + + public error(...args: any[]) { + console.error(`[${this.prefix}]: ${args.join('')}`) + } } export default new Logger('eTSFormExtAbility') diff --git a/ability/FormExtAbility/entry/src/main/js/widget/pages/index/index.hml b/ability/FormExtAbility/entry/src/main/js/widget/pages/index/index.hml index 05b5b96a9def87cd21de370fd7f90140434b757d..23930fa5405b9bd5e42e1b3f36a7fa893d2bd6af 100644 --- a/ability/FormExtAbility/entry/src/main/js/widget/pages/index/index.hml +++ b/ability/FormExtAbility/entry/src/main/js/widget/pages/index/index.hml @@ -1,11 +1,11 @@
- -
- -
-
- {{ $t('strings.temperature') }}{{temperature}} ℃ - {{ $t('strings.time') }} {{time}} -
-
+ +
+ +
+
+ {{ $t('strings.temperature') }}{{ temperature }} ℃ + {{ $t('strings.time') }} {{ time }} +
+
\ No newline at end of file diff --git a/ability/FormExtAbility/package.json b/ability/FormExtAbility/package.json index 8dba951ce675ce77082730a5e10075707c4befd9..3b6b3ead343786ea16571ab11a6ae9ed4e40712d 100644 --- a/ability/FormExtAbility/package.json +++ b/ability/FormExtAbility/package.json @@ -8,8 +8,8 @@ }, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/ability/FormLauncher/.gitignore b/ability/FormLauncher/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/ability/FormLauncher/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/ability/FormLauncher/README_zh.md b/ability/FormLauncher/README_zh.md index 76fa7014b1dae233ed4f6a5f63f7eb679426c278..5982e4a4be6247f591061a39cc660fb94bbb1659 100644 --- a/ability/FormLauncher/README_zh.md +++ b/ability/FormLauncher/README_zh.md @@ -33,7 +33,7 @@ 1.本示例仅支持标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 3.本示例需要使用@ohos.application.formHost系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 diff --git a/ability/FormLauncher/entry/package.json b/ability/FormLauncher/entry/package.json index f04a697de2b2bcccaab60f6d93d5eb08f853d981..4857e2867c1d37e162d54b1a9eaaa121797d969b 100644 --- a/ability/FormLauncher/entry/package.json +++ b/ability/FormLauncher/entry/package.json @@ -1,11 +1,11 @@ { - "devDependencies":{}, - "name":"entry", - "ohos":{ - "org":"huawei", - "directoryLevel":"module", - "buildTool":"hvigor" + "devDependencies": {}, + "name": "entry", + "ohos": { + "org": "huawei", + "directoryLevel": "module", + "buildTool": "hvigor" }, - "version":"1.0.0", - "dependencies":{} + "version": "1.0.0", + "dependencies": {} } \ No newline at end of file diff --git a/ability/FormLauncher/entry/src/main/ets/model/Logger.ts b/ability/FormLauncher/entry/src/main/ets/model/Logger.ts index f50d883d958a661ee63b7a47c5bbc256341120b7..e2aeb095de5a6c324b7adb87cd5b0a68cd389b2d 100644 --- a/ability/FormLauncher/entry/src/main/ets/model/Logger.ts +++ b/ability/FormLauncher/entry/src/main/ets/model/Logger.ts @@ -14,22 +14,28 @@ */ class Logger { - constructor(private prefix: string) {} - public log(...args: any[]) { - console.log(`[${this.prefix}]: ${args.join('')}`) - } - public info(...args: any[]) { - console.info(`[${this.prefix}]: ${args.join('')}`) - } - public debug(...args: any[]) { - console.debug(`[${this.prefix}]: ${args.join('')}`) - } - public warn(...args: any[]) { - console.warn(`[${this.prefix}]: ${args.join('')}`) - } - public error(...args: any[]) { - console.error(`[${this.prefix}]: ${args.join('')}`) - } + constructor(private prefix: string) { + } + + public log(...args: any[]) { + console.log(`[${this.prefix}]: ${args.join('')}`) + } + + public info(...args: any[]) { + console.info(`[${this.prefix}]: ${args.join('')}`) + } + + public debug(...args: any[]) { + console.debug(`[${this.prefix}]: ${args.join('')}`) + } + + public warn(...args: any[]) { + console.warn(`[${this.prefix}]: ${args.join('')}`) + } + + public error(...args: any[]) { + console.error(`[${this.prefix}]: ${args.join('')}`) + } } export default new Logger('eTSFormLauncher') diff --git a/ability/FormLauncher/package.json b/ability/FormLauncher/package.json index 0b1dcaa996db64dd889f27f3c9bb81c567d1305b..200f197090cdb41d84b9b3d1379a0b148d346819 100644 --- a/ability/FormLauncher/package.json +++ b/ability/FormLauncher/package.json @@ -1,15 +1,15 @@ { - "devDependencies":{}, - "name":"mylauncher", - "ohos":{ - "org":"huawei", - "directoryLevel":"project", - "buildTool":"hvigor" + "devDependencies": {}, + "name": "mylauncher", + "ohos": { + "org": "huawei", + "directoryLevel": "project", + "buildTool": "hvigor" }, - "version":"1.0.0", - "dependencies":{ - "@ohos/hypium":"1.0.1", - "@ohos/hvigor-ohos-plugin":"1.1.6", - "@ohos/hvigor":"1.1.6" + "version": "1.0.0", + "dependencies": { + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/ability/JsDistributedMusicPlayer/.gitignore b/ability/JsDistributedMusicPlayer/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/ability/JsDistributedMusicPlayer/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/ability/JsDistributedMusicPlayer/README_zh.md b/ability/JsDistributedMusicPlayer/README_zh.md index 993b0eaa1e406f972500bdb2aa02705f52f1ef0b..85edb95559c39ad095ada42888dcd9c5e9be6e0f 100644 --- a/ability/JsDistributedMusicPlayer/README_zh.md +++ b/ability/JsDistributedMusicPlayer/README_zh.md @@ -26,7 +26,7 @@ 1.本示例仅支持标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 3.如果安装本示例报错为error:install sign info inconsistent,则有可能本应用被设置为系统预置应用,已安装在系统中,此时需使用命令进行替换安装,并在替换安装后对设备进行重启操作,具体命令如下: diff --git a/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/app.js b/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/app.js index e3a0891c0350ac6dec03b34963b6e570653355f2..e2e723dcb860a851fb8d1aa1e1a3e1dfa735110c 100644 --- a/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/app.js +++ b/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/model/KvStoreModel.js b/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/model/KvStoreModel.js index 441b020d78135fe2637165225bfc8dc65f1d0dc9..3b31b7b8e34f26756bc96b66a97c40dfbd54107c 100644 --- a/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/model/KvStoreModel.js +++ b/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/model/KvStoreModel.js @@ -18,97 +18,97 @@ import distributedData from '@ohos.data.distributedData'; const STORE_ID = 'musicplayer_kvstore'; export default class KvStoreModel { - kvManager; - kvStore; + kvManager; + kvStore; - constructor() { - } + constructor() { + } - createKvStore(callback) { - if (typeof (this.kvStore) === 'undefined') { - var config = { - bundleName: 'ohos.samples.distributedmusicplayer', - userInfo: { - userId: '0', - userType: 0 - } - }; - let self = this; - console.info('MusicPlayer[KvStoreModel] createKVManager begin'); - distributedData.createKVManager(config).then((manager) => { - console.info('MusicPlayer[KvStoreModel] createKVManager success, kvManager=' + JSON.stringify(manager)); - self.kvManager = manager; - var options = { - createIfMissing: true, - encrypt: false, - backup: false, - autoSync: true, - kvStoreType: 1, - schema: '', - securityLevel: 3, - }; - console.info('MusicPlayer[KvStoreModel] kvManager.getKVStore begin'); - self.kvManager.getKVStore(STORE_ID, options).then((store) => { - console.info('MusicPlayer[KvStoreModel] getKVStore success, kvStore=' + store); - self.kvStore = store; - callback(); - }); - console.info('MusicPlayer[KvStoreModel] kvManager.getKVStore end'); - }); - console.info('MusicPlayer[KvStoreModel] createKVManager end'); - } else { - callback(); + createKvStore(callback) { + if (typeof (this.kvStore) === 'undefined') { + var config = { + bundleName: 'ohos.samples.distributedmusicplayer', + userInfo: { + userId: '0', + userType: 0 } - } - - broadcastMessage(msg) { - console.info('MusicPlayer[KvStoreModel] broadcastMessage ' + msg); - var num = Math.random(); - let self = this; - this.createKvStore(() => { - self.put(msg, num); + }; + let self = this; + console.info('MusicPlayer[KvStoreModel] createKVManager begin'); + distributedData.createKVManager(config).then((manager) => { + console.info('MusicPlayer[KvStoreModel] createKVManager success, kvManager=' + JSON.stringify(manager)); + self.kvManager = manager; + var options = { + createIfMissing: true, + encrypt: false, + backup: false, + autoSync: true, + kvStoreType: 1, + schema: '', + securityLevel: 3, + }; + console.info('MusicPlayer[KvStoreModel] kvManager.getKVStore begin'); + self.kvManager.getKVStore(STORE_ID, options).then((store) => { + console.info('MusicPlayer[KvStoreModel] getKVStore success, kvStore=' + store); + self.kvStore = store; + callback(); }); + console.info('MusicPlayer[KvStoreModel] kvManager.getKVStore end'); + }); + console.info('MusicPlayer[KvStoreModel] createKVManager end'); + } else { + callback(); } + } - put(key, value) { - console.info('MusicPlayer[KvStoreModel] kvStore.put ' + key + '=' + value); - this.kvStore.put(key, value).then((data) => { - this.kvStore.get(key).then((data) => { - console.info('MusicPlayer[KvStoreModel] kvStore.get ' + key + '=' + JSON.stringify(data)); - }); - console.info('MusicPlayer[KvStoreModel] kvStore.put ' + key + ' finished, data=' + JSON.stringify(data)); - }).catch((err) => { - console.error('MusicPlayer[KvStoreModel] kvStore.put ' + key + ' failed, ' + JSON.stringify(err)); - }); - } + broadcastMessage(msg) { + console.info('MusicPlayer[KvStoreModel] broadcastMessage ' + msg); + var num = Math.random(); + let self = this; + this.createKvStore(() => { + self.put(msg, num); + }); + } - setOnMessageReceivedListener(msg, callback) { - console.info('MusicPlayer[KvStoreModel] setOnMessageReceivedListener ' + msg); - let self = this; - this.createKvStore(() => { - console.info('MusicPlayer[KvStoreModel] kvStore.on(dataChange) begin'); - self.kvStore.on('dataChange', 1, (data) => { - console.info('MusicPlayer[KvStoreModel] dataChange, ' + JSON.stringify(data)); - console.info('MusicPlayer[KvStoreModel] dataChange, insert ' + data.insertEntries.length + ' udpate ' - + data.updateEntries.length); - for (var i = 0; i < data.insertEntries.length; i++) { - if (data.insertEntries[i].key === msg) { - console.info('MusicPlayer[KvStoreModel] insertEntries receive ' + msg + '=' - + JSON.stringify(data.insertEntries[i].value)); - callback(); - return; - } - } - for (i = 0; i < data.updateEntries.length; i++) { - if (data.updateEntries[i].key === msg) { - console.info('MusicPlayer[KvStoreModel] updateEntries receive ' + msg + '=' - + JSON.stringify(data.updateEntries[i].value)); - callback(); - return; - } - } - }); - console.info('MusicPlayer[KvStoreModel] kvStore.on(dataChange) end'); - }); - } + put(key, value) { + console.info('MusicPlayer[KvStoreModel] kvStore.put ' + key + '=' + value); + this.kvStore.put(key, value).then((data) => { + this.kvStore.get(key).then((data) => { + console.info('MusicPlayer[KvStoreModel] kvStore.get ' + key + '=' + JSON.stringify(data)); + }); + console.info('MusicPlayer[KvStoreModel] kvStore.put ' + key + ' finished, data=' + JSON.stringify(data)); + }).catch((err) => { + console.error('MusicPlayer[KvStoreModel] kvStore.put ' + key + ' failed, ' + JSON.stringify(err)); + }); + } + + setOnMessageReceivedListener(msg, callback) { + console.info('MusicPlayer[KvStoreModel] setOnMessageReceivedListener ' + msg); + let self = this; + this.createKvStore(() => { + console.info('MusicPlayer[KvStoreModel] kvStore.on(dataChange) begin'); + self.kvStore.on('dataChange', 1, (data) => { + console.info('MusicPlayer[KvStoreModel] dataChange, ' + JSON.stringify(data)); + console.info('MusicPlayer[KvStoreModel] dataChange, insert ' + data.insertEntries.length + ' udpate ' + + data.updateEntries.length); + for (var i = 0; i < data.insertEntries.length; i++) { + if (data.insertEntries[i].key === msg) { + console.info('MusicPlayer[KvStoreModel] insertEntries receive ' + msg + '=' + + JSON.stringify(data.insertEntries[i].value)); + callback(); + return; + } + } + for (i = 0; i < data.updateEntries.length; i++) { + if (data.updateEntries[i].key === msg) { + console.info('MusicPlayer[KvStoreModel] updateEntries receive ' + msg + '=' + + JSON.stringify(data.updateEntries[i].value)); + callback(); + return; + } + } + }); + console.info('MusicPlayer[KvStoreModel] kvStore.on(dataChange) end'); + }); + } } \ No newline at end of file diff --git a/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/model/RemoteDeviceModel.js b/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/model/RemoteDeviceModel.js index fd11945c431e2fac0dd3ef39086f4e10446bdb17..5cf9652124d3d012ef49bfdcfb5e733288a642b1 100644 --- a/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/model/RemoteDeviceModel.js +++ b/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/model/RemoteDeviceModel.js @@ -18,167 +18,167 @@ import deviceManager from '@ohos.distributedHardware.deviceManager'; var SUBSCRIBE_ID = 100; export default class RemoteDeviceModel { - deviceList = []; - discoverList = []; - callback; - authCallback = null; - #deviceManager; + deviceList = []; + discoverList = []; + callback; + authCallback = null; + #deviceManager; - constructor() { - } + constructor() { + } - registerDeviceListCallback(callback) { - if (typeof (this.#deviceManager) === 'undefined') { - console.log('MusicPlayer[RemoteDeviceModel] deviceManager.createDeviceManager begin'); - deviceManager.createDeviceManager('com.ohos.distributedmusicplayer', (error, value) => { - if (error) { - console.error('createDeviceManager failed.'); - return; - } - this.#deviceManager = value; - this.registerDeviceListCallback_(callback); - console.log('MusicPlayer[RemoteDeviceModel] createDeviceManager callback returned, error=' + error + ' value=' + value); - }); - console.log('MusicPlayer[RemoteDeviceModel] deviceManager.createDeviceManager end'); - } else { - this.registerDeviceListCallback_(callback); + registerDeviceListCallback(callback) { + if (typeof (this.#deviceManager) === 'undefined') { + console.log('MusicPlayer[RemoteDeviceModel] deviceManager.createDeviceManager begin'); + deviceManager.createDeviceManager('com.ohos.distributedmusicplayer', (error, value) => { + if (error) { + console.error('createDeviceManager failed.'); + return; } + this.#deviceManager = value; + this.registerDeviceListCallback_(callback); + console.log('MusicPlayer[RemoteDeviceModel] createDeviceManager callback returned, error=' + error + ' value=' + value); + }); + console.log('MusicPlayer[RemoteDeviceModel] deviceManager.createDeviceManager end'); + } else { + this.registerDeviceListCallback_(callback); } + } - registerDeviceListCallback_(callback) { - console.info('MusicPlayer[RemoteDeviceModel] registerDeviceListCallback'); - this.callback = callback; - if (this.#deviceManager == undefined) { - console.error('MusicPlayer[RemoteDeviceModel] deviceManager has not initialized'); - this.callback(); - return; - } + registerDeviceListCallback_(callback) { + console.info('MusicPlayer[RemoteDeviceModel] registerDeviceListCallback'); + this.callback = callback; + if (this.#deviceManager == undefined) { + console.error('MusicPlayer[RemoteDeviceModel] deviceManager has not initialized'); + this.callback(); + return; + } - console.info('MusicPlayer[RemoteDeviceModel] getTrustedDeviceListSync begin'); - var list = this.#deviceManager.getTrustedDeviceListSync(); - console.info('MusicPlayer[RemoteDeviceModel] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list)); - if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') { - this.deviceList = list; - } - this.callback(); - console.info('MusicPlayer[RemoteDeviceModel] callback finished'); - - this.#deviceManager.on('deviceStateChange', (data) => { - console.info('MusicPlayer[RemoteDeviceModel] deviceStateChange data=' + JSON.stringify(data)); - switch (data.action) { - case 0: - this.deviceList[this.deviceList.length] = data.device; - console.info('MusicPlayer[RemoteDeviceModel] online, updated device list=' + JSON.stringify(this.deviceList)); - this.callback(); - if (this.authCallback != null) { - this.authCallback(); - this.authCallback = null; - } - break; - case 2: - if (this.deviceList.length > 0) { - for (var i = 0; i < this.deviceList.length; i++) { - if (this.deviceList[i].deviceId === data.device.deviceId) { - this.deviceList[i] = data.device; - break; - } - } - } - console.info('MusicPlayer[RemoteDeviceModel] change, updated device list=' + JSON.stringify(this.deviceList)); - this.callback(); - break; - case 1: - if (this.deviceList.length > 0) { - var list = []; - for (var i = 0; i < this.deviceList.length; i++) { - if (this.deviceList[i].deviceId != data.device.deviceId) { - list[i] = data.device; - } - } - this.deviceList = list; - } - console.info('MusicPlayer[RemoteDeviceModel] offline, updated device list=' + JSON.stringify(data.device)); - this.callback(); + console.info('MusicPlayer[RemoteDeviceModel] getTrustedDeviceListSync begin'); + var list = this.#deviceManager.getTrustedDeviceListSync(); + console.info('MusicPlayer[RemoteDeviceModel] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list)); + if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') { + this.deviceList = list; + } + this.callback(); + console.info('MusicPlayer[RemoteDeviceModel] callback finished'); + + this.#deviceManager.on('deviceStateChange', (data) => { + console.info('MusicPlayer[RemoteDeviceModel] deviceStateChange data=' + JSON.stringify(data)); + switch (data.action) { + case 0: + this.deviceList[this.deviceList.length] = data.device; + console.info('MusicPlayer[RemoteDeviceModel] online, updated device list=' + JSON.stringify(this.deviceList)); + this.callback(); + if (this.authCallback != null) { + this.authCallback(); + this.authCallback = null; + } + break; + case 2: + if (this.deviceList.length > 0) { + for (var i = 0; i < this.deviceList.length; i++) { + if (this.deviceList[i].deviceId === data.device.deviceId) { + this.deviceList[i] = data.device; break; - default: - break; + } } - }); - this.#deviceManager.on('deviceFound', (data) => { - console.info('MusicPlayer[RemoteDeviceModel] deviceFound data=' + JSON.stringify(data)); - console.info('MusicPlayer[RemoteDeviceModel] deviceFound this.deviceList=' + this.deviceList); - console.info('MusicPlayer[RemoteDeviceModel] deviceFound this.deviceList.length=' + this.deviceList.length); - for (var i = 0; i < this.discoverList.length; i++) { - if (this.discoverList[i].deviceId === data.device.deviceId) { - console.info('MusicPlayer[RemoteDeviceModel] device founded, ignored'); - return; - } + } + console.info('MusicPlayer[RemoteDeviceModel] change, updated device list=' + JSON.stringify(this.deviceList)); + this.callback(); + break; + case 1: + if (this.deviceList.length > 0) { + var list = []; + for (var i = 0; i < this.deviceList.length; i++) { + if (this.deviceList[i].deviceId != data.device.deviceId) { + list[i] = data.device; + } } - this.discoverList[this.discoverList.length] = data.device; - this.callback(); - }); - this.#deviceManager.on('discoverFail', (data) => { - console.info('MusicPlayer[RemoteDeviceModel] discoverFail data=' + JSON.stringify(data)); - }); - this.#deviceManager.on('serviceDie', () => { - console.error('MusicPlayer[RemoteDeviceModel] serviceDie'); - }); + this.deviceList = list; + } + console.info('MusicPlayer[RemoteDeviceModel] offline, updated device list=' + JSON.stringify(data.device)); + this.callback(); + break; + default: + break; + } + }); + this.#deviceManager.on('deviceFound', (data) => { + console.info('MusicPlayer[RemoteDeviceModel] deviceFound data=' + JSON.stringify(data)); + console.info('MusicPlayer[RemoteDeviceModel] deviceFound this.deviceList=' + this.deviceList); + console.info('MusicPlayer[RemoteDeviceModel] deviceFound this.deviceList.length=' + this.deviceList.length); + for (var i = 0; i < this.discoverList.length; i++) { + if (this.discoverList[i].deviceId === data.device.deviceId) { + console.info('MusicPlayer[RemoteDeviceModel] device founded, ignored'); + return; + } + } + this.discoverList[this.discoverList.length] = data.device; + this.callback(); + }); + this.#deviceManager.on('discoverFail', (data) => { + console.info('MusicPlayer[RemoteDeviceModel] discoverFail data=' + JSON.stringify(data)); + }); + this.#deviceManager.on('serviceDie', () => { + console.error('MusicPlayer[RemoteDeviceModel] serviceDie'); + }); - SUBSCRIBE_ID = Math.floor(65536 * Math.random()); - var info = { - subscribeId: SUBSCRIBE_ID, - mode: 0xAA, - medium: 2, - freq: 2, - isSameAccount: false, - isWakeRemote: true, - capability: 0 - }; - console.info('MusicPlayer[RemoteDeviceModel] startDeviceDiscovery ' + SUBSCRIBE_ID); - this.#deviceManager.startDeviceDiscovery(info); - } + SUBSCRIBE_ID = Math.floor(65536 * Math.random()); + var info = { + subscribeId: SUBSCRIBE_ID, + mode: 0xAA, + medium: 2, + freq: 2, + isSameAccount: false, + isWakeRemote: true, + capability: 0 + }; + console.info('MusicPlayer[RemoteDeviceModel] startDeviceDiscovery ' + SUBSCRIBE_ID); + this.#deviceManager.startDeviceDiscovery(info); + } - authDevice(deviceId, callback) { - console.info('MusicPlayer[RemoteDeviceModel] authDevice ' + deviceId); - for (var i = 0; i < this.discoverList.length; i++) { - if (this.discoverList[i].deviceId === deviceId) { - console.info('MusicPlayer[RemoteDeviceModel] device founded, ignored'); - let extraInfo = { - "targetPkgName": 'ohos.samples.distributedmusicplayer', - "appName": 'Music', - "appDescription": 'Music player application', - "business": '0' - }; - let authParam = { - "authType": 1, - "appIcon": '', - "appThumbnail": '', - "extraInfo": extraInfo - }; - console.info('MusicPlayer[RemoteDeviceModel] authenticateDevice ' + JSON.stringify(this.discoverList[i])); - this.#deviceManager.authenticateDevice(this.discoverList[i], authParam, (err, data) => { - if (err) { - console.info('MusicPlayer[RemoteDeviceModel] authenticateDevice failed, err=' + JSON.stringify(err)); - this.authCallback = null; - } else { - console.info('MusicPlayer[RemoteDeviceModel] authenticateDevice succeed, data=' + JSON.stringify(data)); - this.authCallback = callback; - } - }); - } - } + authDevice(deviceId, callback) { + console.info('MusicPlayer[RemoteDeviceModel] authDevice ' + deviceId); + for (var i = 0; i < this.discoverList.length; i++) { + if (this.discoverList[i].deviceId === deviceId) { + console.info('MusicPlayer[RemoteDeviceModel] device founded, ignored'); + let extraInfo = { + "targetPkgName": 'ohos.samples.distributedmusicplayer', + "appName": 'Music', + "appDescription": 'Music player application', + "business": '0' + }; + let authParam = { + "authType": 1, + "appIcon": '', + "appThumbnail": '', + "extraInfo": extraInfo + }; + console.info('MusicPlayer[RemoteDeviceModel] authenticateDevice ' + JSON.stringify(this.discoverList[i])); + this.#deviceManager.authenticateDevice(this.discoverList[i], authParam, (err, data) => { + if (err) { + console.info('MusicPlayer[RemoteDeviceModel] authenticateDevice failed, err=' + JSON.stringify(err)); + this.authCallback = null; + } else { + console.info('MusicPlayer[RemoteDeviceModel] authenticateDevice succeed, data=' + JSON.stringify(data)); + this.authCallback = callback; + } + }); + } } + } - unregisterDeviceListCallback() { - console.info('MusicPlayer[RemoteDeviceModel] stopDeviceDiscovery ' + SUBSCRIBE_ID); - if(typeof (this.#deviceManager) === 'undefined'){ - return - } - this.#deviceManager.stopDeviceDiscovery(SUBSCRIBE_ID); - this.#deviceManager.off('deviceStateChange'); - this.#deviceManager.off('deviceFound'); - this.#deviceManager.off('discoverFail'); - this.#deviceManager.off('serviceDie'); - this.deviceList = []; + unregisterDeviceListCallback() { + console.info('MusicPlayer[RemoteDeviceModel] stopDeviceDiscovery ' + SUBSCRIBE_ID); + if (typeof (this.#deviceManager) === 'undefined') { + return } + this.#deviceManager.stopDeviceDiscovery(SUBSCRIBE_ID); + this.#deviceManager.off('deviceStateChange'); + this.#deviceManager.off('deviceFound'); + this.#deviceManager.off('discoverFail'); + this.#deviceManager.off('serviceDie'); + this.deviceList = []; + } } \ No newline at end of file diff --git a/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/pages/index/index.hml b/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/pages/index/index.hml index 14de1e58b39391f886132c4b942ced154d84b540..2bbf617e3674e120c15036d4b53feffe85d5b52c 100644 --- a/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/pages/index/index.hml @@ -14,48 +14,48 @@ */-->
-
- - {{ title }} +
+ + {{ title }} + +
+ + +
+
+
+ {{ currentTimeText }} + + {{ totalTimeText }} -
- - -
-
-
- {{ currentTimeText }} - - {{ totalTimeText }} - -
- -
-
- - - - -
+
+ +
+
+ + + + +
+
+ +
+ {{ $t('strings.select') }} + + +
+ + +
+
+
+
+ +
- -
- {{ $t('strings.select') }} - - -
- - -
-
-
-
- -
-
-
+
diff --git a/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/pages/index/index.js b/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/pages/index/index.js index 9a253272a82fac76a5c75fbda593b31ca88d1108..118420a7af81c05488e0818e1b607148438e70e2 100644 --- a/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/pages/index/index.js +++ b/ability/JsDistributedMusicPlayer/entry/src/main/js/MainAbility/pages/index/index.js @@ -20,16 +20,16 @@ import KvStoreModel from '../../model/KvStoreModel.js'; import display from '@ohos.display'; function getShownTimer(ms) { - var seconds = Math.floor(ms / 1000); - var sec = seconds % 60; - var min = (seconds - sec) / 60; - if (sec < 10) { - sec = '0' + sec; - } - if (min < 10) { - min = '0' + min; - } - return min + ':' + sec; + var seconds = Math.floor(ms / 1000); + var sec = seconds % 60; + var min = (seconds - sec) / 60; + if (sec < 10) { + sec = '0' + sec; + } + if (min < 10) { + min = '0' + min; + } + return min + ':' + sec; } const REMOTE_ABILITY_STARTED = 'remoteAbilityStarted'; @@ -39,336 +39,336 @@ const DESIGN_WIDTH = 720.0; const DESIGN_RATIO = 16 / 9; export default { - data: { - title: '', - currentTimeText: '', - totalTimeText: '', - totalMs: 0, - currentProgress: 0, - deviceList: [], - btnPlaySrc: '/common/media/ic_play.svg', - albumSrc: '/common/media/album.png', - remoteDeviceModel: new RemoteDeviceModel(), - playerModel: new PlayerModel(), - kvStoreModel: new KvStoreModel(), - isDialogShowing: false, - isSwitching: false, - riscale: 1, // ratio independent scale ratio - risw: 720, // ratio independent screen width - rish: 1280, // ratio independent screen height - hasInitialized: false, - }, - onInit() { - console.info('MusicPlayer[IndexPage] onInit begin'); - this.grantPermission() - console.info("MusicPlayer[IndexPage] getDefaultDisplay begin"); - display.getDefaultDisplay().then(dis => { - console.info("MusicPlayer[IndexPage] getDefaultDisplay dis=" + JSON.stringify(dis)); - var proportion = DESIGN_WIDTH / dis.width; - var screenWidth = DESIGN_WIDTH; - var screenHeight = (dis.height - SYSTEM_UI_HEIGHT) * proportion; - this.riscale = (screenHeight / screenWidth) / DESIGN_RATIO; - if (this.riscale < 1) { - // The screen ratio is shorter than design ratio - this.risw = screenWidth * this.riscale; - this.rish = screenHeight; - } else { - // The screen ratio is longer than design ratio - this.risw = screenWidth; - this.rish = screenHeight / this.riscale; - } - this.hasInitialized = true; - console.info("MusicPlayer[IndexPage] proportion=" + proportion + ", screenWidth=" - + screenWidth + ", screenHeight=" + screenHeight + ", riscale=" + this.riscale - + ", risw=" + this.risw + ", rish=" + this.rish); - }); - console.info("MusicPlayer[IndexPage] getDefaultDisplay end"); - DEVICE_LIST_LOCALHOST = { - name: this.$t('strings.localhost'), - id: 'localhost', - }; - this.deviceList = [DEVICE_LIST_LOCALHOST]; + data: { + title: '', + currentTimeText: '', + totalTimeText: '', + totalMs: 0, + currentProgress: 0, + deviceList: [], + btnPlaySrc: '/common/media/ic_play.svg', + albumSrc: '/common/media/album.png', + remoteDeviceModel: new RemoteDeviceModel(), + playerModel: new PlayerModel(), + kvStoreModel: new KvStoreModel(), + isDialogShowing: false, + isSwitching: false, + riscale: 1, // ratio independent scale ratio + risw: 720, // ratio independent screen width + rish: 1280, // ratio independent screen height + hasInitialized: false, + }, + onInit() { + console.info('MusicPlayer[IndexPage] onInit begin'); + this.grantPermission() + console.info("MusicPlayer[IndexPage] getDefaultDisplay begin"); + display.getDefaultDisplay().then(dis => { + console.info("MusicPlayer[IndexPage] getDefaultDisplay dis=" + JSON.stringify(dis)); + var proportion = DESIGN_WIDTH / dis.width; + var screenWidth = DESIGN_WIDTH; + var screenHeight = (dis.height - SYSTEM_UI_HEIGHT) * proportion; + this.riscale = (screenHeight / screenWidth) / DESIGN_RATIO; + if (this.riscale < 1) { + // The screen ratio is shorter than design ratio + this.risw = screenWidth * this.riscale; + this.rish = screenHeight; + } else { + // The screen ratio is longer than design ratio + this.risw = screenWidth; + this.rish = screenHeight / this.riscale; + } + this.hasInitialized = true; + console.info("MusicPlayer[IndexPage] proportion=" + proportion + ", screenWidth=" + + screenWidth + ", screenHeight=" + screenHeight + ", riscale=" + this.riscale + + ", risw=" + this.risw + ", rish=" + this.rish); + }); + console.info("MusicPlayer[IndexPage] getDefaultDisplay end"); + DEVICE_LIST_LOCALHOST = { + name: this.$t('strings.localhost'), + id: 'localhost', + }; + this.deviceList = [DEVICE_LIST_LOCALHOST]; - this.currentTimeText = getShownTimer(0); - this.playerModel.setOnStatusChangedListener((isPlaying) => { - console.info('MusicPlayer[IndexPage] on player status changed, isPlaying=' + isPlaying + ', refresh ui'); - this.playerModel.setOnPlayingProgressListener((currentTimeMs) => { - this.currentTimeText = getShownTimer(currentTimeMs); - this.currentProgress = Math.floor(currentTimeMs / this.totalMs * 100); + this.currentTimeText = getShownTimer(0); + this.playerModel.setOnStatusChangedListener((isPlaying) => { + console.info('MusicPlayer[IndexPage] on player status changed, isPlaying=' + isPlaying + ', refresh ui'); + this.playerModel.setOnPlayingProgressListener((currentTimeMs) => { + this.currentTimeText = getShownTimer(currentTimeMs); + this.currentProgress = Math.floor(currentTimeMs / this.totalMs * 100); + }); + if (isPlaying) { + this.btnPlaySrc = '/common/media/ic_pause.svg'; + } else { + this.btnPlaySrc = '/common/media/ic_play.svg'; + } + }); + this.playerModel.getPlaylist(() => { + console.info('MusicPlayer[IndexPage] on playlist generated, refresh ui'); + this.restoreFromWant(); + }); + console.info('MusicPlayer[IndexPage] onInit end'); + }, + grantPermission() { + console.info('MusicPlayer[IndexPage] grantPermission') + let context = featureAbility.getContext() + context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { + console.info(`MusicPlayer[IndexPage] grantPermission,requestPermissionsFromUser,result.requestCode=${result.requestCode}`) + }) + }, + restoreFromWant() { + featureAbility.getWant((error, want) => { + console.info('MusicPlayer[IndexPage] featureAbility.getWant=' + JSON.stringify(want)); + var status = want.parameters; + if (status != null && status.uri != null) { + this.kvStoreModel.broadcastMessage(REMOTE_ABILITY_STARTED); + console.info('MusicPlayer[IndexPage] restorePlayingStatus'); + this.playerModel.restorePlayingStatus(status, (index) => { + console.info('MusicPlayer[IndexPage] restorePlayingStatus finished, index=' + index); + if (index >= 0) { + this.refreshSongInfo(index); + } else { + this.playerModel.preLoad(0, () => { + this.refreshSongInfo(0); }); - if (isPlaying) { - this.btnPlaySrc = '/common/media/ic_pause.svg'; - } else { - this.btnPlaySrc = '/common/media/ic_play.svg'; - } + } }); - this.playerModel.getPlaylist(() => { - console.info('MusicPlayer[IndexPage] on playlist generated, refresh ui'); - this.restoreFromWant(); + } else { + this.playerModel.preLoad(0, () => { + this.refreshSongInfo(0); }); - console.info('MusicPlayer[IndexPage] onInit end'); - }, - grantPermission() { - console.info('MusicPlayer[IndexPage] grantPermission') - let context = featureAbility.getContext() - context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { - console.info(`MusicPlayer[IndexPage] grantPermission,requestPermissionsFromUser,result.requestCode=${result.requestCode}`) - }) - }, - restoreFromWant() { - featureAbility.getWant((error, want) => { - console.info('MusicPlayer[IndexPage] featureAbility.getWant=' + JSON.stringify(want)); - var status = want.parameters; - if (status != null && status.uri != null) { - this.kvStoreModel.broadcastMessage(REMOTE_ABILITY_STARTED); - console.info('MusicPlayer[IndexPage] restorePlayingStatus'); - this.playerModel.restorePlayingStatus(status, (index) => { - console.info('MusicPlayer[IndexPage] restorePlayingStatus finished, index=' + index); - if (index >= 0) { - this.refreshSongInfo(index); - } else { - this.playerModel.preLoad(0, () => { - this.refreshSongInfo(0); - }); - } - }); - } else { - this.playerModel.preLoad(0, () => { - this.refreshSongInfo(0); - }); - } - }); - }, - onNewRequest() { - console.info('MusicPlayer[IndexPage] onNewRequest'); - this.playerModel.pause(); - this.playerModel.seek(0); - this.restoreFromWant(); - }, - onBackPress() { - console.info('MusicPlayer[IndexPage] onBackPress isDialogShowing=' + this.isDialogShowing); - if (this.isDialogShowing === true) { - this.dismissDialog(); - return true; - } - return false; - }, - onDestroy() { - console.info('MusicPlayer[IndexPage] onDestroy begin'); - if (this.playerModel === undefined) { - return - } - this.playerModel.release(); - this.remoteDeviceModel.unregisterDeviceListCallback(); - console.info('MusicPlayer[IndexPage] onDestroy end'); - }, - refreshSongInfo(index) { - console.info('MusicPlayer[IndexPage] refreshSongInfo ' + index + '/' - + this.playerModel.playlist.audioFiles.length); - if (index >= this.playerModel.playlist.audioFiles.length) { - console.warn('MusicPlayer[IndexPage] refreshSongInfo ignored'); - return; - } - // update song title - this.title = this.playerModel.playlist.audioFiles[index].name; - this.albumSrc = (index % 2 === 0) ? '/common/media/album.png' : '/common/media/album2.png'; + } + }); + }, + onNewRequest() { + console.info('MusicPlayer[IndexPage] onNewRequest'); + this.playerModel.pause(); + this.playerModel.seek(0); + this.restoreFromWant(); + }, + onBackPress() { + console.info('MusicPlayer[IndexPage] onBackPress isDialogShowing=' + this.isDialogShowing); + if (this.isDialogShowing === true) { + this.dismissDialog(); + return true; + } + return false; + }, + onDestroy() { + console.info('MusicPlayer[IndexPage] onDestroy begin'); + if (this.playerModel === undefined) { + return + } + this.playerModel.release(); + this.remoteDeviceModel.unregisterDeviceListCallback(); + console.info('MusicPlayer[IndexPage] onDestroy end'); + }, + refreshSongInfo(index) { + console.info('MusicPlayer[IndexPage] refreshSongInfo ' + index + '/' + + this.playerModel.playlist.audioFiles.length); + if (index >= this.playerModel.playlist.audioFiles.length) { + console.warn('MusicPlayer[IndexPage] refreshSongInfo ignored'); + return; + } + // update song title + this.title = this.playerModel.playlist.audioFiles[index].name; + this.albumSrc = (index % 2 === 0) ? '/common/media/album.png' : '/common/media/album2.png'; - // update duration - this.totalMs = this.playerModel.getDuration(); - this.totalTimeText = getShownTimer(this.totalMs); - this.currentTimeText = getShownTimer(this.playerModel.getCurrentMs()); + // update duration + this.totalMs = this.playerModel.getDuration(); + this.totalTimeText = getShownTimer(this.totalMs); + this.currentTimeText = getShownTimer(this.playerModel.getCurrentMs()); - console.info('MusicPlayer[IndexPage] refreshSongInfo this.title=' + this.title + ' this.totalMs=' - + this.totalMs + ' this.totalTimeText=' + this.totalTimeText + ' this.currentTimeText=' + this.currentTimeText); - }, - setProgress(e) { - console.info('MusicPlayer[IndexPage] setProgress ' + e.mode + ', ' + e.value); - this.currentProgress = e.value; - if (isNaN(this.totalMs)) { - this.currentProgress = 0; - console.info('MusicPlayer[IndexPage] setProgress ignored, totalMs=' + this.totalMs); - return; - } - var currentMs = this.currentProgress / 100 * this.totalMs; - this.currentTimeText = getShownTimer(currentMs); - if (e.mode === 'end' || e.mode === 'click') { - console.info('MusicPlayer[IndexPage] player.seek ' + currentMs); - this.playerModel.seek(currentMs); - } - }, - onPreviousClick() { - if (this.isSwitching) { - console.info('MusicPlayer[IndexPage] onPreviousClick ignored, isSwitching'); - return; - } - console.info('MusicPlayer[IndexPage] onPreviousClick'); - this.playerModel.index--; - if (this.playerModel.index < 0 && this.playerModel.playlist.audioFiles.length >= 1) { - this.playerModel.index = this.playerModel.playlist.audioFiles.length - 1; - } - this.currentProgress = 0; - this.isSwitching = true; - this.playerModel.preLoad(this.playerModel.index, () => { - this.refreshSongInfo(this.playerModel.index); - this.playerModel.play(0, true); - this.isSwitching = false; - }); - }, - onNextClick() { - if (this.isSwitching) { - console.info('MusicPlayer[IndexPage] onNextClick ignored, isSwitching'); - return; - } - console.info('MusicPlayer[IndexPage] onNextClick'); - this.playerModel.index++; - if (this.playerModel.index >= this.playerModel.playlist.audioFiles.length) { - this.playerModel.index = 0; - } - this.currentProgress = 0; - this.isSwitching = true; - this.playerModel.preLoad(this.playerModel.index, () => { - this.refreshSongInfo(this.playerModel.index); - this.playerModel.play(0, true); - this.isSwitching = false; - }); - }, - onPlayClick() { - if (this.isSwitching) { - console.info('MusicPlayer[IndexPage] onPlayClick ignored, isSwitching'); - return; - } - console.info('MusicPlayer[IndexPage] onPlayClick, isPlaying=' + this.playerModel.isPlaying); - if (this.playerModel.isPlaying) { - this.playerModel.pause(); - } else { - this.playerModel.preLoad(this.playerModel.index, () => { - this.playerModel.play(-1, true); - }); - } - }, - onContinueAbilityClick() { - console.info('MusicPlayer[IndexPage] onContinueAbilityClick begin'); - this.remoteDeviceModel.registerDeviceListCallback(() => { - console.info('MusicPlayer[IndexPage] registerDeviceListCallback, callback entered'); - var list = []; - list[0] = DEVICE_LIST_LOCALHOST; - var deviceList; - if (this.remoteDeviceModel.discoverList.length > 0) { - deviceList = this.remoteDeviceModel.discoverList; - } else { - deviceList = this.remoteDeviceModel.deviceList; - } - console.info('MusicPlayer[IndexPage] on remote device updated, count=' + deviceList.length); - for (var i = 0; i < deviceList.length; i++) { - console.info('MusicPlayer[IndexPage] device ' + i + '/' + deviceList.length + ' deviceId=' - + deviceList[i].deviceId + ' deviceName=' + deviceList[i].deviceName + ' deviceType=' - + deviceList[i].deviceType); - list[i + 1] = { - name: deviceList[i].deviceName, - id: deviceList[i].deviceId, - }; - } - this.deviceList = list; - }); - this.$element('continueAbilityDialog').show(); - this.isDialogShowing = true; - console.info('MusicPlayer[IndexPage] onContinueAbilityClick end'); - }, - startAbilityContinuation(deviceId, deviceName) { + console.info('MusicPlayer[IndexPage] refreshSongInfo this.title=' + this.title + ' this.totalMs=' + + this.totalMs + ' this.totalTimeText=' + this.totalTimeText + ' this.currentTimeText=' + this.currentTimeText); + }, + setProgress(e) { + console.info('MusicPlayer[IndexPage] setProgress ' + e.mode + ', ' + e.value); + this.currentProgress = e.value; + if (isNaN(this.totalMs)) { + this.currentProgress = 0; + console.info('MusicPlayer[IndexPage] setProgress ignored, totalMs=' + this.totalMs); + return; + } + var currentMs = this.currentProgress / 100 * this.totalMs; + this.currentTimeText = getShownTimer(currentMs); + if (e.mode === 'end' || e.mode === 'click') { + console.info('MusicPlayer[IndexPage] player.seek ' + currentMs); + this.playerModel.seek(currentMs); + } + }, + onPreviousClick() { + if (this.isSwitching) { + console.info('MusicPlayer[IndexPage] onPreviousClick ignored, isSwitching'); + return; + } + console.info('MusicPlayer[IndexPage] onPreviousClick'); + this.playerModel.index--; + if (this.playerModel.index < 0 && this.playerModel.playlist.audioFiles.length >= 1) { + this.playerModel.index = this.playerModel.playlist.audioFiles.length - 1; + } + this.currentProgress = 0; + this.isSwitching = true; + this.playerModel.preLoad(this.playerModel.index, () => { + this.refreshSongInfo(this.playerModel.index); + this.playerModel.play(0, true); + this.isSwitching = false; + }); + }, + onNextClick() { + if (this.isSwitching) { + console.info('MusicPlayer[IndexPage] onNextClick ignored, isSwitching'); + return; + } + console.info('MusicPlayer[IndexPage] onNextClick'); + this.playerModel.index++; + if (this.playerModel.index >= this.playerModel.playlist.audioFiles.length) { + this.playerModel.index = 0; + } + this.currentProgress = 0; + this.isSwitching = true; + this.playerModel.preLoad(this.playerModel.index, () => { + this.refreshSongInfo(this.playerModel.index); + this.playerModel.play(0, true); + this.isSwitching = false; + }); + }, + onPlayClick() { + if (this.isSwitching) { + console.info('MusicPlayer[IndexPage] onPlayClick ignored, isSwitching'); + return; + } + console.info('MusicPlayer[IndexPage] onPlayClick, isPlaying=' + this.playerModel.isPlaying); + if (this.playerModel.isPlaying) { + this.playerModel.pause(); + } else { + this.playerModel.preLoad(this.playerModel.index, () => { + this.playerModel.play(-1, true); + }); + } + }, + onContinueAbilityClick() { + console.info('MusicPlayer[IndexPage] onContinueAbilityClick begin'); + this.remoteDeviceModel.registerDeviceListCallback(() => { + console.info('MusicPlayer[IndexPage] registerDeviceListCallback, callback entered'); + var list = []; + list[0] = DEVICE_LIST_LOCALHOST; + var deviceList; + if (this.remoteDeviceModel.discoverList.length > 0) { + deviceList = this.remoteDeviceModel.discoverList; + } else { + deviceList = this.remoteDeviceModel.deviceList; + } + console.info('MusicPlayer[IndexPage] on remote device updated, count=' + deviceList.length); + for (var i = 0; i < deviceList.length; i++) { + console.info('MusicPlayer[IndexPage] device ' + i + '/' + deviceList.length + ' deviceId=' + + deviceList[i].deviceId + ' deviceName=' + deviceList[i].deviceName + ' deviceType=' + + deviceList[i].deviceType); + list[i + 1] = { + name: deviceList[i].deviceName, + id: deviceList[i].deviceId, + }; + } + this.deviceList = list; + }); + this.$element('continueAbilityDialog').show(); + this.isDialogShowing = true; + console.info('MusicPlayer[IndexPage] onContinueAbilityClick end'); + }, + startAbilityContinuation(deviceId, deviceName) { + this.$element('continueAbilityDialog').close(); + var params; + if (this.playerModel.index >= 0 && this.playerModel.index <= this.playerModel.playlist.audioFiles.length) { + params = { + uri: this.playerModel.playlist.audioFiles[this.playerModel.index].fileUri, + seekTo: this.playerModel.getCurrentMs(), + isPlaying: this.playerModel.isPlaying + }; + } else { + params = { + uri: '', + seekTo: 0, + isPlaying: false + }; + } + console.info('MusicPlayer[IndexPage] featureAbility.startAbility deviceId=' + deviceId + + ' deviceName=' + deviceName); + var wantValue = { + bundleName: 'ohos.samples.distributedmusicplayer', + abilityName: 'ohos.samples.distributedmusicplayer.MainAbility', + deviceId: deviceId, + parameters: params + }; + var timerId = setTimeout(() => { + console.info('MusicPlayer[IndexPage] onMessageReceiveTimeout, terminateSelf'); + featureAbility.terminateSelf((error) => { + console.info('MusicPlayer[IndexPage] terminateSelf finished, error=' + error); + }); + }, 3000); + this.kvStoreModel.setOnMessageReceivedListener(REMOTE_ABILITY_STARTED, () => { + console.info('MusicPlayer[IndexPage] OnMessageReceived, terminateSelf'); + clearTimeout(timerId); + featureAbility.terminateSelf((error) => { + console.info('MusicPlayer[IndexPage] terminateSelf finished, error=' + error); + }); + }); + featureAbility.startAbility({ + want: wantValue + }).then((data) => { + console.info('MusicPlayer[IndexPage] featureAbility.startAbility finished, ' + JSON.stringify(data)); + }); + console.info('MusicPlayer[IndexPage] featureAbility.startAbility want=' + JSON.stringify(wantValue)); + console.info('MusicPlayer[IndexPage] featureAbility.startAbility end'); + }, + onRadioChange(inputValue, e) { + console.info('MusicPlayer[IndexPage] onRadioChange ' + inputValue + ', ' + e.value); + if (inputValue === e.value) { + if (e.value === 'localhost') { this.$element('continueAbilityDialog').close(); - var params; - if (this.playerModel.index >= 0 && this.playerModel.index <= this.playerModel.playlist.audioFiles.length) { - params = { - uri: this.playerModel.playlist.audioFiles[this.playerModel.index].fileUri, - seekTo: this.playerModel.getCurrentMs(), - isPlaying: this.playerModel.isPlaying - }; - } else { - params = { - uri: '', - seekTo: 0, - isPlaying: false - }; + return; + } + if (this.remoteDeviceModel.discoverList.length > 0) { + console.info('MusicPlayer[IndexPage] continue to unauthed device'); + var name = null; + for (var i = 0; i < this.remoteDeviceModel.discoverList.length; i++) { + if (this.remoteDeviceModel.discoverList[i].deviceId === e.value) { + name = this.remoteDeviceModel.discoverList[i].deviceName; + break; + } } - console.info('MusicPlayer[IndexPage] featureAbility.startAbility deviceId=' + deviceId - + ' deviceName=' + deviceName); - var wantValue = { - bundleName: 'ohos.samples.distributedmusicplayer', - abilityName: 'ohos.samples.distributedmusicplayer.MainAbility', - deviceId: deviceId, - parameters: params - }; - var timerId = setTimeout(() => { - console.info('MusicPlayer[IndexPage] onMessageReceiveTimeout, terminateSelf'); - featureAbility.terminateSelf((error) => { - console.info('MusicPlayer[IndexPage] terminateSelf finished, error=' + error); - }); - }, 3000); - this.kvStoreModel.setOnMessageReceivedListener(REMOTE_ABILITY_STARTED, () => { - console.info('MusicPlayer[IndexPage] OnMessageReceived, terminateSelf'); - clearTimeout(timerId); - featureAbility.terminateSelf((error) => { - console.info('MusicPlayer[IndexPage] terminateSelf finished, error=' + error); - }); - }); - featureAbility.startAbility({ - want: wantValue - }).then((data) => { - console.info('MusicPlayer[IndexPage] featureAbility.startAbility finished, ' + JSON.stringify(data)); - }); - console.info('MusicPlayer[IndexPage] featureAbility.startAbility want=' + JSON.stringify(wantValue)); - console.info('MusicPlayer[IndexPage] featureAbility.startAbility end'); - }, - onRadioChange(inputValue, e) { - console.info('MusicPlayer[IndexPage] onRadioChange ' + inputValue + ', ' + e.value); - if (inputValue === e.value) { - if (e.value === 'localhost') { - this.$element('continueAbilityDialog').close(); - return; - } - if (this.remoteDeviceModel.discoverList.length > 0) { - console.info('MusicPlayer[IndexPage] continue to unauthed device'); - var name = null; - for (var i = 0; i < this.remoteDeviceModel.discoverList.length; i++) { - if (this.remoteDeviceModel.discoverList[i].deviceId === e.value) { - name = this.remoteDeviceModel.discoverList[i].deviceName; - break; - } - } - if (name == null) { - console.error('MusicPlayer[IndexPage] onRadioChange failed, can not get name from discoverList'); - return; - } - console.info('MusicPlayer[IndexPage] onRadioChange name=' + name); + if (name == null) { + console.error('MusicPlayer[IndexPage] onRadioChange failed, can not get name from discoverList'); + return; + } + console.info('MusicPlayer[IndexPage] onRadioChange name=' + name); - this.remoteDeviceModel.authDevice(e.value, () => { - console.info('MusicPlayer[IndexPage] auth and online finished'); - for (i = 0; i < this.remoteDeviceModel.deviceList.length; i++) { - if (this.remoteDeviceModel.deviceList[i].deviceName === name) { - this.startAbilityContinuation(this.remoteDeviceModel.deviceList[i].deviceId, this.remoteDeviceModel.deviceList[i].deviceName); - } - } - }); - } else { - console.info('MusicPlayer[IndexPage] continue to authed device'); - for (i = 0; i < this.remoteDeviceModel.deviceList.length; i++) { - if (this.remoteDeviceModel.deviceList[i].deviceId === e.value) { - this.startAbilityContinuation(this.remoteDeviceModel.deviceList[i].deviceId, this.remoteDeviceModel.deviceList[i].deviceName); - } - } + this.remoteDeviceModel.authDevice(e.value, () => { + console.info('MusicPlayer[IndexPage] auth and online finished'); + for (i = 0; i < this.remoteDeviceModel.deviceList.length; i++) { + if (this.remoteDeviceModel.deviceList[i].deviceName === name) { + this.startAbilityContinuation(this.remoteDeviceModel.deviceList[i].deviceId, this.remoteDeviceModel.deviceList[i].deviceName); } + } + }); + } else { + console.info('MusicPlayer[IndexPage] continue to authed device'); + for (i = 0; i < this.remoteDeviceModel.deviceList.length; i++) { + if (this.remoteDeviceModel.deviceList[i].deviceId === e.value) { + this.startAbilityContinuation(this.remoteDeviceModel.deviceList[i].deviceId, this.remoteDeviceModel.deviceList[i].deviceName); + } } - }, - cancelDialog(e) { - this.remoteDeviceModel.unregisterDeviceListCallback(); - this.isDialogShowing = false; - }, - onDismissDialogClicked(e) { - this.dismissDialog(); - }, - dismissDialog() { - this.$element('continueAbilityDialog').close(); - this.remoteDeviceModel.unregisterDeviceListCallback(); - this.isDialogShowing = false; + } } + }, + cancelDialog(e) { + this.remoteDeviceModel.unregisterDeviceListCallback(); + this.isDialogShowing = false; + }, + onDismissDialogClicked(e) { + this.dismissDialog(); + }, + dismissDialog() { + this.$element('continueAbilityDialog').close(); + this.remoteDeviceModel.unregisterDeviceListCallback(); + this.isDialogShowing = false; + } }; diff --git a/common/AirQuality/.gitignore b/common/AirQuality/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/common/AirQuality/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/common/AirQuality/README_zh.md b/common/AirQuality/README_zh.md index 8fb746695da641ee800def2ba4b05badde08e3cc..bb77546ac0d8da3e8479d863218d8f8eff5d5c1e 100644 --- a/common/AirQuality/README_zh.md +++ b/common/AirQuality/README_zh.md @@ -26,7 +26,7 @@ chart:图表组件,用于呈现线形图、柱状图、量规图界面。 1.本示例支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 3.如果安装本示例报错为error:install sign info inconsistent,则有可能本应用被设置为系统预置应用,已安装在系统中,此时需使用命令进行替换安装,并在替换安装后对设备进行重启操作,具体命令如下: diff --git a/common/AirQuality/entry/src/main/js/default/app.js b/common/AirQuality/entry/src/main/js/default/app.js index 50449ecbed6d3b8099f6f9a1fb66e29bbe2177f0..8f942067bdff10596dabb48f3b0e9dfc6ca620da 100644 --- a/common/AirQuality/entry/src/main/js/default/app.js +++ b/common/AirQuality/entry/src/main/js/default/app.js @@ -13,10 +13,10 @@ * limitations under the License. */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/common/AirQuality/entry/src/main/js/default/pages/index/index.css b/common/AirQuality/entry/src/main/js/default/pages/index/index.css index c385c66236178f1ea8ea5799247e64e543cd6af3..cd4b36230b91c5f9e9d5f213a5844140502e33da 100644 --- a/common/AirQuality/entry/src/main/js/default/pages/index/index.css +++ b/common/AirQuality/entry/src/main/js/default/pages/index/index.css @@ -61,11 +61,13 @@ height: 50px; font-size: 35px; } + .progress-div { width: 320px; height: 220px; flex-direction: column; } + .progress { width: 100%; height: 100%; @@ -83,13 +85,13 @@ stroke-width: 20px; width: 100%; height: 100%; - top:5px; + top: 5px; } .mask-layer { width: 100%; height: 100%; - top:10px; + top: 10px; flex-direction: column; } @@ -164,7 +166,7 @@ width: 100%; height: 100%; flex-direction: row; - flex-wrap:wrap; + flex-wrap: wrap; align-items: center; justify-content: center; } diff --git a/common/AirQuality/entry/src/main/js/default/pages/index/index.hml b/common/AirQuality/entry/src/main/js/default/pages/index/index.hml index f8529da6ade121784c5ff61e1954196da9d68f2e..b3afd7803eeaf5c5a7defdbe40b9c98def9737a0 100644 --- a/common/AirQuality/entry/src/main/js/default/pages/index/index.hml +++ b/common/AirQuality/entry/src/main/js/default/pages/index/index.hml @@ -13,108 +13,108 @@ See the License for the specific language governing permissions and limitations under the License. -->
-
- - {{ $t('strings.title') }} -
- - - -
-
- - {{ airData[0].location }} - - - - -
- AQI - {{ airData[0].detailData }} - {{ airData[0].airQuality }} - -
-
-
-
-
- CO - 100 -
-
- NO2 - 90 -
-
- PM10 - 120 -
-
- PM2.5 - 40 -
-
- SO2 - 150 -
-
-
- -
- -
-
-
- - {{ airData[1].location }} - - - - -
- AQI - {{ airData[1].detailData }} - {{ airData[1].airQuality }} - -
-
-
-
-
- CO - 100 -
-
- NO2 - 90 -
-
- PM10 - 120 -
-
- PM2.5 - 40 -
-
- SO2 - 150 -
-
- - -
-
-
-
+
+ + {{ $t('strings.title') }} +
+ + + +
+
+ + {{ airData[0].location }} + + + + +
+ AQI + {{ airData[0].detailData }} + {{ airData[0].airQuality }} + +
+
+
+
+
+ CO + 100 +
+
+ NO2 + 90 +
+
+ PM10 + 120 +
+
+ PM2.5 + 40 +
+
+ SO2 + 150 +
+
+
+ +
+ +
+
+
+ + {{ airData[1].location }} + + + + +
+ AQI + {{ airData[1].detailData }} + {{ airData[1].airQuality }} + +
+
+
+
+
+ CO + 100 +
+
+ NO2 + 90 +
+
+ PM10 + 120 +
+
+ PM2.5 + 40 +
+
+ SO2 + 150 +
+
+ + +
+
+
+
diff --git a/common/AirQuality/entry/src/main/js/default/pages/index/index.js b/common/AirQuality/entry/src/main/js/default/pages/index/index.js index d06306b655e5b300f220030dbc8eca8d7ab9c395..506962cf9bc0ec0e2f8dc28c121387bd3012b617 100644 --- a/common/AirQuality/entry/src/main/js/default/pages/index/index.js +++ b/common/AirQuality/entry/src/main/js/default/pages/index/index.js @@ -16,82 +16,82 @@ import router from '@ohos.router'; import app from '@system.app'; export default { - data: { - textColor1: '#00ff00', - textColor2: '#00ff00', - bgColor1: '#669966', - bgColor2: '#669966', - swiperPage: 0, - percent1: 40, - percent2: 90, - iconcheckedBR: '6px', - iconcheckedColor: '#ffffff', - iconUncheckedColor: '#262626', - src1: '/common/cloud_green.png', - src2: '/common/cloud_green.png', - airData: [{ - location: '东莞', - airQuality: '良', - detailData: 40 - }, { - location: '深圳', - airQuality: '差', - detailData: 90 - }] - }, - onInit() { - if (this.airData[0].detailData > 100) { - this.src1 = '/common/cloud_red.png'; - this.textColor1 = '#ff0000'; - this.bgColor1 = '#9d7462'; - } else if (this.airData[0].detailData > 50 ) { - this.src1 = '/common/cloud_yellow.png'; - this.textColor1 = '#ecf19a'; - this.bgColor1 = '#9d9d62'; - } - if (this.airData[1].detailData > 100) { - this.src2 = '/common/cloud_red.png'; - this.textColor2 = '#ff0000'; - this.bgColor2 = '#9d9d62'; - } else if (50 < this.airData[1].detailData) { - this.src2 = '/common/cloud_yellow.png' - this.textColor2 = '#ecf19a'; - this.bgColor2 = '#9d9d62'; - } - if (this.selectedCityIndex) { - this.swiperPage = this.selectedCityIntex - if (this.swiperPage == 0) { - this.iconcheckedBR = '#ffffff'; - this.iconUncheckedColor = '#262626'; - } else { - this.iconcheckedColor = '#262626'; - this.iconUncheckedColor = '#ffffff'; - } - } - }, - openDetail() { - router.push({ - url: 'pages/second/second', - params: { - selectedCityIndex: this.swiperPage - } - }); - }, - exitApp() { - console.log('start exit'); - app.terminate(); - console.log('end exit') - }, - swiperChange(e) { - this.swiperPage = e.index; - if (e.index == 0) { - this.iconcheckedColor = '#ffffff'; - this.iconUncheckedColor = '#262626'; - } else { - this.iconcheckedColor = '#262626'; - this.iconUncheckedColor = '#ffffff'; - } + data: { + textColor1: '#00ff00', + textColor2: '#00ff00', + bgColor1: '#669966', + bgColor2: '#669966', + swiperPage: 0, + percent1: 40, + percent2: 90, + iconcheckedBR: '6px', + iconcheckedColor: '#ffffff', + iconUncheckedColor: '#262626', + src1: '/common/cloud_green.png', + src2: '/common/cloud_green.png', + airData: [{ + location: '东莞', + airQuality: '良', + detailData: 40 + }, { + location: '深圳', + airQuality: '差', + detailData: 90 + }] + }, + onInit() { + if (this.airData[0].detailData > 100) { + this.src1 = '/common/cloud_red.png'; + this.textColor1 = '#ff0000'; + this.bgColor1 = '#9d7462'; + } else if (this.airData[0].detailData > 50) { + this.src1 = '/common/cloud_yellow.png'; + this.textColor1 = '#ecf19a'; + this.bgColor1 = '#9d9d62'; } + if (this.airData[1].detailData > 100) { + this.src2 = '/common/cloud_red.png'; + this.textColor2 = '#ff0000'; + this.bgColor2 = '#9d9d62'; + } else if (50 < this.airData[1].detailData) { + this.src2 = '/common/cloud_yellow.png' + this.textColor2 = '#ecf19a'; + this.bgColor2 = '#9d9d62'; + } + if (this.selectedCityIndex) { + this.swiperPage = this.selectedCityIntex + if (this.swiperPage == 0) { + this.iconcheckedBR = '#ffffff'; + this.iconUncheckedColor = '#262626'; + } else { + this.iconcheckedColor = '#262626'; + this.iconUncheckedColor = '#ffffff'; + } + } + }, + openDetail() { + router.push({ + url: 'pages/second/second', + params: { + selectedCityIndex: this.swiperPage + } + }); + }, + exitApp() { + console.log('start exit'); + app.terminate(); + console.log('end exit') + }, + swiperChange(e) { + this.swiperPage = e.index; + if (e.index == 0) { + this.iconcheckedColor = '#ffffff'; + this.iconUncheckedColor = '#262626'; + } else { + this.iconcheckedColor = '#262626'; + this.iconUncheckedColor = '#ffffff'; + } + } } diff --git a/common/AirQuality/entry/src/main/js/default/pages/second/second.hml b/common/AirQuality/entry/src/main/js/default/pages/second/second.hml index b8bbd13c418e26e7617e67e3a24e13140f429a49..bbdf7a1ac2b5792d1c69e1aa1254338bf1308a1f 100644 --- a/common/AirQuality/entry/src/main/js/default/pages/second/second.hml +++ b/common/AirQuality/entry/src/main/js/default/pages/second/second.hml @@ -13,135 +13,135 @@ See the License for the specific language governing permissions and limitations under the License. -->
-
- - {{ $t('strings.title') }} -
- - - {{ location }} - - -
-
- CO -
-
-
-
-
-
-
-
-
-
-
- MON - TUE - WED - THU - FRI - SAT - SUN -
-
-
- SO2 -
-
-
-
-
-
-
-
-
-
-
- MON - TUE - WED - THU - FRI - SAT - SUN -
-
-
-
- -
-
- PM10 -
-
-
-
-
-
-
-
-
-
-
- MON - TUE - WED - THU - FRI - SAT - SUN -
-
-
- PM2.5 -
-
-
-
-
-
-
-
-
-
-
- MON - TUE - WED - THU - FRI - SAT - SUN -
-
-
-
- -
-
- NO2 -
-
-
-
-
-
-
-
-
-
-
- MON - TUE - WED - THU - FRI - SAT - SUN -
-
-
-
-
+
+ + {{ $t('strings.title') }} +
+ + + {{ location }} + + +
+
+ CO +
+
+
+
+
+
+
+
+
+
+
+ MON + TUE + WED + THU + FRI + SAT + SUN +
+
+
+ SO2 +
+
+
+
+
+
+
+
+
+
+
+ MON + TUE + WED + THU + FRI + SAT + SUN +
+
+
+
+ +
+
+ PM10 +
+
+
+
+
+
+
+
+
+
+
+ MON + TUE + WED + THU + FRI + SAT + SUN +
+
+
+ PM2.5 +
+
+
+
+
+
+
+
+
+
+
+ MON + TUE + WED + THU + FRI + SAT + SUN +
+
+
+
+ +
+
+ NO2 +
+
+
+
+
+
+
+
+
+
+
+ MON + TUE + WED + THU + FRI + SAT + SUN +
+
+
+
+
diff --git a/common/AirQuality/entry/src/main/js/default/pages/second/second.js b/common/AirQuality/entry/src/main/js/default/pages/second/second.js index fb93746348c21ac2bb1ee19bc7fb82bc20c6ffd5..abdfbe16f1903a4dd7aaa3c68aa4707a321d63fa 100644 --- a/common/AirQuality/entry/src/main/js/default/pages/second/second.js +++ b/common/AirQuality/entry/src/main/js/default/pages/second/second.js @@ -15,17 +15,17 @@ import router from '@ohos.router' export default { - data: { - location: '' - }, - onInit() { - if (this.selectedCityIndex === 0) { - this.location = '东莞'; - } else { - this.location = '深圳'; - } - }, - backMain() { - router.back() + data: { + location: '' + }, + onInit() { + if (this.selectedCityIndex === 0) { + this.location = '东莞'; + } else { + this.location = '深圳'; } + }, + backMain() { + router.back() + } } diff --git a/common/AirQuality/package.json b/common/AirQuality/package.json index 19efc1764b1a84c21166e01990f692f4874b63d1..c948a751bb039727394e97460a2a8e1fb4fd4f63 100644 --- a/common/AirQuality/package.json +++ b/common/AirQuality/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3", - "@ohos/hypium": "1.0.0" + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6", + "@ohos/hypium": "1.0.1" } } diff --git a/common/Clock/.gitignore b/common/Clock/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/common/Clock/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/common/Clock/README_zh.md b/common/Clock/README_zh.md index 6d134cd308d24f7e1f776098151d9fc75430ce5c..89ecc7a6c6e08b9180f5d24307309da42d3ba178 100644 --- a/common/Clock/README_zh.md +++ b/common/Clock/README_zh.md @@ -24,7 +24,7 @@ TextClock:TextClock组件通过文本将当前系统时间显示在设备上 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 3.如果安装本示例报错为error:install sign info inconsistent,则有可能本应用被设置为系统预置应用,已安装在系统中,此时需使用命令进行替换安装,并在替换安装后对设备进行重启操作,具体命令如下: diff --git a/common/Clock/entry/src/main/js/default/app.js b/common/Clock/entry/src/main/js/default/app.js index 58d12b7b501fbf46db906a86187aaf18dfb1f677..6d4065abcfbd0a337fbe6453e432981e7c70e9a6 100644 --- a/common/Clock/entry/src/main/js/default/app.js +++ b/common/Clock/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/common/Clock/entry/src/main/js/default/pages/index/index.hml b/common/Clock/entry/src/main/js/default/pages/index/index.hml index 61032a70c7f87e5b9c89575fe203e933c21b4c88..93effc73a3d606f9cd71b7fef929016381922bbd 100644 --- a/common/Clock/entry/src/main/js/default/pages/index/index.hml +++ b/common/Clock/entry/src/main/js/default/pages/index/index.hml @@ -14,14 +14,14 @@ -->
- - - - - - - {{ hour }}:{{ minute }}:{{ second }} + + + + + + + {{ hour }}:{{ minute }}:{{ second }}
\ No newline at end of file diff --git a/common/Clock/entry/src/main/js/default/pages/index/index.js b/common/Clock/entry/src/main/js/default/pages/index/index.js index ac1a561bec4d39b16abe80a51c5629c548f7810f..c43671bfd9a43dd8bb28ac629ef6152bf748d9e5 100644 --- a/common/Clock/entry/src/main/js/default/pages/index/index.js +++ b/common/Clock/entry/src/main/js/default/pages/index/index.js @@ -14,32 +14,32 @@ */ export default { - timer: undefined, - data: { - hour: 0, - minute: 0, - second: 0 - }, - onInit() { - this.updateTime(); - this.timer = setInterval(this.updateTime, 1000) - }, - updateTime: function () { - var nowTime = new Date() - this.hour = nowTime.getHours() - this.minute = nowTime.getMinutes() - this.second = nowTime.getSeconds() - if (this.hour < 10) { - this.hour = '0' + this.hour - } - if (this.minute < 10) { - this.minute = '0' + this.minute - } - if (this.second < 10) { - this.second = '0' + this.second - } - }, - onDestroy() { - clearInterval(this.timer) + timer: undefined, + data: { + hour: 0, + minute: 0, + second: 0 + }, + onInit() { + this.updateTime(); + this.timer = setInterval(this.updateTime, 1000) + }, + updateTime: function () { + var nowTime = new Date() + this.hour = nowTime.getHours() + this.minute = nowTime.getMinutes() + this.second = nowTime.getSeconds() + if (this.hour < 10) { + this.hour = '0' + this.hour } + if (this.minute < 10) { + this.minute = '0' + this.minute + } + if (this.second < 10) { + this.second = '0' + this.second + } + }, + onDestroy() { + clearInterval(this.timer) + } } \ No newline at end of file diff --git a/common/Clock/package.json b/common/Clock/package.json index 8643303d7616588daae19a4317053b40de8b46da..a2e460b82bb21d757c32867de898b812b4530cc9 100644 --- a/common/Clock/package.json +++ b/common/Clock/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/common/DistributeCalc/.gitignore b/common/DistributeCalc/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/common/DistributeCalc/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/common/DistributeCalc/README_zh.md b/common/DistributeCalc/README_zh.md index bdb8adb7aeb41aed6edd68ea1e14e12a2fe22105..39bd180756d26671d54de550821661253e8560b9 100644 --- a/common/DistributeCalc/README_zh.md +++ b/common/DistributeCalc/README_zh.md @@ -40,7 +40,7 @@ 3.分布式计算功能使用的前提是分布式组网。 -4.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +4.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 5.本示例需要使用@ohos.distributedHardware.deviceManager系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 diff --git a/common/DistributeCalc/entry/src/main/js/MainAbility/app.js b/common/DistributeCalc/entry/src/main/js/MainAbility/app.js index e3a0891c0350ac6dec03b34963b6e570653355f2..e2e723dcb860a851fb8d1aa1e1a3e1dfa735110c 100644 --- a/common/DistributeCalc/entry/src/main/js/MainAbility/app.js +++ b/common/DistributeCalc/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/common/DistributeCalc/entry/src/main/js/MainAbility/common/RemoteDeviceModel.js b/common/DistributeCalc/entry/src/main/js/MainAbility/common/RemoteDeviceModel.js index 82cd0ad31ebcbcb17e4c986c9284973217efe8e7..ba3dd019329d3f3c532f77877e74094df7455015 100644 --- a/common/DistributeCalc/entry/src/main/js/MainAbility/common/RemoteDeviceModel.js +++ b/common/DistributeCalc/entry/src/main/js/MainAbility/common/RemoteDeviceModel.js @@ -19,171 +19,171 @@ import deviceManager from '@ohos.distributedHardware.deviceManager'; let SUBSCRIBE_ID = 100; export default class RemoteDeviceModel { - deviceList = []; - discoverList = []; - callback; - authCallback; - deviceManager = undefined; + deviceList = []; + discoverList = []; + callback; + authCallback; + deviceManager = undefined; - registerDeviceListCallback(callback) { - if (typeof (this.deviceManager) === 'undefined') { - console.log("Calc[RemoteDeviceModel] deviceManager.createDeviceManager begin"); - deviceManager.createDeviceManager("ohos.samples.distributedcalc", (error, value) => { - if (error) { - console.error("Calc[RemoteDeviceModel] createDeviceManager failed."); - return; - } - this.deviceManager = value; - this.registerDeviceListCallback_(callback); - console.log("Calc[RemoteDeviceModel] createDeviceManager callback returned, error=" + error + " value=" + value); - }); - console.log("Calc[RemoteDeviceModel] deviceManager.createDeviceManager end"); - } else { - this.registerDeviceListCallback_(callback); + registerDeviceListCallback(callback) { + if (typeof (this.deviceManager) === 'undefined') { + console.log("Calc[RemoteDeviceModel] deviceManager.createDeviceManager begin"); + deviceManager.createDeviceManager("ohos.samples.distributedcalc", (error, value) => { + if (error) { + console.error("Calc[RemoteDeviceModel] createDeviceManager failed."); + return; } + this.deviceManager = value; + this.registerDeviceListCallback_(callback); + console.log("Calc[RemoteDeviceModel] createDeviceManager callback returned, error=" + error + " value=" + value); + }); + console.log("Calc[RemoteDeviceModel] deviceManager.createDeviceManager end"); + } else { + this.registerDeviceListCallback_(callback); } + } - registerDeviceListCallback_(callback) { - console.info('Calc[RemoteDeviceModel] registerDeviceListCallback'); - this.callback = callback; - if (this.deviceManager === undefined) { - console.error('Calc[RemoteDeviceModel] deviceManager has not initialized'); - this.callback(); - return; - } + registerDeviceListCallback_(callback) { + console.info('Calc[RemoteDeviceModel] registerDeviceListCallback'); + this.callback = callback; + if (this.deviceManager === undefined) { + console.error('Calc[RemoteDeviceModel] deviceManager has not initialized'); + this.callback(); + return; + } - console.info('Calc[RemoteDeviceModel] getTrustedDeviceListSync begin'); - let list = this.deviceManager.getTrustedDeviceListSync(); - console.info('Calc[RemoteDeviceModel] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list)); - if (typeof (list) !== 'undefined' && typeof (list.length) !== 'undefined') { - this.deviceList = list; - } - this.callback(); - console.info('Calc[RemoteDeviceModel] callback finished'); + console.info('Calc[RemoteDeviceModel] getTrustedDeviceListSync begin'); + let list = this.deviceManager.getTrustedDeviceListSync(); + console.info('Calc[RemoteDeviceModel] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list)); + if (typeof (list) !== 'undefined' && typeof (list.length) !== 'undefined') { + this.deviceList = list; + } + this.callback(); + console.info('Calc[RemoteDeviceModel] callback finished'); - this.deviceManager.on('deviceStateChange', (data) => { - console.info('Calc[RemoteDeviceModel] deviceStateChange data=' + JSON.stringify(data)); - switch (data.action) { - case 0: - this.deviceList[this.deviceList.length] = data.device; - console.info('Calc[RemoteDeviceModel] online, updated device list=' + JSON.stringify(this.deviceList)); - this.callback(); - if (this.authCallback != null) { - this.authCallback(); - this.authCallback = null; - } - break; - case 2: - if (this.deviceList.length > 0) { - for (let i = 0; i < this.deviceList.length; i++) { - if (this.deviceList[i].deviceId === data.device.deviceId) { - this.deviceList[i] = data.device; - break; - } - } - } - console.info('Calc[RemoteDeviceModel] change, updated device list=' + JSON.stringify(this.deviceList)); - this.callback(); + this.deviceManager.on('deviceStateChange', (data) => { + console.info('Calc[RemoteDeviceModel] deviceStateChange data=' + JSON.stringify(data)); + switch (data.action) { + case 0: + this.deviceList[this.deviceList.length] = data.device; + console.info('Calc[RemoteDeviceModel] online, updated device list=' + JSON.stringify(this.deviceList)); + this.callback(); + if (this.authCallback != null) { + this.authCallback(); + this.authCallback = null; + } + break; + case 2: + if (this.deviceList.length > 0) { + for (let i = 0; i < this.deviceList.length; i++) { + if (this.deviceList[i].deviceId === data.device.deviceId) { + this.deviceList[i] = data.device; break; - case 1: - if (this.deviceList.length > 0) { - let list = []; - for (let j = 0; j < this.deviceList.length; j++) { - if (this.deviceList[j].deviceId != data.device.deviceId) { - list[j] = data.device; - } - } - this.deviceList = list; - } - console.info('Calc[RemoteDeviceModel] offline, updated device list=' + JSON.stringify(data.device)); - this.callback(); - break; - default: - break; + } } - }); - this.deviceManager.on('deviceFound', (data) => { - console.info('Calc[RemoteDeviceModel] deviceFound data=' + JSON.stringify(data)); - console.info('Calc[RemoteDeviceModel] deviceFound this.discoverList=' + this.discoverList); - for (let i = 0;i < this.discoverList.length; i++) { - if (this.discoverList[i].deviceId === data.device.deviceId) { - console.info('Calc[RemoteDeviceModel] device founded ignored'); - return; - } + } + console.info('Calc[RemoteDeviceModel] change, updated device list=' + JSON.stringify(this.deviceList)); + this.callback(); + break; + case 1: + if (this.deviceList.length > 0) { + let list = []; + for (let j = 0; j < this.deviceList.length; j++) { + if (this.deviceList[j].deviceId != data.device.deviceId) { + list[j] = data.device; + } } - this.discoverList[this.discoverList.length] = data.device; - console.info('Calc[RemoteDeviceModel] deviceFound this.discoverList=' + this.discoverList); - this.callback(); - }); - this.deviceManager.on('discoverFail', (data) => { - prompt.showToast({ - message: 'discoverFail reason=' + data.reason, - duration: 3000, - }); - console.info('Calc[RemoteDeviceModel] discoverFail data=' + JSON.stringify(data)); - }); - this.deviceManager.on('serviceDie', () => { - prompt.showToast({ - message: 'serviceDie', - duration: 3000, - }); - console.error('Calc[RemoteDeviceModel] serviceDie'); - }); + this.deviceList = list; + } + console.info('Calc[RemoteDeviceModel] offline, updated device list=' + JSON.stringify(data.device)); + this.callback(); + break; + default: + break; + } + }); + this.deviceManager.on('deviceFound', (data) => { + console.info('Calc[RemoteDeviceModel] deviceFound data=' + JSON.stringify(data)); + console.info('Calc[RemoteDeviceModel] deviceFound this.discoverList=' + this.discoverList); + for (let i = 0;i < this.discoverList.length; i++) { + if (this.discoverList[i].deviceId === data.device.deviceId) { + console.info('Calc[RemoteDeviceModel] device founded ignored'); + return; + } + } + this.discoverList[this.discoverList.length] = data.device; + console.info('Calc[RemoteDeviceModel] deviceFound this.discoverList=' + this.discoverList); + this.callback(); + }); + this.deviceManager.on('discoverFail', (data) => { + prompt.showToast({ + message: 'discoverFail reason=' + data.reason, + duration: 3000, + }); + console.info('Calc[RemoteDeviceModel] discoverFail data=' + JSON.stringify(data)); + }); + this.deviceManager.on('serviceDie', () => { + prompt.showToast({ + message: 'serviceDie', + duration: 3000, + }); + console.error('Calc[RemoteDeviceModel] serviceDie'); + }); - SUBSCRIBE_ID = Math.floor(65536 * Math.random()); - let info = { - subscribeId: SUBSCRIBE_ID, - mode: 0xAA, - medium: 2, - freq: 2, - isSameAccount: false, - isWakeRemote: true, - capability: 0 - }; - console.info('Calc[RemoteDeviceModel] startDeviceDiscovery ' + SUBSCRIBE_ID); - this.deviceManager.startDeviceDiscovery(info); + SUBSCRIBE_ID = Math.floor(65536 * Math.random()); + let info = { + subscribeId: SUBSCRIBE_ID, + mode: 0xAA, + medium: 2, + freq: 2, + isSameAccount: false, + isWakeRemote: true, + capability: 0 + }; + console.info('Calc[RemoteDeviceModel] startDeviceDiscovery ' + SUBSCRIBE_ID); + this.deviceManager.startDeviceDiscovery(info); + } + + unregisterDeviceListCallback() { + console.info('Calc[RemoteDeviceModel] stopDeviceDiscovery ' + SUBSCRIBE_ID); + if (this.deviceManager === undefined) { + return } + this.deviceManager.stopDeviceDiscovery(SUBSCRIBE_ID); + this.deviceManager.off('deviceStateChange'); + this.deviceManager.off('deviceFound'); + this.deviceManager.off('discoverFail'); + this.deviceManager.off('serviceDie'); + this.deviceList = []; + } - unregisterDeviceListCallback() { - console.info('Calc[RemoteDeviceModel] stopDeviceDiscovery ' + SUBSCRIBE_ID); + authenticateDevice(device, callBack) { + console.info('Calc[RemoteDeviceModel] authenticateDevice ' + JSON.stringify(device)); + for (let i = 0; i < this.discoverList.length; i++) { + if (this.discoverList[i].deviceId === device.deviceId) { + let extraInfo = { + 'targetPkgName': 'ohos.samples.distributedcalc', + 'appName': 'Distributed Calc', + 'appDescription': 'Distributed Calc', + 'business': '0' + }; + let authParam = { + 'authType': 1, + 'extraInfo': extraInfo + }; if (this.deviceManager === undefined) { return } - this.deviceManager.stopDeviceDiscovery(SUBSCRIBE_ID); - this.deviceManager.off('deviceStateChange'); - this.deviceManager.off('deviceFound'); - this.deviceManager.off('discoverFail'); - this.deviceManager.off('serviceDie'); - this.deviceList = []; - } - - authenticateDevice(device, callBack) { - console.info('Calc[RemoteDeviceModel] authenticateDevice ' + JSON.stringify(device)); - for (let i = 0; i < this.discoverList.length; i++) { - if (this.discoverList[i].deviceId === device.deviceId) { - let extraInfo = { - 'targetPkgName': 'ohos.samples.distributedcalc', - 'appName': 'Distributed Calc', - 'appDescription': 'Distributed Calc', - 'business': '0' - }; - let authParam = { - 'authType': 1, - 'extraInfo': extraInfo - }; - if (this.deviceManager === undefined) { - return - } - this.deviceManager.authenticateDevice(device, authParam, (err, data) => { - if (err) { - console.info('Calc[RemoteDeviceModel] authenticateDevice error:' + JSON.stringify(err)); - this.authCallback = null; - return; - } - console.info('Calc[RemoteDeviceModel] authenticateDevice succeed:' + JSON.stringify(data)); - this.authCallback = callBack; - }) - } - } + this.deviceManager.authenticateDevice(device, authParam, (err, data) => { + if (err) { + console.info('Calc[RemoteDeviceModel] authenticateDevice error:' + JSON.stringify(err)); + this.authCallback = null; + return; + } + console.info('Calc[RemoteDeviceModel] authenticateDevice succeed:' + JSON.stringify(data)); + this.authCallback = callBack; + }) + } } + } } \ No newline at end of file diff --git a/common/DistributeCalc/entry/src/main/js/MainAbility/common/calculator.js b/common/DistributeCalc/entry/src/main/js/MainAbility/common/calculator.js index ffbb349cf5a1650cda2463531c41eba562455dd8..ffefbd3881eae41221285746ad3e471d8469397f 100644 --- a/common/DistributeCalc/entry/src/main/js/MainAbility/common/calculator.js +++ b/common/DistributeCalc/entry/src/main/js/MainAbility/common/calculator.js @@ -14,162 +14,162 @@ */ const OperatorLevels = { - '+': 0, - '-': 0, - '*': 1, - '/': 1, + '+': 0, + '-': 0, + '*': 1, + '/': 1, }; const OperatorHandlers = { - '+': (one, other) => (parseFloat(one) + parseFloat(other)).toFixed(getFloatNum(one, other, '+')), - '-': (one, other) => (one - other).toFixed(getFloatNum(one, other, '-')), - '*': (one, other) => (one * other).toFixed(getFloatNum(one, other, '*')), - '/': (one, other) => (one / other).toFixed(getFloatNum(one, other, '/')), + '+': (one, other) => (parseFloat(one) + parseFloat(other)).toFixed(getFloatNum(one, other, '+')), + '-': (one, other) => (one - other).toFixed(getFloatNum(one, other, '-')), + '*': (one, other) => (one * other).toFixed(getFloatNum(one, other, '*')), + '/': (one, other) => (one / other).toFixed(getFloatNum(one, other, '/')), }; function getFloatNum(one, other, oprate) { - let num = 0; - let s1 = (new String(one)).toString(); - let s2 = (new String(other)).toString(); - let num1 = 0; - if (s1.indexOf('.') !== -1) { - num1 = s1.split('.')[1].length; - } - let num2 = 0; - if (s2.indexOf('.') !== -1) { - num2 = s2.split('.')[1].length; - } - if (oprate === '+' || oprate === '-') { - num = Math.max(num1, num2); - } - if (oprate === '*') { - num = num1 + num2; - } - if (oprate === '/') { - num = (num1 + s2.length) > 3 ? (num1 + s2.length) : 3; - } - return num; + let num = 0; + let s1 = (new String(one)).toString(); + let s2 = (new String(other)).toString(); + let num1 = 0; + if (s1.indexOf('.') !== -1) { + num1 = s1.split('.')[1].length; + } + let num2 = 0; + if (s2.indexOf('.') !== -1) { + num2 = s2.split('.')[1].length; + } + if (oprate === '+' || oprate === '-') { + num = Math.max(num1, num2); + } + if (oprate === '*') { + num = num1 + num2; + } + if (oprate === '/') { + num = (num1 + s2.length) > 3 ? (num1 + s2.length) : 3; + } + return num; } function calcSuffixExpression(expression) { - const numberStack = []; + const numberStack = []; - while (expression.length) { - let element = expression.shift(); - if (!isOperator(element)) { - numberStack.push(element); - } else { - const one = numberStack.pop(); - const other = numberStack.pop(); - const result = OperatorHandlers[element](other, one); - if (result.length > 15) { - numberStack.push(parseFloat(result).toExponential()); - } else { - numberStack.push(result); - } - } + while (expression.length) { + let element = expression.shift(); + if (!isOperator(element)) { + numberStack.push(element); + } else { + const one = numberStack.pop(); + const other = numberStack.pop(); + const result = OperatorHandlers[element](other, one); + if (result.length > 15) { + numberStack.push(parseFloat(result).toExponential()); + } else { + numberStack.push(result); + } } - return numberStack[0]; + } + return numberStack[0]; } function toSuffixExpression(expression) { - const operatorStack = []; - const suffixExpression = []; - let topOperator; - for (let idx = 0, size = expression.length; idx < size; idx++) { - const element = expression[idx]; - if (element === '(') { - operatorStack.push(element); - continue; - } - if (element === ')') { - if (operatorStack.length) { - let operator = operatorStack.pop(); - while (operator !== '(') { - suffixExpression.push(operator); - operator = operatorStack.pop(); - } - } - continue; - } - if (isOperator(element)) { - if (!operatorStack.length) { - operatorStack.push(element); - } else { - topOperator = operatorStack[operatorStack.length - 1]; - if (!isGrouping(topOperator) && !isPrioritized(element, topOperator)) { - suffixExpression.push(operatorStack.pop()); - } - operatorStack.push(element); - } - continue; + const operatorStack = []; + const suffixExpression = []; + let topOperator; + for (let idx = 0, size = expression.length; idx < size; idx++) { + const element = expression[idx]; + if (element === '(') { + operatorStack.push(element); + continue; + } + if (element === ')') { + if (operatorStack.length) { + let operator = operatorStack.pop(); + while (operator !== '(') { + suffixExpression.push(operator); + operator = operatorStack.pop(); } - suffixExpression.push(element); + } + continue; } - while (operatorStack.length) { - suffixExpression.push(operatorStack.pop()); + if (isOperator(element)) { + if (!operatorStack.length) { + operatorStack.push(element); + } else { + topOperator = operatorStack[operatorStack.length - 1]; + if (!isGrouping(topOperator) && !isPrioritized(element, topOperator)) { + suffixExpression.push(operatorStack.pop()); + } + operatorStack.push(element); + } + continue; } - return suffixExpression; + suffixExpression.push(element); + } + while (operatorStack.length) { + suffixExpression.push(operatorStack.pop()); + } + return suffixExpression; } function parseInfixExpression(content) { - const size = content.length; - const lastIdx = size - 1; - let number = ''; - const expression = []; - for (let idx = 0; idx < size; idx++) { - const element = content[idx]; - if (isGrouping(element)) { - if (number !== '') { - expression.push(number); - number = ''; - } - expression.push(element); - } else if (isOperator(element)) { - if (isSymbol(element) && (idx === 0 || content[idx - 1] === '(')) { - number += element; - } else { - if (number !== '') { - expression.push(number); - number = ''; - } - - if (idx !== lastIdx) { - expression.push(element); - } - } - } else { - number += element; + const size = content.length; + const lastIdx = size - 1; + let number = ''; + const expression = []; + for (let idx = 0; idx < size; idx++) { + const element = content[idx]; + if (isGrouping(element)) { + if (number !== '') { + expression.push(number); + number = ''; + } + expression.push(element); + } else if (isOperator(element)) { + if (isSymbol(element) && (idx === 0 || content[idx - 1] === '(')) { + number += element; + } else { + if (number !== '') { + expression.push(number); + number = ''; } - if (idx === lastIdx && number !== '') { - expression.push(number); + if (idx !== lastIdx) { + expression.push(element); } + } + } else { + number += element; + } + + if (idx === lastIdx && number !== '') { + expression.push(number); } - return expression; + } + return expression; } function isPrioritized(one, other) { - return OperatorLevels[one] > OperatorLevels[other]; + return OperatorLevels[one] > OperatorLevels[other]; } export function isOperator(operator) { - return ( - operator === '+' || operator === '-' || operator === '*' || operator === '/' - ); + return ( + operator === '+' || operator === '-' || operator === '*' || operator === '/' + ); } function isSymbol(symbol) { - return symbol === '+' || symbol === '-'; + return symbol === '+' || symbol === '-'; } function isGrouping(operator) { - return operator === '(' || operator === ')'; + return operator === '(' || operator === ')'; } export function calc(content) { - const infixExpression = parseInfixExpression(content); - const suffixExpression = toSuffixExpression(infixExpression); - return calcSuffixExpression(suffixExpression); + const infixExpression = parseInfixExpression(content); + const suffixExpression = toSuffixExpression(infixExpression); + return calcSuffixExpression(suffixExpression); } diff --git a/common/DistributeCalc/entry/src/main/js/MainAbility/common/kvstoreModel.js b/common/DistributeCalc/entry/src/main/js/MainAbility/common/kvstoreModel.js index 5d148a4e91efcd22c1af82b4836e2dd085dc1f1c..ca7e2c9ee6bb9f9b3170882985a097ca8ec69033 100644 --- a/common/DistributeCalc/entry/src/main/js/MainAbility/common/kvstoreModel.js +++ b/common/DistributeCalc/entry/src/main/js/MainAbility/common/kvstoreModel.js @@ -17,84 +17,83 @@ import distributedData from '@ohos.data.distributedData'; const STORE_ID = 'distributedcalc'; export class KvStoreModel { - kvManager; - kvStore; + kvManager; + kvStore; - constructor() { - } + constructor() { + } - createKvStore(callback) { - if ((typeof (this.kvStore) !== 'undefined')) { - callback(); - return; - } - var config = { - bundleName: 'ohos.samples.distributedcalc', - userInfo: { - userId: '0', - userType: 0 - } - }; - console.info('[KvStoreModel] createKVManager begin'); - distributedData.createKVManager(config).then((manager) => { - console.info('[KvStoreModel] createKVManager success, kvManager=' + JSON.stringify(manager)); - this.kvManager = manager; - let options = { - createIfMissing: true, - encrypt: false, - backup: false, - autoSync: true, - kvStoreType: 1, - securityLevel: 1, - }; - console.info('[KvStoreModel] kvManager.getKVStore begin'); - this.kvManager.getKVStore(STORE_ID, options).then((store) => { - console.info('[KvStoreModel] getKVStore success, kvStore=' + store); - this.kvStore = store; - callback(); - }); - console.info('[KvStoreModel] kvManager.getKVStore end'); - }); - console.info('[KvStoreModel] createKVManager end'); + createKvStore(callback) { + if ((typeof (this.kvStore) !== 'undefined')) { + callback(); + return; } + var config = { + bundleName: 'ohos.samples.distributedcalc', + userInfo: { + userId: '0', + userType: 0 + } + }; + console.info('[KvStoreModel] createKVManager begin'); + distributedData.createKVManager(config).then((manager) => { + console.info('[KvStoreModel] createKVManager success, kvManager=' + JSON.stringify(manager)); + this.kvManager = manager; + let options = { + createIfMissing: true, + encrypt: false, + backup: false, + autoSync: true, + kvStoreType: 1, + securityLevel: 1, + }; + console.info('[KvStoreModel] kvManager.getKVStore begin'); + this.kvManager.getKVStore(STORE_ID, options).then((store) => { + console.info('[KvStoreModel] getKVStore success, kvStore=' + store); + this.kvStore = store; + callback(); + }); + console.info('[KvStoreModel] kvManager.getKVStore end'); + }); + console.info('[KvStoreModel] createKVManager end'); + } - put(key, value) { - console.info('[KvStoreModel] kvStore.put ' + key + '=' + value); - this.kvStore.put(key, value + 'end').then((data) => { - console.info('[KvStoreModel] kvStore.put ' + key + ' finished, data=' + JSON.stringify(data)); - }).catch((err) => { - console.error('[KvStoreModel] kvStore.put ' + key + ' failed, ' + JSON.stringify(err)); - }); - } + put(key, value) { + console.info('[KvStoreModel] kvStore.put ' + key + '=' + value); + this.kvStore.put(key, value + 'end').then((data) => { + console.info('[KvStoreModel] kvStore.put ' + key + ' finished, data=' + JSON.stringify(data)); + }).catch((err) => { + console.error('[KvStoreModel] kvStore.put ' + key + ' failed, ' + JSON.stringify(err)); + }); + } - off() { - if (this.kvStore !== null) { - this.kvStore.off('dataChange'); - }) - } + off() { + if (this.kvStore !== null) { + this.kvStore.off('dataChange') } + } - setOnMessageReceivedListener(msg, refreshdata) { - console.info('[KvStoreModel] setOnMessageReceivedListener ' + msg); - this.createKvStore(() => { - console.info('[KvStoreModel] kvStore.on(dataChange) begin'); - this.kvStore.on('dataChange', 1, (data) => { - console.info('[KvStoreModel] dataChange, ' + JSON.stringify(data)); - console.info('[KvStoreModel] dataChange, insert ' + data.insertEntries.length + ' udpate ' - + data.updateEntries.length); - let entries = data.insertEntries.length > 0 ? data.insertEntries : data.updateEntries; - for (let i = 0; i < entries.length; i++) { - if (entries[i].key === msg) { - let value = entries[i].value.value; - console.info('[KvStoreModel] Entries receive ' + msg + '=' + value); - let valueResult = value.substring(0, value.lastIndexOf('end')); - console.info('[KvStoreModel] Entries receive valueResult = ' + valueResult); - refreshdata(valueResult); - return; - } - } - }); - console.info('[KvStoreModel] kvStore.on(dataChange) end'); - }); - } + setOnMessageReceivedListener(msg, refreshdata) { + console.info('[KvStoreModel] setOnMessageReceivedListener ' + msg); + this.createKvStore(() => { + console.info('[KvStoreModel] kvStore.on(dataChange) begin'); + this.kvStore.on('dataChange', 1, (data) => { + console.info('[KvStoreModel] dataChange, ' + JSON.stringify(data)); + console.info('[KvStoreModel] dataChange, insert ' + data.insertEntries.length + ' udpate ' + + data.updateEntries.length); + let entries = data.insertEntries.length > 0 ? data.insertEntries : data.updateEntries; + for (let i = 0; i < entries.length; i++) { + if (entries[i].key === msg) { + let value = entries[i].value.value; + console.info('[KvStoreModel] Entries receive ' + msg + '=' + value); + let valueResult = value.substring(0, value.lastIndexOf('end')); + console.info('[KvStoreModel] Entries receive valueResult = ' + valueResult); + refreshdata(valueResult); + return; + } + } + }); + console.info('[KvStoreModel] kvStore.on(dataChange) end'); + }); + } } \ No newline at end of file diff --git a/common/DistributeCalc/entry/src/main/js/MainAbility/pages/index/index.hml b/common/DistributeCalc/entry/src/main/js/MainAbility/pages/index/index.hml index c52260a68054af40aa5f4650dcc60c2abafb6415..8c38ccb7ca92f2e46150615b7b6b3442fe402269 100644 --- a/common/DistributeCalc/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/common/DistributeCalc/entry/src/main/js/MainAbility/pages/index/index.hml @@ -14,100 +14,100 @@ limitations under the License. -->
-
- -
- - - {{ title }} - -
- -
- - {{ expression }} +
+ +
+ + + {{ title }} - - {{ result }} - -
-
- -
- 7 -
-
- 8 -
-
- 9 -
-
- -
-
- -
-
- 4 -
-
- 5 -
-
- 6 -
-
- -
-
- -
-
- 1 -
-
- 2 -
-
- 3 -
-
- -
-
- -
-
- 0 -
-
- . -
-
- -
-
-
- -
- 选择设备 - - -
- {{ $item.deviceName - }} - - -
-
-
- 取消 +
+ +
+ + {{ expression }} + + + {{ result }} + +
+
+ +
+ 7 +
+
+ 8 +
+
+ 9 +
+
+ +
+
+ +
+
+ 4 +
+
+ 5 +
+
+ 6 +
+
+ +
+
+ +
+
+ 1 +
+
+ 2 +
+
+ 3 +
+
+ +
+
+ +
+
+ 0 +
+
+ . +
+
+ +
+
+
+ +
+ 选择设备 + + +
+ {{ $item.deviceName + }} -
-
+ +
+ + + 取消 + +
+
\ No newline at end of file diff --git a/common/DistributeCalc/entry/src/main/js/MainAbility/pages/index/index.js b/common/DistributeCalc/entry/src/main/js/MainAbility/pages/index/index.js index fa812e2936a42b01877075e52feae6d7f765ad20..0aefb21e0ae921ac43eb83f59207037f58720186 100644 --- a/common/DistributeCalc/entry/src/main/js/MainAbility/pages/index/index.js +++ b/common/DistributeCalc/entry/src/main/js/MainAbility/pages/index/index.js @@ -25,263 +25,263 @@ let remoteDeviceModel = new RemoteDeviceModel() let timerId = 0 export default { - data: { - title: '计算器', - expression: '', - result: '', - selectedIndex: 0, - isFA: false, - isPush: false, - isDistributed: false, - deviceList: [] - }, - onInit() { - this.grantPermission() - this.$watch('expression', (value) => { - if (value !== '') { - console.info('Calc[IndexPage] value ' + value); - this.result = calc(value); - console.info('Calc[IndexPage] result = ' + this.result); - console.log('Calc[IndexPage] put key start'); - this.dataChange('expression', value); - } - }); - this.initKVManager(); - }, - onShow() { - featureAbility.getWant((error, want) => { - console.info('Calc[IndexPage] featureAbility.getWant =' + JSON.stringify(want.parameters)); - if (want.parameters.isFA === 'FA') { - this.isFA = true; - this.isDistributed = true; - } - }); - }, - grantPermission() { - console.info('Calc[IndexPage] grantPermission') - let context = featureAbility.getContext() - context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { - console.info(`Calc[IndexPage] grantPermission,requestPermissionsFromUser,result.requestCode=${result}`) - }) - }, - dataChange(key, value) { - console.log('Calc[IndexPage] dataChange isDistributed = ' + this.isDistributed); - if (this.isDistributed && kvStoreModel != null) { - kvStoreModel.put(key, value); - } - }, - initKVManager() { - kvStoreModel.setOnMessageReceivedListener('expression', (value) => { - console.log('Calc[IndexPage] data changed:' + value); - if (value === 'exit') { - console.info('Calc[CalcPage] app exit!'); - app.terminate(); - return; - } - if (value === 'clear') { - console.log('Calc[IndexPage] data expression:clear'); - this.expression = ''; - this.result = ''; - return; - } - if (value === 'equal') { - if (this.result !== '') { - console.log('Calc[IndexPage] data expression:equal'); - this.expression = this.result; - this.result = ''; - pressedEqual = true; - } - return; - } - this.expression = value; - pressedEqual = false; - console.log('Calc[IndexPage] data expression:' + this.expression); - }); - timerId = setInterval(() => { - if (this.isDistributed) { - let temp = this.expression; - this.expression = temp; - } - }, 200); - }, - stopDataListener() { - console.log('Calc[IndexPage] stopDataListener'); - if(kvStoreModel === null || kvStoreModel === undefined) { - return - } - kvStoreModel.off() - }, - onHide() { - if (remoteDeviceModel === undefined) { - return - } - remoteDeviceModel.unregisterDeviceListCallback(); - if (this.isDistributed && kvStoreModel != null) { - this.stopDataListener(); - this.isDistributed = false; - } - clearInterval(timerId) - kvStoreModel = null - remoteDeviceModel = undefined - }, - showDialog() { - console.info('Calc[IndexPage] showDialog start'); - this.deviceList = []; - if (remoteDeviceModel === undefined) { - remoteDeviceModel = new RemoteDeviceModel() - } - remoteDeviceModel.registerDeviceListCallback(() => { - console.info('Calc[IndexPage] registerDeviceListCallback on remote device updated, count=' - + remoteDeviceModel.deviceList.length); - let list = []; - list.push({ - deviceId: '0', - deviceName: 'Local device', - deviceType: 0, - networkId: '', - checked: this.selectedIndex === 0 - }); - let tempList = remoteDeviceModel.discoverList.length > 0 ? remoteDeviceModel.discoverList : remoteDeviceModel.deviceList; - for (let i = 0; i < tempList.length; i++) { - console.info('Calc[IndexPage] device ' + i + '/' + tempList.length - + ' deviceId=' + tempList[i].deviceId + ' deviceName=' + tempList[i].deviceName - + ' deviceType=' + tempList[i].deviceType); - list.push({ - deviceId: tempList[i].deviceId, - deviceName: tempList[i].deviceName, - deviceType: tempList[i].deviceType, - networkId: tempList[i].networkId, - checked: this.selectedIndex === (i + 1) - }); - } - this.deviceList = list; - this.$element('showDialog').close(); - this.$element('showDialog').show(); - }); - }, - cancelDialog() { - this.$element('showDialog').close(); - if(remoteDeviceModel === undefined) { - return; - } - remoteDeviceModel.unregisterDeviceListCallback(); - }, - - selectDevice(item) { - let index = this.deviceList.indexOf(item); - console.log('Calc[IndexPage] select index:' + index); - console.log('Calc[IndexPage] select selectedIndex:' + this.selectedIndex); - if (index === this.selectedIndex) { - console.log('Calc[IndexPage] index === this.selectedIndex'); - return; - } - this.selectedIndex = index; - if (index === 0) { - console.log('Calc[IndexPage] stop ability'); - this.dataChange('expression', 'exit'); - this.isDistributed = false; - this.stopDataListener(); - this.clearSelectState(); - return; - } - console.log('Calc[IndexPage] start ability ......'); + data: { + title: '计算器', + expression: '', + result: '', + selectedIndex: 0, + isFA: false, + isPush: false, + isDistributed: false, + deviceList: [] + }, + onInit() { + this.grantPermission() + this.$watch('expression', (value) => { + if (value !== '') { + console.info('Calc[IndexPage] value ' + value); + this.result = calc(value); + console.info('Calc[IndexPage] result = ' + this.result); + console.log('Calc[IndexPage] put key start'); + this.dataChange('expression', value); + } + }); + this.initKVManager(); + }, + onShow() { + featureAbility.getWant((error, want) => { + console.info('Calc[IndexPage] featureAbility.getWant =' + JSON.stringify(want.parameters)); + if (want.parameters.isFA === 'FA') { + this.isFA = true; this.isDistributed = true; - if (remoteDeviceModel === undefined || remoteDeviceModel.discoverList.length <= 0) { - console.log('Calc[IndexPage] continue device:' + JSON.stringify(this.deviceList)); - this.startAbility(this.deviceList[index].deviceId); - this.clearSelectState(); - return; - } - console.log('Calc[IndexPage] start ability1, needAuth'); - remoteDeviceModel.authenticateDevice(this.deviceList[index], () => { - console.log('Calc[IndexPage] auth and online finished'); - this.startAbility(this.deviceList[index].deviceId); - }); - this.clearSelectState(); - console.log('Calc[IndexPage] start ability end....'); - }, - clearSelectState() { - this.deviceList = []; - this.$element('showDialog').close(); - }, - async startAbility(deviceId) { - console.log('Calc[IndexPage] startAbility deviceId:' + deviceId); - await featureAbility.startAbility({ - want: { - bundleName: 'ohos.samples.distributedcalc', - abilityName: 'ohos.samples.distributedcalc.MainAbility', - deviceId: deviceId, - parameters: { - isFA: 'FA' - } - } - }) - console.log('Calc[IndexPage] start ability finished'); - this.dataChange('expression', this.expression); - console.log('Calc[IndexPage] startAbility end'); - }, - handleClear() { + } + }); + }, + grantPermission() { + console.info('Calc[IndexPage] grantPermission') + let context = featureAbility.getContext() + context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { + console.info(`Calc[IndexPage] grantPermission,requestPermissionsFromUser,result.requestCode=${result}`) + }) + }, + dataChange(key, value) { + console.log('Calc[IndexPage] dataChange isDistributed = ' + this.isDistributed); + if (this.isDistributed && kvStoreModel != null) { + kvStoreModel.put(key, value); + } + }, + initKVManager() { + kvStoreModel.setOnMessageReceivedListener('expression', (value) => { + console.log('Calc[IndexPage] data changed:' + value); + if (value === 'exit') { + console.info('Calc[CalcPage] app exit!'); + app.terminate(); + return; + } + if (value === 'clear') { + console.log('Calc[IndexPage] data expression:clear'); this.expression = ''; this.result = ''; - console.log('Calc[IndexPage] handleClear'); - this.dataChange('expression', 'clear'); - }, - handleInput(value) { - console.log('Calc[IndexPage] handle input value:' + value); - this.isPush = false; - if (isOperator(value)) { - if (pressedEqual) { - pressedEqual = false; - } else { - const size = this.expression.length; - if (size) { - const last = this.expression.charAt(size - 1); - if (isOperator(last)) { - this.expression = this.expression.substring(0, this.expression.length - 1); - } - } - } - if (!this.expression && (value === '*' || value === '/')) { - return; - } - this.expression += value; - } else { - if (pressedEqual) { - pressedEqual = false; - } - this.expression += value; + return; + } + if (value === 'equal') { + if (this.result !== '') { + console.log('Calc[IndexPage] data expression:equal'); + this.expression = this.result; + this.result = ''; + pressedEqual = true; } + return; + } + this.expression = value; + pressedEqual = false; + console.log('Calc[IndexPage] data expression:' + this.expression); + }); + timerId = setInterval(() => { + if (this.isDistributed) { + let temp = this.expression; + this.expression = temp; + } + }, 200); + }, + stopDataListener() { + console.log('Calc[IndexPage] stopDataListener'); + if (kvStoreModel === null || kvStoreModel === undefined) { + return + } + kvStoreModel.off() + }, + onHide() { + if (remoteDeviceModel === undefined) { + return + } + remoteDeviceModel.unregisterDeviceListCallback(); + if (this.isDistributed && kvStoreModel != null) { + this.stopDataListener(); + this.isDistributed = false; + } + clearInterval(timerId) + kvStoreModel = null + remoteDeviceModel = undefined + }, + showDialog() { + console.info('Calc[IndexPage] showDialog start'); + this.deviceList = []; + if (remoteDeviceModel === undefined) { + remoteDeviceModel = new RemoteDeviceModel() + } + remoteDeviceModel.registerDeviceListCallback(() => { + console.info('Calc[IndexPage] registerDeviceListCallback on remote device updated, count=' + + remoteDeviceModel.deviceList.length); + let list = []; + list.push({ + deviceId: '0', + deviceName: 'Local device', + deviceType: 0, + networkId: '', + checked: this.selectedIndex === 0 + }); + let tempList = remoteDeviceModel.discoverList.length > 0 ? remoteDeviceModel.discoverList : remoteDeviceModel.deviceList; + for (let i = 0; i < tempList.length; i++) { + console.info('Calc[IndexPage] device ' + i + '/' + tempList.length + + ' deviceId=' + tempList[i].deviceId + ' deviceName=' + tempList[i].deviceName + + ' deviceType=' + tempList[i].deviceType); + list.push({ + deviceId: tempList[i].deviceId, + deviceName: tempList[i].deviceName, + deviceType: tempList[i].deviceType, + networkId: tempList[i].networkId, + checked: this.selectedIndex === (i + 1) + }); + } + this.deviceList = list; + this.$element('showDialog').close(); + this.$element('showDialog').show(); + }); + }, + cancelDialog() { + this.$element('showDialog').close(); + if (remoteDeviceModel === undefined) { + return; + } + remoteDeviceModel.unregisterDeviceListCallback(); + }, - }, - handleBackspace() { - if (pressedEqual) { - this.expression = ''; - this.result = ''; - pressedEqual = false; - console.log('Calc[IndexPage] handleBackspace1'); - this.dataChange('expression', 'clear'); - } else { - this.isPush = false; - this.expression = this.expression.substring(0, this.expression.length - 1); - if (!this.expression.length) { - this.result = ''; - console.log('Calc[IndexPage] handleBackspace2'); - this.dataChange('expression', 'clear'); - } + selectDevice(item) { + let index = this.deviceList.indexOf(item); + console.log('Calc[IndexPage] select index:' + index); + console.log('Calc[IndexPage] select selectedIndex:' + this.selectedIndex); + if (index === this.selectedIndex) { + console.log('Calc[IndexPage] index === this.selectedIndex'); + return; + } + this.selectedIndex = index; + if (index === 0) { + console.log('Calc[IndexPage] stop ability'); + this.dataChange('expression', 'exit'); + this.isDistributed = false; + this.stopDataListener(); + this.clearSelectState(); + return; + } + console.log('Calc[IndexPage] start ability ......'); + this.isDistributed = true; + if (remoteDeviceModel === undefined || remoteDeviceModel.discoverList.length <= 0) { + console.log('Calc[IndexPage] continue device:' + JSON.stringify(this.deviceList)); + this.startAbility(this.deviceList[index].deviceId); + this.clearSelectState(); + return; + } + console.log('Calc[IndexPage] start ability1, needAuth'); + remoteDeviceModel.authenticateDevice(this.deviceList[index], () => { + console.log('Calc[IndexPage] auth and online finished'); + this.startAbility(this.deviceList[index].deviceId); + }); + this.clearSelectState(); + console.log('Calc[IndexPage] start ability end....'); + }, + clearSelectState() { + this.deviceList = []; + this.$element('showDialog').close(); + }, + async startAbility(deviceId) { + console.log('Calc[IndexPage] startAbility deviceId:' + deviceId); + await featureAbility.startAbility({ + want: { + bundleName: 'ohos.samples.distributedcalc', + abilityName: 'ohos.samples.distributedcalc.MainAbility', + deviceId: deviceId, + parameters: { + isFA: 'FA' } - }, - handleEqual() { - if (this.result !== '') { - this.isPush = true; - this.expression = this.result; - this.result = ''; - pressedEqual = true; - console.log('Calc[IndexPage] handleEqual'); - this.dataChange('expression', 'equal'); + } + }) + console.log('Calc[IndexPage] start ability finished'); + this.dataChange('expression', this.expression); + console.log('Calc[IndexPage] startAbility end'); + }, + handleClear() { + this.expression = ''; + this.result = ''; + console.log('Calc[IndexPage] handleClear'); + this.dataChange('expression', 'clear'); + }, + handleInput(value) { + console.log('Calc[IndexPage] handle input value:' + value); + this.isPush = false; + if (isOperator(value)) { + if (pressedEqual) { + pressedEqual = false; + } else { + const size = this.expression.length; + if (size) { + const last = this.expression.charAt(size - 1); + if (isOperator(last)) { + this.expression = this.expression.substring(0, this.expression.length - 1); + } } - }, - handleExist() { - console.log('Calc[IndexPage] handleExist'); - app.terminate(); + } + if (!this.expression && (value === '*' || value === '/')) { + return; + } + this.expression += value; + } else { + if (pressedEqual) { + pressedEqual = false; + } + this.expression += value; + } + + }, + handleBackspace() { + if (pressedEqual) { + this.expression = ''; + this.result = ''; + pressedEqual = false; + console.log('Calc[IndexPage] handleBackspace1'); + this.dataChange('expression', 'clear'); + } else { + this.isPush = false; + this.expression = this.expression.substring(0, this.expression.length - 1); + if (!this.expression.length) { + this.result = ''; + console.log('Calc[IndexPage] handleBackspace2'); + this.dataChange('expression', 'clear'); + } + } + }, + handleEqual() { + if (this.result !== '') { + this.isPush = true; + this.expression = this.result; + this.result = ''; + pressedEqual = true; + console.log('Calc[IndexPage] handleEqual'); + this.dataChange('expression', 'equal'); } + }, + handleExist() { + console.log('Calc[IndexPage] handleExist'); + app.terminate(); + } }; \ No newline at end of file diff --git a/common/ECG/.gitignore b/common/ECG/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/common/ECG/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/common/ECG/README_zh.md b/common/ECG/README_zh.md index 9c156c5ff0d379451187017e5472f82cf7b31f85..9a5d060f4700b3aee5f3cf20fb758a11f9ffc13e 100644 --- a/common/ECG/README_zh.md +++ b/common/ECG/README_zh.md @@ -22,7 +22,7 @@ Stack:堆叠容器,子组件按照顺序依次入栈,后一个子组件覆 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 3.如果安装本示例报错为error:install sign info inconsistent,则有可能本应用被设置为系统预置应用,已安装在系统中,此时需使用命令进行替换安装,并在替换安装后对设备进行重启操作,具体命令如下: diff --git a/common/ECG/entry/src/main/js/default/app.js b/common/ECG/entry/src/main/js/default/app.js index 58d12b7b501fbf46db906a86187aaf18dfb1f677..6d4065abcfbd0a337fbe6453e432981e7c70e9a6 100644 --- a/common/ECG/entry/src/main/js/default/app.js +++ b/common/ECG/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/common/ECG/entry/src/main/js/default/pages/index/index.css b/common/ECG/entry/src/main/js/default/pages/index/index.css index e5e9577f95273e413f4c2d6a00c48f780f012b08..e31ac9c103d13c0dce19906b9ed9cc5a47ed4c02 100644 --- a/common/ECG/entry/src/main/js/default/pages/index/index.css +++ b/common/ECG/entry/src/main/js/default/pages/index/index.css @@ -43,38 +43,46 @@ display: flex; flex-shrink: 1; } + .hundredImg { left: 100px; object-fit: contain; display: flex; flex-shrink: 1; } + .chart_t_r { width: 80px; height: 40px; color: #a6a6a6; } + .stack_main { width: 100%; height: 60%; flex-direction: column; justify-content: center; } + .chart_bg { width: 100%; height: 100%; } + .chart { width: 100%; height: 171px; } + .chart_time { text-align: center; color: white; } + font_size { font-size: 38px; } + .div_bottom { width: 100%; height: 20%; diff --git a/common/ECG/entry/src/main/js/default/pages/index/index.hml b/common/ECG/entry/src/main/js/default/pages/index/index.hml index 458d99130317f36e3a216da2a74063409899bb27..fa547a2f572b77072f09c6942ebf5b25e39058b8 100644 --- a/common/ECG/entry/src/main/js/default/pages/index/index.hml +++ b/common/ECG/entry/src/main/js/default/pages/index/index.hml @@ -13,22 +13,24 @@ limitations under the License. -->
-
- - - - - - {{ $t('strings.times_minute') }} - -
- - - - -
- - {{ chartTime }}{{ $t('strings.count_down') }} - -
+
+ + + + + + {{ $t('strings.times_minute') }} + +
+ + + + +
+ + {{ chartTime }}{{ $t('strings.count_down') }} + +
\ No newline at end of file diff --git a/common/ECG/entry/src/main/js/default/pages/index/index.js b/common/ECG/entry/src/main/js/default/pages/index/index.js index 325a11538d708741f6f82b9551ee6875a250fbc9..19a909fdfb50ed80f288f92c3a0a63253065beed 100644 --- a/common/ECG/entry/src/main/js/default/pages/index/index.js +++ b/common/ECG/entry/src/main/js/default/pages/index/index.js @@ -13,199 +13,207 @@ * limitations under the License. */ export default { - data: { - hundredImg: "/common/A054_110.png", - tensImg: "/common/A054_110.png", - onesImg: "/common/A054_110.png", - tensLeft: "100px", - onesLeft: "120px", - chartUnit: "170px", - hundredDisplay: "none", - realHrValue: 0, - moving: false, - leftNum: 0, - passTime: 0, - chartTime: 30, - chartHeartImg: '/common/A054_078.png', - isFill: false, - chartHeartInterval: '', - electrocardInterval: '', - heartDataInterval: '', - maskLeft: 454, - tipTop: "320px", - hideFlag: false, - isBreak: true, - digMaskLeft: 454, - times_minute: "", - ecgData: [ - 45,45,45,46,46,46,46,47,47,47, - 47,46,46,46,46,46,46,45,45,45, - 44,44,45,49,73,94,97,80,51,43, - 42,43,43,43,43,43,43,43,43,43, - 44,44,44,44,44,45,45,45,45,46, - 46,47,47,47,48,48,49,50,51,52, - 54,54,55,56,56,55,54,53,52,48, - 47,45,45,44,44,43,43,43,43,43, - 44,44,44,44,45,45,45,46,46,46, - 46,46,46,46,47,47,47,47,47,47 - ], - heartData: [70,78,80,89,90,85,95,99,101,106,118], - datasets: [ - { - strokeColor: '#fc3159', - data: [50] - } - ], - options: { - xAxis: { display: false, min: 0, max: 454}, - yAxis: { display: false, min: 0, max: 100}, - series: { - lineStyle: { - width: "5", - smooth: true - }, - headPoint: { - shape: 'circle', - size: '8px', - strokeColor: '#ffffff', - fillColor: '#ffffff', - }, - loop: { - margin: 30, - gradient: true - } - } + data: { + hundredImg: "/common/A054_110.png", + tensImg: "/common/A054_110.png", + onesImg: "/common/A054_110.png", + tensLeft: "100px", + onesLeft: "120px", + chartUnit: "170px", + hundredDisplay: "none", + realHrValue: 0, + moving: false, + leftNum: 0, + passTime: 0, + chartTime: 30, + chartHeartImg: '/common/A054_078.png', + isFill: false, + chartHeartInterval: '', + electrocardInterval: '', + heartDataInterval: '', + maskLeft: 454, + tipTop: "320px", + hideFlag: false, + isBreak: true, + digMaskLeft: 454, + times_minute: "", + ecgData: [ + 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, + 47, 46, 46, 46, 46, 46, 46, 45, 45, 45, + 44, 44, 45, 49, 73, 94, 97, 80, 51, 43, + 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 44, 44, 44, 44, 44, 45, 45, 45, 45, 46, + 46, 47, 47, 47, 48, 48, 49, 50, 51, 52, + 54, 54, 55, 56, 56, 55, 54, 53, 52, 48, + 47, 45, 45, 44, 44, 43, 43, 43, 43, 43, + 44, 44, 44, 44, 45, 45, 45, 46, 46, 46, + 46, 46, 46, 46, 47, 47, 47, 47, 47, 47 + ], + heartData: [70, 78, 80, 89, 90, 85, 95, 99, 101, 106, 118], + datasets: [ + { + strokeColor: '#fc3159', + data: [50] + } + ], + options: { + xAxis: { + display: false, min: 0, max: 454 + }, + yAxis: { + display: false, min: 0, max: 100 + }, + series: { + lineStyle: { + width: "5", + smooth: true + }, + headPoint: { + shape: 'circle', + size: '8px', + strokeColor: '#ffffff', + fillColor: '#ffffff', + }, + loop: { + margin: 30, + gradient: true } - }, - onInit() { - this.times_minute = this.$t('strings.times_minute'); - }, - onShow() { - this.startChartHeart(); - this.handleMeasureData(); - }, - onHide() { - console.log('onHide'); - this.clearChart() - this.clearTimes() - }, - handleMeasureData() { - this.updateElectrocarddiogram(); - this.updateHeart(); - }, - updateElectrocarddiogram() { - let minEcgIndex = 0; - let maxEcgIndex = 99; - let curEcgIndex = minEcgIndex; - this.electrocardInterval = setInterval(() => { - let arrayObj = []; - for (let i = 0; i < 13; i++) { - if (curEcgIndex == maxEcgIndex) { - curEcgIndex = minEcgIndex; - } else { - arrayObj.push(this.ecgData[curEcgIndex]); - curEcgIndex++; - } - } - this.addChartDate(arrayObj); - this.handleCountDown(); - }, 100); - }, - updateHeart() { - this.heartDataInterval = setInterval(() => { - this.realHrValue = this.heartData[Math.floor(Math.random() * this.heartData.length)]; - }, 1000); - }, - addChartDate(list) { - let appendDate = { serial: 0, data: list }; - this.$refs.chart.append(appendDate); - }, - handleCountDown() { - let countdownValue = 30; - this.passTime++; - if (this.passTime % 10 == 0) { - countdownValue -= (this.passTime / 10); - this.setRealHrValue(); - if (countdownValue > 0) { - if (countdownValue < 10) { - this.chartTime = '0' + countdownValue; - } else { - this.chartTime = countdownValue; - } - } else { - this.chartTime = 0; - } + } + } + }, + onInit() { + this.times_minute = this.$t('strings.times_minute'); + }, + onShow() { + this.startChartHeart(); + this.handleMeasureData(); + }, + onHide() { + console.log('onHide'); + this.clearChart() + this.clearTimes() + }, + handleMeasureData() { + this.updateElectrocarddiogram(); + this.updateHeart(); + }, + updateElectrocarddiogram() { + let minEcgIndex = 0; + let maxEcgIndex = 99; + let curEcgIndex = minEcgIndex; + this.electrocardInterval = setInterval(() => { + let arrayObj = []; + for (let i = 0; i < 13; i++) { + if (curEcgIndex == maxEcgIndex) { + curEcgIndex = minEcgIndex; + } else { + arrayObj.push(this.ecgData[curEcgIndex]); + curEcgIndex++; } - }, - setRealHrValue() { - let hundreds, tens, ones; - let realHrMin = 0; - let realHrMax = 255; - let doubleAvgHr = 2; - let threeAvgHr = 3; - let subIndexZero = 0; - let subIndexOne = 1; - let subIndexTwo = 2; - let subIndexEnd = 3; - if (this.realHrValue == realHrMin || this.realHrValue == realHrMax) { - this.initRealHrValue(); + } + this.addChartDate(arrayObj); + this.handleCountDown(); + }, 100); + }, + updateHeart() { + this.heartDataInterval = setInterval(() => { + this.realHrValue = this.heartData[Math.floor(Math.random() * this.heartData.length)]; + }, 1000); + }, + addChartDate(list) { + let appendDate = { + serial: 0, data: list + }; + this.$refs.chart.append(appendDate); + }, + handleCountDown() { + let countdownValue = 30; + this.passTime++; + if (this.passTime % 10 == 0) { + countdownValue -= (this.passTime / 10); + this.setRealHrValue(); + if (countdownValue > 0) { + if (countdownValue < 10) { + this.chartTime = '0' + countdownValue; } else { - this.times_minute = this.$t('strings.ecg_times_minute_many_id'); - let number = this.realHrValue.toString(); - if (number.length == doubleAvgHr) { - this.hundredDisplay = 'none'; - this.tensLeft = '100px'; - this.onesLeft = '120px'; - this.chartUnit = '170px'; - tens = number.substring(subIndexZero, subIndexOne); - ones = number.substring(subIndexOne, subIndexTwo); - this.tensImg = '/common/A054_10' + tens + '.png'; - this.onesImg = '/common/A054_10' + ones + '.png'; - } else if (number.length == threeAvgHr) { - this.hundredDisplay = 'block'; - this.tensLeft = '130px'; - this.onesLeft = '150px'; - this.chartUnit = '170px'; - hundreds = number.substring(subIndexZero, subIndexOne); - tens = number.substring(subIndexOne, subIndexTwo); - ones = number.substring(subIndexTwo, subIndexEnd); - this.hundredImg = '/common/A054_10' + hundreds + '.png'; - this.tensImg = '/common/A054_10' + tens + '.png'; - this.onesImg = '/common/A054_10' + ones + '.png'; - } else { - } + this.chartTime = countdownValue; } - }, - initRealHrValue() { + } else { + this.chartTime = 0; + } + } + }, + setRealHrValue() { + let hundreds, tens, ones; + let realHrMin = 0; + let realHrMax = 255; + let doubleAvgHr = 2; + let threeAvgHr = 3; + let subIndexZero = 0; + let subIndexOne = 1; + let subIndexTwo = 2; + let subIndexEnd = 3; + if (this.realHrValue == realHrMin || this.realHrValue == realHrMax) { + this.initRealHrValue(); + } else { + this.times_minute = this.$t('strings.ecg_times_minute_many_id'); + let number = this.realHrValue.toString(); + if (number.length == doubleAvgHr) { this.hundredDisplay = 'none'; this.tensLeft = '100px'; this.onesLeft = '120px'; this.chartUnit = '170px'; - this.tensImg = '/common/A054_110.png'; - this.onesImg = '/common/A054_110.png'; - }, - startChartHeart() { - let chartHeartIndex = 78; - let chartEndHeartIndex = 97; - let heartImgIndex = chartHeartIndex; - this.chartHeartInterval = setInterval(() => { - if (heartImgIndex == chartEndHeartIndex) { - heartImgIndex = chartHeartIndex; - } else { - this.chartHeartImg = '/common/A054_0' + heartImgIndex + '.png'; - heartImgIndex++; - } - }, 50); - }, - clearTimes() { - clearInterval(this.chartHeartInterval); - clearInterval(this.electrocardInterval); - clearInterval(this.heartDataInterval); - }, - clearChart() { - this.chartTime = 30; - this.datasets = [{ strokeColor: '#fc3159', data: [50]}]; + tens = number.substring(subIndexZero, subIndexOne); + ones = number.substring(subIndexOne, subIndexTwo); + this.tensImg = '/common/A054_10' + tens + '.png'; + this.onesImg = '/common/A054_10' + ones + '.png'; + } else if (number.length == threeAvgHr) { + this.hundredDisplay = 'block'; + this.tensLeft = '130px'; + this.onesLeft = '150px'; + this.chartUnit = '170px'; + hundreds = number.substring(subIndexZero, subIndexOne); + tens = number.substring(subIndexOne, subIndexTwo); + ones = number.substring(subIndexTwo, subIndexEnd); + this.hundredImg = '/common/A054_10' + hundreds + '.png'; + this.tensImg = '/common/A054_10' + tens + '.png'; + this.onesImg = '/common/A054_10' + ones + '.png'; + } else { + } } + }, + initRealHrValue() { + this.hundredDisplay = 'none'; + this.tensLeft = '100px'; + this.onesLeft = '120px'; + this.chartUnit = '170px'; + this.tensImg = '/common/A054_110.png'; + this.onesImg = '/common/A054_110.png'; + }, + startChartHeart() { + let chartHeartIndex = 78; + let chartEndHeartIndex = 97; + let heartImgIndex = chartHeartIndex; + this.chartHeartInterval = setInterval(() => { + if (heartImgIndex == chartEndHeartIndex) { + heartImgIndex = chartHeartIndex; + } else { + this.chartHeartImg = '/common/A054_0' + heartImgIndex + '.png'; + heartImgIndex++; + } + }, 50); + }, + clearTimes() { + clearInterval(this.chartHeartInterval); + clearInterval(this.electrocardInterval); + clearInterval(this.heartDataInterval); + }, + clearChart() { + this.chartTime = 30; + this.datasets = [{ + strokeColor: '#fc3159', data: [50] + }]; + } } diff --git a/common/ECG/package.json b/common/ECG/package.json index 22166ab829ee7ce188933fb11504dd77b670c92a..75cf93354a29c7516ebef4ace43ae790767001be 100644 --- a/common/ECG/package.json +++ b/common/ECG/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } \ No newline at end of file diff --git a/common/Flashlight/.gitignore b/common/Flashlight/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/common/Flashlight/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/common/Flashlight/README_zh.md b/common/Flashlight/README_zh.md index 6a2c773dab852b91e1ee8b8250c83615ebe261b7..0a5cf34eee0719b6af5db1e207f8497f365a4aff 100644 --- a/common/Flashlight/README_zh.md +++ b/common/Flashlight/README_zh.md @@ -22,7 +22,7 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 3.如果安装本示例报错为error:install sign info inconsistent,则有可能本应用被设置为系统预置应用,已安装在系统中,此时需使用命令进行替换安装,并在替换安装后对设备进行重启操作,具体命令如下: diff --git a/common/Flashlight/entry/src/main/js/default/app.js b/common/Flashlight/entry/src/main/js/default/app.js index 58d12b7b501fbf46db906a86187aaf18dfb1f677..6d4065abcfbd0a337fbe6453e432981e7c70e9a6 100644 --- a/common/Flashlight/entry/src/main/js/default/app.js +++ b/common/Flashlight/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/common/Flashlight/entry/src/main/js/default/pages/index/index.hml b/common/Flashlight/entry/src/main/js/default/pages/index/index.hml index d93af6f8938aae7fd178895a04d7f42fc0214b41..dc1e44eec033c33b4b4ecc70490a5ad65cc05ab1 100644 --- a/common/Flashlight/entry/src/main/js/default/pages/index/index.hml +++ b/common/Flashlight/entry/src/main/js/default/pages/index/index.hml @@ -13,9 +13,9 @@ limitations under the License. --> -
- - {{ time }} -
+
+ + {{ time }} +
\ No newline at end of file diff --git a/common/Flashlight/entry/src/main/js/default/pages/index/index.js b/common/Flashlight/entry/src/main/js/default/pages/index/index.js index 4be071386e1674b60ccd22f9862655b7c5f8d19d..2b9b391e44348df5e6dff429d664f13f27fadab3 100644 --- a/common/Flashlight/entry/src/main/js/default/pages/index/index.js +++ b/common/Flashlight/entry/src/main/js/default/pages/index/index.js @@ -15,43 +15,44 @@ import app from '@system.app'; export default { - data: { - lightShow: true, - time: '' - }, - onInit() { - setTimeout(() => { - app.terminate(); - }, 300000); - }, - onShow() { - this.refreshTime(); - }, - onDestroy() {}, - refreshTime() { - setTimeout(() => { - let nowTime = new Date(); - let minutes = nowTime.getMinutes(); - let hours = nowTime.getHours(); - let minStr = ''; - let hourStr = ''; - if (minutes < 10) { - minStr = '0' + minutes.toString(); - } else { - minStr = minutes.toString(); - } - if (hours < 10) { - hourStr = '0' + hours.toString(); - } else { - hourStr = hours.toString(); - } - this.time = hourStr + ':' + minStr; - this.refreshTime(); - }, 1000); - }, - changeMode() { - this.lightShow = !this.lightShow; - } + data: { + lightShow: true, + time: '' + }, + onInit() { + setTimeout(() => { + app.terminate(); + }, 300000); + }, + onShow() { + this.refreshTime(); + }, + onDestroy() { + }, + refreshTime() { + setTimeout(() => { + let nowTime = new Date(); + let minutes = nowTime.getMinutes(); + let hours = nowTime.getHours(); + let minStr = ''; + let hourStr = ''; + if (minutes < 10) { + minStr = '0' + minutes.toString(); + } else { + minStr = minutes.toString(); + } + if (hours < 10) { + hourStr = '0' + hours.toString(); + } else { + hourStr = hours.toString(); + } + this.time = hourStr + ':' + minStr; + this.refreshTime(); + }, 1000); + }, + changeMode() { + this.lightShow = !this.lightShow; + } } diff --git a/common/Flashlight/package.json b/common/Flashlight/package.json index 8533871251004303135bda6431d0dd789aa1b57d..9bc4425a1843fccd8f2f4a9cade7bbf5007cec4b 100644 --- a/common/Flashlight/package.json +++ b/common/Flashlight/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } -} \ No newline at end of file +} diff --git a/common/Runninglock/entry/src/main/ets/MainAbility/common/lockSwitch.ets b/common/Runninglock/entry/src/main/ets/MainAbility/common/lockSwitch.ets index 31836e2069ab6124f0c6b533ad6ad1e03ee774d1..5f64a9c28cc9d80439d8c7d3e1863f71a1324a1f 100644 --- a/common/Runninglock/entry/src/main/ets/MainAbility/common/lockSwitch.ets +++ b/common/Runninglock/entry/src/main/ets/MainAbility/common/lockSwitch.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import lock from '@ohos.runninglock' +import lock from '@ohos.runningLock' import Logger from '../util/Logger' const TAG: string = 'RunningLock' diff --git a/common/Runninglock/entry/src/main/ets/MainAbility/pages/index.ets b/common/Runninglock/entry/src/main/ets/MainAbility/pages/index.ets index 052dbd4f8371a7b95b1adc0e9cf749c2232e6ab2..89dd03c2fc499ceb4c74fdb1619908d5a38630ec 100644 --- a/common/Runninglock/entry/src/main/ets/MainAbility/pages/index.ets +++ b/common/Runninglock/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import lock from '@ohos.runninglock' +import lock from '@ohos.runningLock' import { LockSwitch } from '../common/lockSwitch' import Logger from '../util/Logger' diff --git a/data/DDMQuery/.gitignore b/data/DDMQuery/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/data/DDMQuery/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/data/DDMQuery/README_zh.md b/data/DDMQuery/README_zh.md index b95f7ef4f44b782c24a279faab6a960c804cc277..63141b716193fe7fdd3c4f26350694d38fd4ce4e 100644 --- a/data/DDMQuery/README_zh.md +++ b/data/DDMQuery/README_zh.md @@ -32,4 +32,4 @@ KvStoreResultSet:提供获取KVStore数据库结果集的方法,提供查询 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/data/DDMQuery/entry/src/main/ets/MainAbility/pages/Index.ets b/data/DDMQuery/entry/src/main/ets/MainAbility/pages/Index.ets index d65513a6833a30c899514d27903395520d0dd11f..54744183fcf9fab1f9d5e8c927e549865237fb43 100644 --- a/data/DDMQuery/entry/src/main/ets/MainAbility/pages/Index.ets +++ b/data/DDMQuery/entry/src/main/ets/MainAbility/pages/Index.ets @@ -19,9 +19,8 @@ import { TitleBar } from "../common/TitleBar" @Entry @Component struct Index { - build() { - Column(){ + Column() { TitleBar() Query() } diff --git a/data/DDMQuery/package.json b/data/DDMQuery/package.json index e6ddf8f92313258fc1fd797a01434d2ce2c7e8ec..ef64eda021fb16c93d01ba5dd7a3a9583e208f69 100644 --- a/data/DDMQuery/package.json +++ b/data/DDMQuery/package.json @@ -8,8 +8,8 @@ }, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } } diff --git a/device/Bluetooth/README_zh.md b/device/Bluetooth/README_zh.md index 59aa0e92e4b546279c3acd9fbbbd434510788841..f5af0a7fd139c7003047f8bd9e2514736c24494a 100644 --- a/device/Bluetooth/README_zh.md +++ b/device/Bluetooth/README_zh.md @@ -34,6 +34,6 @@ 2.本示例仅支持API9版本SDK,本示例涉及使用系统接口:cancelPairedDevice(),需要手动替换Full SDK才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。。 +3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 4.本示例所配置的权限ohos.permission.MANAGE_BLUETOOTH为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465))。 \ No newline at end of file diff --git a/device/Browser/AppScope/app.json5 b/device/Browser/AppScope/app.json5 index b8f840ab25eb43969d9ee1f87ef1b33931d9c111..88cbd21634fe38d4b05c52d03e02b464f5101187 100644 --- a/device/Browser/AppScope/app.json5 +++ b/device/Browser/AppScope/app.json5 @@ -1,6 +1,6 @@ { "app": { - "bundleName": "ohos.samples.browser1", + "bundleName": "ohos.samples.browser", "vendor": "samples", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/device/Browser/entry/src/main/resources/rawfile/favicon.ico b/device/Browser/entry/src/main/resources/rawfile/favicon.ico deleted file mode 100644 index fdc021cfebd1341e379d891a8218f4d299def273..0000000000000000000000000000000000000000 Binary files a/device/Browser/entry/src/main/resources/rawfile/favicon.ico and /dev/null differ diff --git a/device/DeviceManager/.gitignore b/device/DeviceManager/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/device/DeviceManager/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/device/DeviceManager/README_zh.md b/device/DeviceManager/README_zh.md index 0ec7811ced929ddd85d13dd398fb82a811e8b195..8d369a2f258d859f4bb878f81211205136af9d8d 100644 --- a/device/DeviceManager/README_zh.md +++ b/device/DeviceManager/README_zh.md @@ -28,6 +28,6 @@ 2.本示例仅支持标准系统上运行。 -3.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 4.本示例需要使用@ohos.distributedHardware.deviceManager系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 \ No newline at end of file diff --git a/media/ImageShow/entry/src/main/ets/pages/Index.ets b/media/ImageShow/entry/src/main/ets/pages/Index.ets index 8f5d898829f04010ab6998dd0448fe8a4d552a1e..c54898f0239232f27a6f07dbbe2710fbe83bead3 100644 --- a/media/ImageShow/entry/src/main/ets/pages/Index.ets +++ b/media/ImageShow/entry/src/main/ets/pages/Index.ets @@ -27,9 +27,9 @@ struct Index { @State isShowCamera: boolean = false @State isShowComment: boolean = true - async onPageShow() { + async aboutToAppear() { Logger.info(TAG, 'enter onPageShow') - if (router.getParams()['isShowCamera'] !== undefined && router.getParams()['isShowCamera'] !== null) { + if (router.getParams()['isShowCamera'] && router.getParams()['isShowCamera'] !== undefined && router.getParams()['isShowCamera'] !== null) { this.isShowCamera = router.getParams()['isShowCamera'] Logger.info(TAG, `this.isShowCamera = ${this.isShowCamera}`) } diff --git a/media/JsAudioPlayer/.gitignore b/media/JsAudioPlayer/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4222b99195171f6433f7abe1fecaf4121895cce4 --- /dev/null +++ b/media/JsAudioPlayer/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +/build-profile.json5 +/package-lock.json +/entry/package-lock.json \ No newline at end of file diff --git a/media/JsAudioPlayer/README_zh.md b/media/JsAudioPlayer/README_zh.md index 5d72e705edcd2bda97cf3fcc40c711f1236f072a..680f6a6f16e7aee7658877c157ec1e6eacfcae23 100644 --- a/media/JsAudioPlayer/README_zh.md +++ b/media/JsAudioPlayer/README_zh.md @@ -24,4 +24,4 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file diff --git a/media/JsAudioPlayer/entry/src/main/js/default/app.js b/media/JsAudioPlayer/entry/src/main/js/default/app.js index 58d12b7b501fbf46db906a86187aaf18dfb1f677..6d4065abcfbd0a337fbe6453e432981e7c70e9a6 100644 --- a/media/JsAudioPlayer/entry/src/main/js/default/app.js +++ b/media/JsAudioPlayer/entry/src/main/js/default/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/media/JsAudioPlayer/entry/src/main/js/default/common/PlayerModel.js b/media/JsAudioPlayer/entry/src/main/js/default/common/PlayerModel.js index 493058ffd04278ce79a4a8695cbd2525d1d933ca..ecc08a0cb2ad911a356f6bad540ef1233344f1dc 100644 --- a/media/JsAudioPlayer/entry/src/main/js/default/common/PlayerModel.js +++ b/media/JsAudioPlayer/entry/src/main/js/default/common/PlayerModel.js @@ -18,256 +18,256 @@ import fileIo from '@ohos.fileio' export class Playlist { - constructor() { - } + constructor() { + } - audioFiles = []; + audioFiles = []; } export class Song { - constructor(name, fileUri, duration) { - this.name = name; - this.fileUri = fileUri; - this.duration = duration; - } + constructor(name, fileUri, duration) { + this.name = name; + this.fileUri = fileUri; + this.duration = duration; + } } export default class PlayerModel { - isPlaying = false; - playlist = new Playlist; - index; - #player; - #statusChangedListener; - #playingProgressListener; - #intervalID; - #currentTimeMs = 0; + isPlaying = false; + playlist = new Playlist; + index; + #player; + #statusChangedListener; + #playingProgressListener; + #intervalID; + #currentTimeMs = 0; - constructor() { - this.#player = media.createAudioPlayer(); - this.initAudioPlayer() - console.info('MusicPlayer[PlayerModel] createAudioPlayer=' + this.#player); - } + constructor() { + this.#player = media.createAudioPlayer(); + this.initAudioPlayer() + console.info('MusicPlayer[PlayerModel] createAudioPlayer=' + this.#player); + } - initAudioPlayer() { - console.info('MusicPlayer[PlayerModel] initAudioPlayer begin'); - this.#player.on('error', () => { - console.error(`MusicPlayer[PlayerModel] player error`); - }); - this.#player.on('finish', () => { - console.log('MusicPlayer[PlayerModel] finish() callback is called'); - this.notifyPlayingStatus(false); - }); - this.#player.on('timeUpdate', () => { - console.log('MusicPlayer[PlayerModel] timeUpdate() callback is called ') - }); - console.info('MusicPlayer[PlayerModel] initAudioPlayer end'); - } + initAudioPlayer() { + console.info('MusicPlayer[PlayerModel] initAudioPlayer begin'); + this.#player.on('error', () => { + console.error(`MusicPlayer[PlayerModel] player error`); + }); + this.#player.on('finish', () => { + console.log('MusicPlayer[PlayerModel] finish() callback is called'); + this.notifyPlayingStatus(false); + }); + this.#player.on('timeUpdate', () => { + console.log('MusicPlayer[PlayerModel] timeUpdate() callback is called ') + }); + console.info('MusicPlayer[PlayerModel] initAudioPlayer end'); + } - release() { - if (typeof (this.#player) != 'undefined') { - console.info('MusicPlayer[PlayerModel] player.release begin'); - this.#player.release(); - console.info('MusicPlayer[PlayerModel] player.release end'); - this.#player = undefined; - } + release() { + if (typeof (this.#player) != 'undefined') { + console.info('MusicPlayer[PlayerModel] player.release begin'); + this.#player.release(); + console.info('MusicPlayer[PlayerModel] player.release end'); + this.#player = undefined; } + } - restorePlayingStatus(status, callback) { - console.info('MusicPlayer[PlayerModel] restorePlayingStatus ' + JSON.stringify(status)); - for (var i = 0; i < this.playlist.audioFiles.length; i++) { - if (this.playlist.audioFiles[i].fileUri === status.uri) { - console.info('MusicPlayer[PlayerModel] restore to index ' + i); - this.preLoad(i, () => { - this.play(status.seekTo, status.isPlaying); - console.info('MusicPlayer[PlayerModel] restore play status'); - callback(i); - }); - return; - } - } - console.warn('MusicPlayer[PlayerModel] restorePlayingStatus failed'); - callback(-1); + restorePlayingStatus(status, callback) { + console.info('MusicPlayer[PlayerModel] restorePlayingStatus ' + JSON.stringify(status)); + for (var i = 0; i < this.playlist.audioFiles.length; i++) { + if (this.playlist.audioFiles[i].fileUri === status.uri) { + console.info('MusicPlayer[PlayerModel] restore to index ' + i); + this.preLoad(i, () => { + this.play(status.seekTo, status.isPlaying); + console.info('MusicPlayer[PlayerModel] restore play status'); + callback(i); + }); + return; + } } + console.warn('MusicPlayer[PlayerModel] restorePlayingStatus failed'); + callback(-1); + } - getPlaylist(callback) { - // generate play list - console.info('MusicPlayer[PlayerModel] generatePlayList'); + getPlaylist(callback) { + // generate play list + console.info('MusicPlayer[PlayerModel] generatePlayList'); - console.info('MusicPlayer[PlayerModel] getAudioAssets begin'); - this.playlist = new Playlist(); - this.playlist.audioFiles = []; - this.playlist.audioFiles[0] = new Song('dynamic.wav', 'system/etc/dynamic.wav', 0); - this.playlist.audioFiles[1] = new Song('demo.wav', 'system/etc/demo.wav', 0); - callback() - console.info('MusicPlayer[PlayerModel] getAudioAssets end'); - } + console.info('MusicPlayer[PlayerModel] getAudioAssets begin'); + this.playlist = new Playlist(); + this.playlist.audioFiles = []; + this.playlist.audioFiles[0] = new Song('dynamic.wav', 'system/etc/dynamic.wav', 0); + this.playlist.audioFiles[1] = new Song('demo.wav', 'system/etc/demo.wav', 0); + callback() + console.info('MusicPlayer[PlayerModel] getAudioAssets end'); + } - setOnStatusChangedListener(callback) { - this.#statusChangedListener = callback; - } + setOnStatusChangedListener(callback) { + this.#statusChangedListener = callback; + } - setOnPlayingProgressListener(callback) { - this.#playingProgressListener = callback; - } + setOnPlayingProgressListener(callback) { + this.#playingProgressListener = callback; + } - notifyPlayingStatus(isPlaying) { - this.isPlaying = isPlaying; - this.#statusChangedListener(this.isPlaying); - console.log('MusicPlayer[PlayerModel] notifyPlayingStatus isPlaying=' + isPlaying + ' intervalId=' + this.#intervalID); - if (isPlaying) { - if (typeof (this.#intervalID) === 'undefined') { - let self = this; - this.#intervalID = setInterval(() => { - if (typeof (self.#playingProgressListener) != "undefined" && self.#playingProgressListener != null) { - var timeMs = self.#player.currentTime; - this.#currentTimeMs = timeMs; - if (typeof (timeMs) === 'undefined') { - timeMs = 0; - } - console.log('MusicPlayer[PlayerModel] player.currentTime=' + timeMs); - self.#playingProgressListener(timeMs); - } - }, 500); - console.log('MusicPlayer[PlayerModel] set update interval ' + this.#intervalID); + notifyPlayingStatus(isPlaying) { + this.isPlaying = isPlaying; + this.#statusChangedListener(this.isPlaying); + console.log('MusicPlayer[PlayerModel] notifyPlayingStatus isPlaying=' + isPlaying + ' intervalId=' + this.#intervalID); + if (isPlaying) { + if (typeof (this.#intervalID) === 'undefined') { + let self = this; + this.#intervalID = setInterval(() => { + if (typeof (self.#playingProgressListener) != "undefined" && self.#playingProgressListener != null) { + var timeMs = self.#player.currentTime; + this.#currentTimeMs = timeMs; + if (typeof (timeMs) === 'undefined') { + timeMs = 0; } - } else { - this.cancelTimer(); - } + console.log('MusicPlayer[PlayerModel] player.currentTime=' + timeMs); + self.#playingProgressListener(timeMs); + } + }, 500); + console.log('MusicPlayer[PlayerModel] set update interval ' + this.#intervalID); + } + } else { + this.cancelTimer(); } + } - cancelTimer() { - if (typeof (this.#intervalID) != 'undefined') { - console.log('MusicPlayer[PlayerModel] clear update interval ' + this.#intervalID); - clearInterval(this.#intervalID); - this.#intervalID = undefined; - } + cancelTimer() { + if (typeof (this.#intervalID) != 'undefined') { + console.log('MusicPlayer[PlayerModel] clear update interval ' + this.#intervalID); + clearInterval(this.#intervalID); + this.#intervalID = undefined; } + } - preLoad(index, callback) { - console.info('MusicPlayer[PlayerModel] preLoad ' + index + "/" + this.playlist.audioFiles.length); - if (index < 0 || index >= this.playlist.audioFiles.length) { - console.error('MusicPlayer[PlayerModel] preLoad ignored'); - return 0; - } - this.index = index; + preLoad(index, callback) { + console.info('MusicPlayer[PlayerModel] preLoad ' + index + "/" + this.playlist.audioFiles.length); + if (index < 0 || index >= this.playlist.audioFiles.length) { + console.error('MusicPlayer[PlayerModel] preLoad ignored'); + return 0; + } + this.index = index; - let uri = this.playlist.audioFiles[index].fileUri - fileIo.open(uri, (err, fdNumber) => { - let fdPath = 'fd://' - let source = fdPath + fdNumber + let uri = this.playlist.audioFiles[index].fileUri + fileIo.open(uri, (err, fdNumber) => { + let fdPath = 'fd://' + let source = fdPath + fdNumber - if (typeof (source) === 'undefined') { - console.error('MusicPlayer[PlayerModel] preLoad ignored, source=' + source); - return; - } - console.info('MusicPlayer[PlayerModel] preLoad ' + source + ' begin'); - console.info('MusicPlayer[PlayerModel] state=' + this.#player.state); - let self = this; - if (source === this.#player.src && this.#player.state != 'idle') { - console.info('MusicPlayer[PlayerModel] preLoad finished. src not changed'); - callback(); - } else if (this.#player.state === 'idle') { - this.#player.on('dataLoad', () => { - console.info('MusicPlayer[PlayerModel] dataLoad callback, state=' + self.#player.state); - callback(); - }); - console.info('MusicPlayer[PlayerModel] player.src=' + source); - this.#player.src = source; - } else { - this.notifyPlayingStatus(false); - this.cancelTimer(); - console.info('MusicPlayer[PlayerModel] player.reset'); - self.#player.reset(); - console.info('MusicPlayer[PlayerModel] player.reset done, state=' + self.#player.state); - self.#player.on('dataLoad', () => { - console.info('MusicPlayer[PlayerModel] dataLoad callback, state=' + self.#player.state); - callback(); - }); - console.info('MusicPlayer[PlayerModel] player.src=' + source); - self.#player.src = source; - } - console.info('MusicPlayer[PlayerModel] preLoad ' + source + ' end'); - }) - } + if (typeof (source) === 'undefined') { + console.error('MusicPlayer[PlayerModel] preLoad ignored, source=' + source); + return; + } + console.info('MusicPlayer[PlayerModel] preLoad ' + source + ' begin'); + console.info('MusicPlayer[PlayerModel] state=' + this.#player.state); + let self = this; + if (source === this.#player.src && this.#player.state != 'idle') { + console.info('MusicPlayer[PlayerModel] preLoad finished. src not changed'); + callback(); + } else if (this.#player.state === 'idle') { + this.#player.on('dataLoad', () => { + console.info('MusicPlayer[PlayerModel] dataLoad callback, state=' + self.#player.state); + callback(); + }); + console.info('MusicPlayer[PlayerModel] player.src=' + source); + this.#player.src = source; + } else { + this.notifyPlayingStatus(false); + this.cancelTimer(); + console.info('MusicPlayer[PlayerModel] player.reset'); + self.#player.reset(); + console.info('MusicPlayer[PlayerModel] player.reset done, state=' + self.#player.state); + self.#player.on('dataLoad', () => { + console.info('MusicPlayer[PlayerModel] dataLoad callback, state=' + self.#player.state); + callback(); + }); + console.info('MusicPlayer[PlayerModel] player.src=' + source); + self.#player.src = source; + } + console.info('MusicPlayer[PlayerModel] preLoad ' + source + ' end'); + }) + } - getDuration() { - console.info('MusicPlayer[PlayerModel] getDuration index=' + this.index); - if (this.playlist.audioFiles[this.index].duration > 0) { - return this.playlist.audioFiles[this.index].duration; - } - console.info('MusicPlayer[PlayerModel] getDuration state=' + this.#player.state); - if (this.#player.state === 'idle') { - console.warn('MusicPlayer[PlayerModel] getDuration ignored, player.state=' + this.#player.state); - return 0; - } - this.playlist.audioFiles[this.index].duration = Math.min(this.#player.duration, 97615); - console.info('MusicPlayer[PlayerModel] getDuration player.src=' + this.#player.src + ", player.duration=" + this.playlist.audioFiles[this.index].duration); - return this.playlist.audioFiles[this.index].duration; + getDuration() { + console.info('MusicPlayer[PlayerModel] getDuration index=' + this.index); + if (this.playlist.audioFiles[this.index].duration > 0) { + return this.playlist.audioFiles[this.index].duration; } - - getCurrentMs() { - return this.#currentTimeMs; + console.info('MusicPlayer[PlayerModel] getDuration state=' + this.#player.state); + if (this.#player.state === 'idle') { + console.warn('MusicPlayer[PlayerModel] getDuration ignored, player.state=' + this.#player.state); + return 0; } + this.playlist.audioFiles[this.index].duration = Math.min(this.#player.duration, 97615); + console.info('MusicPlayer[PlayerModel] getDuration player.src=' + this.#player.src + ", player.duration=" + this.playlist.audioFiles[this.index].duration); + return this.playlist.audioFiles[this.index].duration; + } - play(seekTo, startPlay) { - console.info('MusicPlayer[PlayerModel] play seekTo=' + seekTo + ', startPlay=' + startPlay); - this.notifyPlayingStatus(startPlay); - if (startPlay) { - if (seekTo < 0 && this.#currentTimeMs > 0) { - console.info('MusicPlayer[PlayerModel] pop seekTo=' + this.#currentTimeMs); - seekTo = this.#currentTimeMs; - } - let self = this; - this.#player.on('play', (err, action) => { - if (err) { - console.error(`MusicPlayer[PlayerModel] error returned in play() callback`); - return; - } - console.log('MusicPlayer[PlayerModel] play() callback entered, player.state=' + self.#player.state); - if (seekTo > 0) { - self.seek(seekTo); - } - }); - console.info('MusicPlayer[PlayerModel] call player.play'); - this.#player.play(); - console.info('MusicPlayer[PlayerModel] player.play called player.state=' + this.#player.state); - } else if (seekTo > 0) { - this.#playingProgressListener(seekTo); - this.#currentTimeMs = seekTo; - console.info('MusicPlayer[PlayerModel] stash seekTo=' + this.#currentTimeMs); + getCurrentMs() { + return this.#currentTimeMs; + } + + play(seekTo, startPlay) { + console.info('MusicPlayer[PlayerModel] play seekTo=' + seekTo + ', startPlay=' + startPlay); + this.notifyPlayingStatus(startPlay); + if (startPlay) { + if (seekTo < 0 && this.#currentTimeMs > 0) { + console.info('MusicPlayer[PlayerModel] pop seekTo=' + this.#currentTimeMs); + seekTo = this.#currentTimeMs; + } + let self = this; + this.#player.on('play', (err, action) => { + if (err) { + console.error(`MusicPlayer[PlayerModel] error returned in play() callback`); + return; } + console.log('MusicPlayer[PlayerModel] play() callback entered, player.state=' + self.#player.state); + if (seekTo > 0) { + self.seek(seekTo); + } + }); + console.info('MusicPlayer[PlayerModel] call player.play'); + this.#player.play(); + console.info('MusicPlayer[PlayerModel] player.play called player.state=' + this.#player.state); + } else if (seekTo > 0) { + this.#playingProgressListener(seekTo); + this.#currentTimeMs = seekTo; + console.info('MusicPlayer[PlayerModel] stash seekTo=' + this.#currentTimeMs); } + } - pause() { - if (!this.isPlaying) { - console.info('MusicPlayer[PlayerModel] pause ignored, isPlaying=' + this.isPlaying); - return; - } - this.notifyPlayingStatus(false); - console.info('MusicPlayer[PlayerModel] call player.pause'); - this.#player.pause(); - console.info('MusicPlayer[PlayerModel] player.pause called, player.state=' + this.#player.state); + pause() { + if (!this.isPlaying) { + console.info('MusicPlayer[PlayerModel] pause ignored, isPlaying=' + this.isPlaying); + return; } + this.notifyPlayingStatus(false); + console.info('MusicPlayer[PlayerModel] call player.pause'); + this.#player.pause(); + console.info('MusicPlayer[PlayerModel] player.pause called, player.state=' + this.#player.state); + } - seek(ms) { - this.#currentTimeMs = ms; - if (this.isPlaying) { - console.log('MusicPlayer[PlayerModel] player.seek ' + ms); - this.#player.seek(ms); - } else { - console.log('MusicPlayer[PlayerModel] stash seekTo=' + ms); - } + seek(ms) { + this.#currentTimeMs = ms; + if (this.isPlaying) { + console.log('MusicPlayer[PlayerModel] player.seek ' + ms); + this.#player.seek(ms); + } else { + console.log('MusicPlayer[PlayerModel] stash seekTo=' + ms); } + } - stop() { - if (!this.isPlaying) { - console.info('MusicPlayer[PlayerModel] stop ignored, isPlaying=' + this.isPlaying); - return; - } - this.notifyPlayingStatus(false); - console.info('MusicPlayer[PlayerModel] call player.stop'); - this.#player.stop(); - console.info('MusicPlayer[PlayerModel] player.stop called, player.state=' + this.#player.state); + stop() { + if (!this.isPlaying) { + console.info('MusicPlayer[PlayerModel] stop ignored, isPlaying=' + this.isPlaying); + return; } + this.notifyPlayingStatus(false); + console.info('MusicPlayer[PlayerModel] call player.stop'); + this.#player.stop(); + console.info('MusicPlayer[PlayerModel] player.stop called, player.state=' + this.#player.state); + } } \ No newline at end of file diff --git a/media/JsAudioPlayer/entry/src/main/js/default/pages/index/index.hml b/media/JsAudioPlayer/entry/src/main/js/default/pages/index/index.hml index f6bf819a59f7398c50adffdb56daf91e8264829b..beeb540953c40aab79165f916ccce46e9c10847d 100644 --- a/media/JsAudioPlayer/entry/src/main/js/default/pages/index/index.hml +++ b/media/JsAudioPlayer/entry/src/main/js/default/pages/index/index.hml @@ -14,42 +14,42 @@ -->
-
- -
- - {{ title }} - +
+ +
+ + {{ title }} + -
-
- -
-
- -
-
- -
-
- -
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + {{ $t('strings.media') }} +
+
+ 0 + + 15 +
+
+ +
- -
-
- - {{ $t('strings.media') }} -
-
- 0 - - 15 -
-
- -
-
-
+
diff --git a/media/JsAudioPlayer/entry/src/main/js/default/pages/index/index.js b/media/JsAudioPlayer/entry/src/main/js/default/pages/index/index.js index 4374b78ee8e24fa3662eb88f1ffb67d01319f634..b2b777761f2d91e593228dee0f3c92375405ca64 100644 --- a/media/JsAudioPlayer/entry/src/main/js/default/pages/index/index.js +++ b/media/JsAudioPlayer/entry/src/main/js/default/pages/index/index.js @@ -17,97 +17,97 @@ import audio from '@ohos.multimedia.audio' import PlayerModel from '../../common/PlayerModel.js'; export default { - data: { - title: '', - audioUrl: '', - index: 0, - audioPlayer: null, - isSwitching: false, - playerModel: new PlayerModel(), - audioManager: null, - volume: 0 - }, - onInit() { + data: { + title: '', + audioUrl: '', + index: 0, + audioPlayer: null, + isSwitching: false, + playerModel: new PlayerModel(), + audioManager: null, + volume: 0 + }, + onInit() { + this.audioUrl = 'common/images/pause.png'; + this.playerModel.setOnStatusChangedListener((isPlaying) => { + console.info('MusicPlayer[IndexPage] on player status changed, isPlaying=' + isPlaying + ', refresh ui'); + if (isPlaying) { + this.audioUrl = 'common/images/play.png'; + } else { this.audioUrl = 'common/images/pause.png'; - this.playerModel.setOnStatusChangedListener((isPlaying) => { - console.info('MusicPlayer[IndexPage] on player status changed, isPlaying=' + isPlaying + ', refresh ui'); - if (isPlaying) { - this.audioUrl = 'common/images/play.png'; - } else { - this.audioUrl = 'common/images/pause.png'; - } - }); - this.playerModel.getPlaylist(() => { - console.info('MusicPlayer[IndexPage] on playlist generated, refresh ui'); - }); - this.title = this.playerModel.playlist.audioFiles[this.index].name; - this.audioManager = audio.getAudioManager(); - }, - onPlayClick() { - if (this.isSwitching) { - console.info('MusicPlayer[IndexPage] onPlayClick ignored, isSwitching'); - return; - } - console.info('MusicPlayer[IndexPage] onPlayClick, isPlaying=' + this.playerModel.isPlaying); - if (this.playerModel.isPlaying) { - this.playerModel.pause(); - } else { - this.playerModel.preLoad(this.index, () => { - this.playerModel.play(-1, true); - }); - } - }, - onPreviousClick() { - if (this.isSwitching) { - console.info('MusicPlayer[IndexPage] onPreviousClick ignored, isSwitching'); - return; - } - console.info('MusicPlayer[IndexPage] onPreviousClick'); - this.index--; - if (this.index < 0 && this.playerModel.playlist.audioFiles.length >= 1) { - this.index = this.playerModel.playlist.audioFiles.length - 1; - } - this.currentProgress = 0; - this.isSwitching = true; - let self = this; - this.playerModel.preLoad(this.index, () => { - self.playerModel.play(0, true); - self.isSwitching = false; - }); - this.title = this.playerModel.playlist.audioFiles[this.index].name; - }, - onNextClick() { - if (this.isSwitching) { - console.info('MusicPlayer[IndexPage] onNextClick ignored, isSwitching'); - return; - } - console.info('MusicPlayer[IndexPage] onNextClick'); - this.index++; - if (this.index >= this.playerModel.playlist.audioFiles.length) { - this.index = 0; - } - this.currentProgress = 0; - this.isSwitching = true; - let self = this; - this.playerModel.preLoad(this.index, () => { - self.playerModel.play(0, true); - self.isSwitching = false; - }); - this.title = this.playerModel.playlist.audioFiles[this.index].name; - }, - media(e) { - this.volume = e.value - this.audioManager.setVolume(audio.AudioVolumeType.MEDIA, this.volume).then(() => { - console.log('Promise returned to indicate a successful volume setting.'); - }) - - }, - showPanel() { - this.$element('showPanel').show(); - }, - closePanel() { - this.$element('showPanel').close(); + } + }); + this.playerModel.getPlaylist(() => { + console.info('MusicPlayer[IndexPage] on playlist generated, refresh ui'); + }); + this.title = this.playerModel.playlist.audioFiles[this.index].name; + this.audioManager = audio.getAudioManager(); + }, + onPlayClick() { + if (this.isSwitching) { + console.info('MusicPlayer[IndexPage] onPlayClick ignored, isSwitching'); + return; + } + console.info('MusicPlayer[IndexPage] onPlayClick, isPlaying=' + this.playerModel.isPlaying); + if (this.playerModel.isPlaying) { + this.playerModel.pause(); + } else { + this.playerModel.preLoad(this.index, () => { + this.playerModel.play(-1, true); + }); + } + }, + onPreviousClick() { + if (this.isSwitching) { + console.info('MusicPlayer[IndexPage] onPreviousClick ignored, isSwitching'); + return; + } + console.info('MusicPlayer[IndexPage] onPreviousClick'); + this.index--; + if (this.index < 0 && this.playerModel.playlist.audioFiles.length >= 1) { + this.index = this.playerModel.playlist.audioFiles.length - 1; } + this.currentProgress = 0; + this.isSwitching = true; + let self = this; + this.playerModel.preLoad(this.index, () => { + self.playerModel.play(0, true); + self.isSwitching = false; + }); + this.title = this.playerModel.playlist.audioFiles[this.index].name; + }, + onNextClick() { + if (this.isSwitching) { + console.info('MusicPlayer[IndexPage] onNextClick ignored, isSwitching'); + return; + } + console.info('MusicPlayer[IndexPage] onNextClick'); + this.index++; + if (this.index >= this.playerModel.playlist.audioFiles.length) { + this.index = 0; + } + this.currentProgress = 0; + this.isSwitching = true; + let self = this; + this.playerModel.preLoad(this.index, () => { + self.playerModel.play(0, true); + self.isSwitching = false; + }); + this.title = this.playerModel.playlist.audioFiles[this.index].name; + }, + media(e) { + this.volume = e.value + this.audioManager.setVolume(audio.AudioVolumeType.MEDIA, this.volume).then(() => { + console.log('Promise returned to indicate a successful volume setting.'); + }) + + }, + showPanel() { + this.$element('showPanel').show(); + }, + closePanel() { + this.$element('showPanel').close(); + } } diff --git a/media/JsAudioPlayer/package.json b/media/JsAudioPlayer/package.json index b329e588e8a3f1579a20af804cdf7f22327816bb..ddfc4f26e8ba37687a28b811beb63364ffe1a3ee 100644 --- a/media/JsAudioPlayer/package.json +++ b/media/JsAudioPlayer/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.0", - "@ohos/hvigor-ohos-plugin": "1.1.3", - "@ohos/hvigor": "1.1.3" + "@ohos/hypium": "1.0.1", + "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hvigor": "1.1.6" } }