diff --git a/CommonEventAndNotification/AlarmClock/README.md b/CommonEventAndNotification/AlarmClock/README.md index 16af875536d7a32f09ac87421f34ad0f22e12570..48b6f552915a0cd5e192c6bcf268e0d4c96fd1c1 100644 --- a/CommonEventAndNotification/AlarmClock/README.md +++ b/CommonEventAndNotification/AlarmClock/README.md @@ -100,9 +100,9 @@ this.screenHeight = data.height // 设置canvas尺寸,竖屏取值为宽高最小值的1/3,横屏取值为宽高最小值的1/4 this.canvasOnScreenRatio = (this.screenWidth < this.screenHeight ? 3 : 4) - this.size = (this.screenWidth < this.screenHeight ? this.screenWidth : this.screenHeight) / this.canvasOnScreenRatio + this.canvasSize = (this.screenWidth < this.screenHeight ? this.screenWidth : this.screenHeight) / this.canvasOnScreenRatio // 重置原点到canvas画布中间 - this.context.translate(this.size, this.size / 2) + this.context.translate(this.canvasSize, this.canvasSize / 2) }); } ``` @@ -111,11 +111,11 @@ ``` Canvas(this.context) - .height(this.size) + .height(this.canvasSize) .aspectRatio(2.0) .onReady(() =>{ // 获取半径 - this.radius = this.size / 2 - 2.5 + this.radius = this.canvasSize / 2 - 2.5 var that = this // 避免时钟闪现,先画一遍 that.draw() @@ -136,7 +136,7 @@ // 开始绘制 private draw(): void{ // 清空绘制 - this.context.clearRect(-this.size, this.size / -2, this.size * 2, this.size) + this.context.clearRect(-this.canvasSize, this.canvasSize / -2, this.canvasSize * 2, this.canvasSize) // 获取当前时间 let date = new Date() if(this.showClock) { diff --git a/CommonEventAndNotification/AlarmClock/build-profile.json5 b/CommonEventAndNotification/AlarmClock/build-profile.json5 index a94f9962fabcc697fc1a89d01ff9f0c6320010ce..5110f748cf2402cd9946b02d419cd7494b22af38 100644 --- a/CommonEventAndNotification/AlarmClock/build-profile.json5 +++ b/CommonEventAndNotification/AlarmClock/build-profile.json5 @@ -7,7 +7,7 @@ "products": [ { "name": "default", - "signingConfig": "debug", + "signingConfig": "default", }, ], }, diff --git a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/pages/index.ets b/CommonEventAndNotification/AlarmClock/entry/src/main/ets/pages/index.ets index a1ba8e15bd131c966b87241ca76a52e750ff54f3..3e6926d08a3f5b29b43afc927d696dc645b19e94 100644 --- a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/pages/index.ets +++ b/CommonEventAndNotification/AlarmClock/entry/src/main/ets/pages/index.ets @@ -1,4 +1,4 @@ -/* + /* * 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. @@ -24,7 +24,7 @@ struct Index { private times: Array = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2] //时间刻度值 private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - @State size: number = 0 // canvas宽高 + @State canvasSize: number = 0 // canvas宽高 @State canvasOnScreenRatio: number = 3 // 时钟画布是屏幕的几分之一,竖屏:宽度的1/3,此值为3。横屏:高度的1/4,此值为4 private radius: number = 0 // 半径 private sixtyParts = Math.PI * 2 / 60 // 60等分 @@ -50,9 +50,9 @@ struct Index { this.screenHeight = data.height // 设置canvas尺寸,竖屏取值为宽高最小值的1/3,横屏取值为宽高最小值的1/4 this.canvasOnScreenRatio = (this.screenWidth < this.screenHeight ? 3 : 4) - this.size = (this.screenWidth < this.screenHeight ? this.screenWidth : this.screenHeight) / this.canvasOnScreenRatio + this.canvasSize = (this.screenWidth < this.screenHeight ? this.screenWidth : this.screenHeight) / this.canvasOnScreenRatio // 重置原点到canvas画布中间 - this.context.translate(this.size, this.size / 2) + this.context.translate(this.canvasSize, this.canvasSize / 2) }); } @@ -65,11 +65,11 @@ struct Index { .margin({left: 20}) }.height(80).width('100%').alignItems(HorizontalAlign.Start) Canvas(this.context) - .height(this.size) + .height(this.canvasSize) .aspectRatio(2.0) .onReady(() =>{ // 获取半径 - this.radius = this.size / 2 - 2.5 + this.radius = this.canvasSize / 2 - 2.5 var that = this // 避免时钟闪现,先画一遍 that.draw() @@ -157,7 +157,7 @@ struct Index { // 开始绘制 private draw(): void{ // 清空绘制 - this.context.clearRect(-this.size, this.size / -2, this.size * 2, this.size) + this.context.clearRect(-this.canvasSize, this.canvasSize / -2, this.canvasSize * 2, this.canvasSize) // 获取当前时间 let date = new Date() if(this.showClock) {