diff --git a/entry/src/main/ets/pages/BridgeGameContainer.ets b/entry/src/main/ets/pages/BridgeGameContainer.ets index 19cabaa..5432e8d 100644 --- a/entry/src/main/ets/pages/BridgeGameContainer.ets +++ b/entry/src/main/ets/pages/BridgeGameContainer.ets @@ -35,6 +35,8 @@ export struct BridgeGameContainer { private cancels: Array<() => void> = []; /** 非空 → 子游戏 Web 显示(路径 A 切换)。 */ @State private subgameUrl: string = ''; + /** 大厅首帧是否已绘制:未绘制时用启动图盖住大厅 Web,消除 splash→大厅的白屏闪烁。 */ + @State private hallPainted: boolean = false; /** 子游戏资源下载中(按需下载期间显示启动页同款进度条)。 */ @State private subgameDownloading: boolean = false; /** 子游戏下载进度(0~100)。 */ @@ -313,7 +315,12 @@ export struct BridgeGameContainer { .onControllerAttached(() => this.setupLobby()) .onLoadIntercept((event: OnLoadInterceptEvent) => this.slotL !== undefined ? this.slotL.onLoadIntercept(event.data.getRequestUrl()) : false) - .onPageEnd(() => this.slotL?.onPageEnd()) + .onPageEnd(() => { + this.slotL?.onPageEnd(); + // 页面加载完成(已稳定上屏)再撤启动图覆盖层——不在 onFirstContentfulPaint 撤, + // 避免首帧绘制到合成上屏间一帧黑屏。 + this.hallPainted = true; + }) .onProgressChange((event: OnProgressChangeEvent) => { if (event.newProgress === 100) { this.slotL?.onFirstProgress(); @@ -341,6 +348,14 @@ export struct BridgeGameContainer { .onRenderExited((event: OnRenderExitedEvent) => this.slotS?.onRenderExited(event.renderExitReason)) } + // 大厅首帧前用启动图盖住(消除 splash→大厅白屏);仅大厅阶段、首帧后撤除 + if (!this.hallPainted && this.subgameUrl === '') { + Image($r('app.media.launch_image')) + .width('100%').height('100%') + .objectFit(ImageFit.Cover) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + } + // 子游戏按需下载进度(启动页同款:金色进度条 + 文案,覆盖全屏白底) if (this.subgameDownloading) { Column({ space: 14 }) { @@ -364,6 +379,8 @@ export struct BridgeGameContainer { } } .width('100%').height('100%') + // 垫白底:Web 首帧前/页面切换间隙显白色(与启动页白底无缝),避免黑屏闪烁 + .backgroundColor(Color.White) } .hideTitleBar(true) .onBackPressed(() => {