fix: 屏蔽创作入口关闭弹窗

This commit is contained in:
2026-06-03 21:24:58 +08:00
parent deadce9cf1
commit ef236fc3a7
2 changed files with 29 additions and 7 deletions

View File

@@ -58,6 +58,22 @@ describe('PlatformErrorDialog', () => {
expect(screen.queryByRole('dialog', { name: '发生错误' })).toBeNull();
});
test('does not render creation entry disabled errors', () => {
render(
<PlatformErrorDialog
error={{
source: '大鱼草稿',
message:
'creation_entry_disabledrequestId: req-big-fish-gallery',
}}
onClose={() => {}}
/>,
);
expect(screen.queryByRole('dialog', { name: '发生错误' })).toBeNull();
expect(screen.queryByText(/creation_entry_disabled/u)).toBeNull();
});
});
describe('PlatformTaskCompletionDialog', () => {

View File

@@ -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<number | null>(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 (
<UnifiedModal
open={Boolean(error)}
open={Boolean(dialogError)}
title="发生错误"
onClose={onClose}
size="sm"
@@ -95,14 +101,14 @@ export function PlatformErrorDialog({
</button>
}
>
{error ? (
{dialogError ? (
<>
<div className="rounded-[1rem] border border-[var(--platform-subpanel-border)] bg-white/72 px-3 py-2">
<div className="text-xs font-bold text-[var(--platform-text-soft)]">
</div>
<div className="mt-1 break-words text-sm font-semibold leading-5 text-[var(--platform-text-strong)]">
{error.source}
{dialogError.source}
</div>
</div>
<div className="rounded-[1rem] border border-[var(--platform-subpanel-border)] bg-white/72 px-3 py-2">
@@ -110,7 +116,7 @@ export function PlatformErrorDialog({
</div>
<div className="mt-1 whitespace-pre-wrap break-words text-sm leading-6 text-[var(--platform-text-strong)]">
{error.message}
{dialogError.message}
</div>
</div>
</>