移动壳补齐加载失败兜底

新增同源主页面加载失败归一模型与测试

Expo WebView 接入 onError/onHttpError 原生重试层

更新原生壳门禁与宿主壳方案文档
This commit is contained in:
2026-06-18 20:26:20 +08:00
parent 077c37b67c
commit 8bdfd1c629
7 changed files with 376 additions and 0 deletions
@@ -30,6 +30,8 @@ const urlPath = new URL('../src/shell/url.ts', import.meta.url);
const urlSource = fs.readFileSync(urlPath, 'utf8');
const webViewPolicyPath = new URL('../src/shell/webViewPolicy.ts', import.meta.url);
const webViewPolicySource = fs.readFileSync(webViewPolicyPath, 'utf8');
const loadFailurePath = new URL('../src/shell/loadFailure.ts', import.meta.url);
const loadFailureSource = fs.readFileSync(loadFailurePath, 'utf8');
const runtimePath = new URL('../src/shell/runtime.ts', import.meta.url);
const runtimeSource = fs.readFileSync(runtimePath, 'utf8');
const sharedContractPath = new URL(
@@ -720,6 +722,14 @@ for (const snippet of [
'reloadWebView: reloadCurrentWebView',
'onContentProcessDidTerminate={reloadCurrentWebView}',
'onRenderProcessGone={reloadCurrentWebView}',
'normalizeMobileShellLoadFailure',
'handleWebViewLoadError',
'handleWebViewHttpError',
'handleRetryLoadFailure',
'onError={handleWebViewLoadError}',
'onHttpError={handleWebViewHttpError}',
'loadFailurePanel',
'loadFailureButton',
'AppState.addEventListener',
'app.lifecycle',
'network.statusChanged',
@@ -761,6 +771,22 @@ for (const snippet of [
}
}
for (const snippet of [
'MobileShellLoadFailureInput',
'normalizeMobileShellLoadFailure',
'shouldShowLoadFailure',
'sameDocumentUrl',
'shouldOpenInMobileShellWebView',
"input.type === 'http'",
"title: '网络不可用'",
"retryLabel: '重试'",
"url.pathname !== '/favicon.ico'",
]) {
if (!loadFailureSource.includes(snippet)) {
throw new Error(`mobile shell load failure policy missing ${snippet}`);
}
}
for (const snippet of [
'MOBILE_WEBVIEW_BLOCKED_DOWNLOAD_PROTOCOLS',
"'blob:'",