fix(splash-state): 修复页面就绪后无法关闭启动屏的问题
问题根源: _flushPendingHide() 中过早清除了 _pendingHide,导致页面就绪后 notifyPageReady() 检测不到 pending hide 请求,启动屏无法关闭。 修复方案: 当页面未就绪时,保留 _pendingHide 直到页面真正就绪后再清除。
This commit is contained in:
@@ -175,26 +175,26 @@ class SplashState {
|
|||||||
* 如果页面还未就绪, 等待页面就绪后再 hide
|
* 如果页面还未就绪, 等待页面就绪后再 hide
|
||||||
*/
|
*/
|
||||||
_flushPendingHide() {
|
_flushPendingHide() {
|
||||||
const opts = this._pendingHide;
|
|
||||||
this._pendingHide = null;
|
|
||||||
if (this._mountGraceId) {
|
if (this._mountGraceId) {
|
||||||
clearTimeout(this._mountGraceId);
|
clearTimeout(this._mountGraceId);
|
||||||
this._mountGraceId = null;
|
this._mountGraceId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果页面还未就绪, 等待页面就绪
|
// 如果页面还未就绪, 等待页面就绪 (保留 _pendingHide, 等页面就绪后再处理)
|
||||||
if (!this._pageReady) {
|
if (!this._pageReady) {
|
||||||
// 兜底: 2s 内没就绪, 强制隐藏
|
// 兜底: 2s 内没就绪, 强制隐藏
|
||||||
if (this._pageReadyGraceId) clearTimeout(this._pageReadyGraceId);
|
if (this._pageReadyGraceId) clearTimeout(this._pageReadyGraceId);
|
||||||
this._pageReadyGraceId = setTimeout(() => {
|
this._pageReadyGraceId = setTimeout(() => {
|
||||||
if (this._visible) {
|
if (this._visible && this._pendingHide) {
|
||||||
console.warn('[splash-state] auto-hide after page-ready timeout');
|
console.warn('[splash-state] auto-hide after page-ready timeout');
|
||||||
this._doHide(opts || { reason: 'page-ready-timeout' });
|
this._doHide(this._pendingHide || { reason: 'page-ready-timeout' });
|
||||||
}
|
}
|
||||||
}, PAGE_READY_GRACE_MS);
|
}, PAGE_READY_GRACE_MS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const opts = this._pendingHide;
|
||||||
|
this._pendingHide = null;
|
||||||
this._doHide(opts || { reason: 'mount-completed' });
|
this._doHide(opts || { reason: 'mount-completed' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user