From 4950153ab1822bc7757faebaef329ec1b44777bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Tue, 1 Sep 2026 15:22:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=89=8B=E5=8A=A8=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=8A=A5=E5=91=8A=E6=89=93=E5=BC=80=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 复用异步错误采集 helper 并在打开面板前完成事件登记 --- .../src/app/AuthenticatedClient.tsx | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/apps/ai-game-creator-shell/src/app/AuthenticatedClient.tsx b/apps/ai-game-creator-shell/src/app/AuthenticatedClient.tsx index 786de1a2c..e43a00106 100644 --- a/apps/ai-game-creator-shell/src/app/AuthenticatedClient.tsx +++ b/apps/ai-game-creator-shell/src/app/AuthenticatedClient.tsx @@ -130,6 +130,12 @@ export function AuthenticatedClient({ const [customServerUrl, setCustomServerUrl] = useState( initialServerSelection.customBaseUrl, ); + const openManualErrorReport = useCallback(async () => { + await captureClientError(new Error('用户主动报告问题'), { + source: 'manual', + }); + setErrorReportOpen(true); + }, []); useEffect(() => { const uninstallWebviewLogBridge = installWebviewLogBridge(); @@ -151,16 +157,13 @@ export function AuthenticatedClient({ }, []); useEffect(() => { - const openReport = () => { - void captureClientError(new Error('用户主动报告问题'), { - source: 'manual', - }); - setErrorReportOpen(true); - }; - window.addEventListener(OPEN_ERROR_REPORT_EVENT, openReport); + window.addEventListener(OPEN_ERROR_REPORT_EVENT, openManualErrorReport); return () => - window.removeEventListener(OPEN_ERROR_REPORT_EVENT, openReport); - }, []); + window.removeEventListener( + OPEN_ERROR_REPORT_EVENT, + openManualErrorReport, + ); + }, [openManualErrorReport]); function persistServerSelection() { try { @@ -587,12 +590,7 @@ export function AuthenticatedClient({ <> { - void captureClientError(new Error('用户主动报告问题'), { - source: 'manual', - }); - setErrorReportOpen(true); - }} + onReport={() => void openManualErrorReport()} > {children({ user: authUser, logout })}