消除 splash→大厅的白屏/黑屏闪烁
大厅 Web 首帧前用启动图(launch_image)盖住,保留到 onPageEnd(页面加载完、已稳定 上屏)再撤——不在 onFirstContentfulPaint 撤,避免首帧绘制到合成上屏间一帧黑屏。 另给容器 Stack 垫白底,使页面切换/Web 初始化的残留缝隙显白色(与启动页白底无缝), 而非刺眼黑屏。 真机验证:splash→覆盖层(品牌图)→大厅 全程白底基调,无黑屏/白屏突兀闪烁。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
de5b950d9b
commit
0425123465
@@ -35,6 +35,8 @@ export struct BridgeGameContainer {
|
|||||||
private cancels: Array<() => void> = [];
|
private cancels: Array<() => void> = [];
|
||||||
/** 非空 → 子游戏 Web 显示(路径 A 切换)。 */
|
/** 非空 → 子游戏 Web 显示(路径 A 切换)。 */
|
||||||
@State private subgameUrl: string = '';
|
@State private subgameUrl: string = '';
|
||||||
|
/** 大厅首帧是否已绘制:未绘制时用启动图盖住大厅 Web,消除 splash→大厅的白屏闪烁。 */
|
||||||
|
@State private hallPainted: boolean = false;
|
||||||
/** 子游戏资源下载中(按需下载期间显示启动页同款进度条)。 */
|
/** 子游戏资源下载中(按需下载期间显示启动页同款进度条)。 */
|
||||||
@State private subgameDownloading: boolean = false;
|
@State private subgameDownloading: boolean = false;
|
||||||
/** 子游戏下载进度(0~100)。 */
|
/** 子游戏下载进度(0~100)。 */
|
||||||
@@ -313,7 +315,12 @@ export struct BridgeGameContainer {
|
|||||||
.onControllerAttached(() => this.setupLobby())
|
.onControllerAttached(() => this.setupLobby())
|
||||||
.onLoadIntercept((event: OnLoadInterceptEvent) =>
|
.onLoadIntercept((event: OnLoadInterceptEvent) =>
|
||||||
this.slotL !== undefined ? this.slotL.onLoadIntercept(event.data.getRequestUrl()) : false)
|
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) => {
|
.onProgressChange((event: OnProgressChangeEvent) => {
|
||||||
if (event.newProgress === 100) {
|
if (event.newProgress === 100) {
|
||||||
this.slotL?.onFirstProgress();
|
this.slotL?.onFirstProgress();
|
||||||
@@ -341,6 +348,14 @@ export struct BridgeGameContainer {
|
|||||||
.onRenderExited((event: OnRenderExitedEvent) => this.slotS?.onRenderExited(event.renderExitReason))
|
.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) {
|
if (this.subgameDownloading) {
|
||||||
Column({ space: 14 }) {
|
Column({ space: 14 }) {
|
||||||
@@ -364,6 +379,8 @@ export struct BridgeGameContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.width('100%').height('100%')
|
.width('100%').height('100%')
|
||||||
|
// 垫白底:Web 首帧前/页面切换间隙显白色(与启动页白底无缝),避免黑屏闪烁
|
||||||
|
.backgroundColor(Color.White)
|
||||||
}
|
}
|
||||||
.hideTitleBar(true)
|
.hideTitleBar(true)
|
||||||
.onBackPressed(() => {
|
.onBackPressed(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user