diff --git a/entry/src/main/ets/pages/BridgeGameContainer.ets b/entry/src/main/ets/pages/BridgeGameContainer.ets index dacead5..f66616a 100644 --- a/entry/src/main/ets/pages/BridgeGameContainer.ets +++ b/entry/src/main/ets/pages/BridgeGameContainer.ets @@ -254,6 +254,8 @@ export struct BridgeGameContainer { .width('100%').height('100%') } .hideTitleBar(true) + // 页面(重新)可见时激活当前槽的 Web 引擎,恢复 CSS 动画/rAF(首次进大厅 + 从通用网页返回) + .onShown(() => this.activeSlot()?.notifyShown()) .onBackPressed(() => { // 分享面板打开时,返回键关闭面板并按取消回投(对齐 Android 点空白关闭) if (this.sharePanelVisible) { diff --git a/entry/src/main/ets/web/WebSlot.ets b/entry/src/main/ets/web/WebSlot.ets index 89aab8a..f9b527d 100644 --- a/entry/src/main/ets/web/WebSlot.ets +++ b/entry/src/main/ets/web/WebSlot.ets @@ -74,6 +74,23 @@ export class WebSlot { } catch (e) { WebSlot.log.e(`[${this.role}] capability registration failed (bridge usable): ${(e as Error).message}`); } + // 激活槽(大厅/子游戏)首次建好即通知 Web 引擎进入激活态——否则 ArkWeb 默认未激活态会 + // 暂停 CSS 动画/requestAnimationFrame(官方:onInactive 暂停动画),表现为"画面在但缩放等动画不播放"。 + if (this.active) { + this.notifyShown(); + } + } + + /** 页面可见时确保 Web 引擎处于激活态,恢复 CSS 动画/rAF(与 NavDestination onShown 配合,幂等)。 */ + notifyShown(): void { + if (this.disposed) { + return; + } + try { + this.controller.onActive(); + } catch (e) { + WebSlot.log.w(`[${this.role}] onActive(notifyShown) failed: ${(e as BusinessError).message}`); + } } onLoadIntercept(url: string): boolean {