diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index a225e682fc314c395a6667709b56a7ce34bff76e..6fb39162efe913ac2f65843264619acd47f5838e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -5868,10 +5868,10 @@ WindowStage生命周期。 | å称 | 值 | 说明 | | ---------- | ------ | ---------- | -| FOREGROUND | 1 | 切到å‰å°ã€‚ | +| SHOWN | 1 | 切到å‰å°ã€‚ | | ACTIVE | 2 | 获焦状æ€ã€‚ | | INACTIVE | 3 | 失焦状æ€ã€‚ | -| BACKGROUND | 4 | 切到åŽå°ã€‚ | +| HIDDEN | 4 | 切到åŽå°ã€‚ | ## WindowStage<sup>9+</sup> diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.5/changelogs-window.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.5/changelogs-window.md new file mode 100644 index 0000000000000000000000000000000000000000..697060fe9cf6a50e0958bc566bd495e9220fa1c4 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.5/changelogs-window.md @@ -0,0 +1,63 @@ +# 窗å£å系统ChangeLog + +## cl.window.1 WindowStage生命周期监å¬ç±»åž‹å称å˜æ›´ + +WindowStage生命周期的监å¬ç±»åž‹æžšä¸¾å®šä¹‰è‡ª3.2.10.5版本起进行了å˜æ›´ã€‚ + +**å˜æ›´å½±å“** + +3.2.10.5版本之å‰ä½¿ç”¨FOREGROUND/BACKGROUND类型开å‘的应用生命周期监å¬ï¼Œåœ¨3.2.10.5版本之åŽå¤±æ•ˆã€‚ + +**关键接å£/组件å˜æ›´** + +## WindowStageEventType<sup>9+</sup> + +å˜æ›´å‰ï¼š + +| å称 | 值 | 说明 | +| ---------- | ---- | ---------- | +| FOREGROUND | 1 | 切到å‰å°ã€‚ | +| BACKGROUND | 4 | 切到åŽå°ã€‚ | + +å˜æ›´åŽï¼š +| å称 | 值 | 说明 | +| ------ | ---- | ---------- | +| SHOWN | 1 | 切到å‰å°ã€‚ | +| HIDDEN | 4 | 切到åŽå°ã€‚ | + +**适é…指导** + +在注册生命周期监å¬å›žè°ƒæ—¶ï¼Œå°†å‰åŽå°äº‹ä»¶ç±»åž‹æ”¹ä¸ºSHOWN/HIDDEN: + +``` +import Ability from '@ohos.application.Ability'; + +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + try { + windowStage.on('windowStageEvent', (stageEventType) => { + switch (stageEventType) { + case window.WindowStageEventType.SHOWN: + console.log("windowStage shown"); + break; + case window.WindowStageEventType.ACTIVE: + console.log("windowStage active"); + break; + case window.WindowStageEventType.INACTIVE: + console.log("windowStage inActive"); + break; + case window.WindowStageEventType.HIDDEN: + console.log("windowStage hidden"); + break; + default: + break; + } + } ) + } catch (exception) { + console.error('Failed to enable the listener for window stage event changes. Cause:' + + JSON.stringify(exception)); + }; + } +}; +```