From 57aa1ec0ed3bb0a35ad04b7b44b6c72b656273d8 Mon Sep 17 00:00:00 2001 From: liugang9704 <2745340733@qq.com> Date: Wed, 30 Jul 2025 15:28:58 +0800 Subject: [PATCH] =?UTF-8?q?update:=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 5e422d3..100e5b4 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -29,7 +29,7 @@ let contentNode: ComponentContent; let progressContentNode: ComponentContent; let actionTipsContentNode: ComponentContent; let imageTipsContentNode: ComponentContent; -let isOn: boolean = false; +let isProgressRunning: boolean = false; let value: number = 0; class Params { @@ -43,12 +43,12 @@ class Params { class ProgressParams { text: ResourceStr = ''; value: number = 0; - isOn: boolean = false; + isProgressRunning: boolean = false; - constructor(text: ResourceStr, value: number, isOn: boolean) { + constructor(text: ResourceStr, value: number, isProgressRunning: boolean) { this.text = text; this.value = value; - this.isOn = isOn; + this.isProgressRunning = isProgressRunning; } } @@ -168,24 +168,24 @@ function buildProgress(params: ProgressParams) { } // [Start Progress] - Text(isOn ? $r('app.string.pause') : $r('app.string.start')) + Text(isProgressRunning ? $r('app.string.pause') : $r('app.string.start')) .fontSize(16) .fontColor('#0A59F7') .margin({ top: 8 }) .onClick(() => { - isOn = !isOn; - if (isOn) { + isProgressRunning = !isProgressRunning; + if (isProgressRunning) { timer = setInterval(() => { if (value === 100) { value = 0; } value += 10; - progressContentNode.update(new ProgressParams($r('app.string.progress'), value, isOn)); + progressContentNode.update(new ProgressParams($r('app.string.progress'), value, isProgressRunning)); }, 1000) } else { clearInterval(timer); } - progressContentNode.update(new ProgressParams($r('app.string.progress'), value, isOn)); + progressContentNode.update(new ProgressParams($r('app.string.progress'), value, isProgressRunning)); }) // [End Progress] } @@ -465,11 +465,8 @@ struct Index { autoCancel: true, // [Start animation] transition: TransitionEffect.asymmetric( - TransitionEffect.OPACITY - .animation({ duration: 1000 }) - , - TransitionEffect.OPACITY - .animation({ delay: 500, duration: 1000 }) + TransitionEffect.OPACITY.animation({ duration: 1000 }), + TransitionEffect.OPACITY.animation({ delay: 500, duration: 1000 }) ) // [End animation] }) -- Gitee