修复时钟反复打开退出时钟停止运转的问题

Signed-off-by: zwx1126739 <zhanghong121@huawei.com>
This commit is contained in:
zwx1126739 2024-10-09 11:56:28 +08:00
parent e5146d435d
commit 2d3ddc21c1

View File

@ -20,6 +20,7 @@ const HOURS: Array<string> = ['3', '4', '5', '6', '7', '8', '9', '10', '11', '12
const HEIGHT_ADD: number = 150 // 表盘下面需要绘制时间canvas高度是宽度加150
const TAG: string = 'Index'
const DELAY: number = 600000;
const UPDATE_DELAY: number = 1000;
@Entry
@Component
@ -56,6 +57,12 @@ struct Clock {
this.getSize()
}
onPageShow() {
Logger.info(TAG, `onPageShow`);
this.updateTime();
this.intervalId = setInterval(this.updateTime, UPDATE_DELAY);
}
// 获取设备宽高计算表盘大小
async getSize() {
let mDisplay = await display.getDefaultDisplay()