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 })}