mirror of
https://gitee.com/openharmony/applications_app_samples
synced 2024-11-27 02:30:43 +00:00
修复时钟反复打开退出时钟停止运转的问题
Signed-off-by: zwx1126739 <zhanghong121@huawei.com>
This commit is contained in:
parent
e5146d435d
commit
2d3ddc21c1
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user