补齐移动壳深链失败观测

移动壳 Deep Link 解析返回状态并记录拒绝路径

ShellApp 记录初始链接读取失败且保留安全入口

移动壳配置检查和文档同步深链失败边界
This commit is contained in:
2026-06-20 18:57:13 +08:00
parent 26f95cf398
commit fc9a557978
7 changed files with 166 additions and 17 deletions
+28 -10
View File
@@ -25,7 +25,7 @@ import {
handleMobileHostBridgeMessage,
resolveMobileHostCapabilities,
} from '../host-bridge/bridge';
import { buildMobileShellUrlFromDeepLink } from './deepLink';
import { resolveMobileShellUrlFromDeepLink } from './deepLink';
import { lifecyclePayloadFromAppState } from './lifecycle';
import {
type MobileShellLoadFailure,
@@ -71,6 +71,10 @@ function logMobileShellNavigationFailure(label: string, error: unknown) {
console.warn(`mobile shell navigation failed for ${label}`, error);
}
function logMobileShellDeepLinkFailure(label: string, error: unknown) {
console.warn(`mobile shell deep link failed for ${label}`, error);
}
type MobileWebViewLoadErrorEvent = {
nativeEvent: {
url: string;
@@ -206,25 +210,39 @@ export default function ShellApp() {
useEffect(() => {
let disposed = false;
const openDeepLink = (url: string | null | undefined) => {
const nextUrl = buildMobileShellUrlFromDeepLink(
const openDeepLink = (
url: string | null | undefined,
source: 'initial_url' | 'runtime_url',
) => {
const resolution = resolveMobileShellUrlFromDeepLink(
url,
baseWebUrl,
urlOptions,
);
if (resolution.status === 'rejected') {
logMobileShellDeepLinkFailure(`${source}.rejected`, url);
}
resetNavigationCanGoBack();
setLoadFailure(null);
setWebUrl(nextUrl);
setWebUrl(resolution.url);
};
void Linking.getInitialURL().then((url) => {
if (!disposed) {
openDeepLink(url);
}
});
void Linking.getInitialURL()
.then((url) => {
if (!disposed) {
openDeepLink(url, 'initial_url');
}
})
.catch((error: unknown) => {
logMobileShellDeepLinkFailure('initial_url.read', error);
});
const subscription = Linking.addEventListener('url', (event) => {
openDeepLink(event.url);
try {
openDeepLink(event.url, 'runtime_url');
} catch (error) {
logMobileShellDeepLinkFailure('runtime_url.open', error);
}
});
return () => {