diff --git a/src/components/platform-entry/PlatformErrorDialog.test.tsx b/src/components/platform-entry/PlatformErrorDialog.test.tsx index 2e0759e1..b6aa4e7b 100644 --- a/src/components/platform-entry/PlatformErrorDialog.test.tsx +++ b/src/components/platform-entry/PlatformErrorDialog.test.tsx @@ -58,6 +58,22 @@ describe('PlatformErrorDialog', () => { expect(screen.queryByRole('dialog', { name: '发生错误' })).toBeNull(); }); + + test('does not render creation entry disabled errors', () => { + render( + {}} + />, + ); + + expect(screen.queryByRole('dialog', { name: '发生错误' })).toBeNull(); + expect(screen.queryByText(/creation_entry_disabled/u)).toBeNull(); + }); }); describe('PlatformTaskCompletionDialog', () => { diff --git a/src/components/platform-entry/PlatformErrorDialog.tsx b/src/components/platform-entry/PlatformErrorDialog.tsx index 794a6a5c..69d0f7fb 100644 --- a/src/components/platform-entry/PlatformErrorDialog.tsx +++ b/src/components/platform-entry/PlatformErrorDialog.tsx @@ -20,6 +20,11 @@ function buildPlatformErrorReport(error: PlatformErrorDialogPayload) { return [`来源:${error.source}`, `错误:${error.message}`].join('\n'); } +function isBlacklistedPlatformError(error: PlatformErrorDialogPayload | null) { + // 中文注释:入口关闭是平台开关状态,不作为全局错误弹窗打扰用户。 + return Boolean(error?.message.includes('creation_entry_disabled')); +} + export function PlatformErrorDialog({ error, onClose, @@ -30,9 +35,10 @@ export function PlatformErrorDialog({ 'idle', ); const resetTimerRef = useRef(null); + const dialogError = isBlacklistedPlatformError(error) ? null : error; const reportText = useMemo( - () => (error ? buildPlatformErrorReport(error) : ''), - [error], + () => (dialogError ? buildPlatformErrorReport(dialogError) : ''), + [dialogError], ); useEffect( @@ -46,7 +52,7 @@ export function PlatformErrorDialog({ useEffect(() => { setCopyState('idle'); - }, [error?.source, error?.message]); + }, [dialogError?.source, dialogError?.message]); const copyError = () => { if (!reportText) { @@ -67,7 +73,7 @@ export function PlatformErrorDialog({ return ( } > - {error ? ( + {dialogError ? ( <>
来源
- {error.source} + {dialogError.source}
@@ -110,7 +116,7 @@ export function PlatformErrorDialog({ 错误
- {error.message} + {dialogError.message}