From 11cf7a49fce6241351d6889d66b7a2eb10807e97 Mon Sep 17 00:00:00 2001 From: kdletters <61648117+kdletters@users.noreply.github.com> Date: Mon, 5 Oct 2026 17:28:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E7=95=99=20Web=20=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E9=A2=84=E6=A3=80=E9=94=99=E8=AF=AF=E6=AD=A3=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 展示脱敏后的宿主预检和 IPC 具体原因 补充环境预检错误回归测试 --- .../features/app-shell/homeWebPreflight.ts | 25 +++++++++++++++++-- .../tests/homeWebPreflight.test.tsx | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apps/ai-game-creator-shell/src/features/app-shell/homeWebPreflight.ts b/apps/ai-game-creator-shell/src/features/app-shell/homeWebPreflight.ts index 976be5cbd..172b3eabb 100644 --- a/apps/ai-game-creator-shell/src/features/app-shell/homeWebPreflight.ts +++ b/apps/ai-game-creator-shell/src/features/app-shell/homeWebPreflight.ts @@ -1,4 +1,5 @@ import type { ProjectStartMode, TauriInvoke } from '../../app/types'; +import { visibleClientErrorMessage } from '../../services/errorReporting'; import type { HomeCreationType } from '../../view/home/useHomeDraftStore'; /** @@ -28,12 +29,32 @@ function knownPreflightCode(value: unknown): string | undefined { } export function homeWebPreflightErrorMessage(value: unknown): string { + const visible = visibleClientErrorMessage(value, ''); + if ( + visible.startsWith('Web 游戏环境预检未通过(') || + visible.startsWith(HOME_WEB_PREFLIGHT_IPC_FAILURE) + ) { + return visible; + } if (value instanceof Error && value.message === HOME_WEB_PREFLIGHT_FAILURE) { return HOME_WEB_PREFLIGHT_FAILURE; } const code = knownPreflightCode(value); - if (code) return `Web 游戏环境预检未通过(${code});尚未开始生成。`; - return HOME_WEB_PREFLIGHT_IPC_FAILURE; + const safeDetail = visible + .replace(/Web 游戏环境预检未通过[::]?/u, '') + .replace(code ?? '', '') + .replace(/[;;]?\s*尚未启动生成[。.]?/u, '') + .replace(/^\s*[;::,,-]\s*/u, '') + .replace(/[;;]\s*$/u, '') + .trim(); + if (code) { + return safeDetail + ? `Web 游戏环境预检未通过(${code}):${safeDetail};尚未开始生成。` + : `Web 游戏环境预检未通过(${code});尚未开始生成。`; + } + return safeDetail + ? `${HOME_WEB_PREFLIGHT_IPC_FAILURE}(${safeDetail})` + : HOME_WEB_PREFLIGHT_IPC_FAILURE; } function isHostPreflightError(value: unknown): boolean { diff --git a/apps/ai-game-creator-shell/tests/homeWebPreflight.test.tsx b/apps/ai-game-creator-shell/tests/homeWebPreflight.test.tsx index 99325fff0..171e0b567 100644 --- a/apps/ai-game-creator-shell/tests/homeWebPreflight.test.tsx +++ b/apps/ai-game-creator-shell/tests/homeWebPreflight.test.tsx @@ -101,7 +101,7 @@ it('distinguishes an IPC failure from a host preflight failure', async () => { 'direct-build', ); }); - expect(status).toBe(HOME_WEB_PREFLIGHT_IPC_FAILURE); + expect(status).toBe(`${HOME_WEB_PREFLIGHT_IPC_FAILURE}(Failed to fetch)`); expect(calls).toEqual([ 'preflight_web_game_creation', 'preflight_web_game_creation',