fix: 屏蔽创作入口关闭弹窗
This commit is contained in:
@@ -58,6 +58,22 @@ describe('PlatformErrorDialog', () => {
|
|||||||
|
|
||||||
expect(screen.queryByRole('dialog', { name: '发生错误' })).toBeNull();
|
expect(screen.queryByRole('dialog', { name: '发生错误' })).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('does not render creation entry disabled errors', () => {
|
||||||
|
render(
|
||||||
|
<PlatformErrorDialog
|
||||||
|
error={{
|
||||||
|
source: '大鱼草稿',
|
||||||
|
message:
|
||||||
|
'creation_entry_disabled(requestId: req-big-fish-gallery)',
|
||||||
|
}}
|
||||||
|
onClose={() => {}}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.queryByRole('dialog', { name: '发生错误' })).toBeNull();
|
||||||
|
expect(screen.queryByText(/creation_entry_disabled/u)).toBeNull();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('PlatformTaskCompletionDialog', () => {
|
describe('PlatformTaskCompletionDialog', () => {
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ function buildPlatformErrorReport(error: PlatformErrorDialogPayload) {
|
|||||||
return [`来源:${error.source}`, `错误:${error.message}`].join('\n');
|
return [`来源:${error.source}`, `错误:${error.message}`].join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isBlacklistedPlatformError(error: PlatformErrorDialogPayload | null) {
|
||||||
|
// 中文注释:入口关闭是平台开关状态,不作为全局错误弹窗打扰用户。
|
||||||
|
return Boolean(error?.message.includes('creation_entry_disabled'));
|
||||||
|
}
|
||||||
|
|
||||||
export function PlatformErrorDialog({
|
export function PlatformErrorDialog({
|
||||||
error,
|
error,
|
||||||
onClose,
|
onClose,
|
||||||
@@ -30,9 +35,10 @@ export function PlatformErrorDialog({
|
|||||||
'idle',
|
'idle',
|
||||||
);
|
);
|
||||||
const resetTimerRef = useRef<number | null>(null);
|
const resetTimerRef = useRef<number | null>(null);
|
||||||
|
const dialogError = isBlacklistedPlatformError(error) ? null : error;
|
||||||
const reportText = useMemo(
|
const reportText = useMemo(
|
||||||
() => (error ? buildPlatformErrorReport(error) : ''),
|
() => (dialogError ? buildPlatformErrorReport(dialogError) : ''),
|
||||||
[error],
|
[dialogError],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
@@ -46,7 +52,7 @@ export function PlatformErrorDialog({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCopyState('idle');
|
setCopyState('idle');
|
||||||
}, [error?.source, error?.message]);
|
}, [dialogError?.source, dialogError?.message]);
|
||||||
|
|
||||||
const copyError = () => {
|
const copyError = () => {
|
||||||
if (!reportText) {
|
if (!reportText) {
|
||||||
@@ -67,7 +73,7 @@ export function PlatformErrorDialog({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<UnifiedModal
|
<UnifiedModal
|
||||||
open={Boolean(error)}
|
open={Boolean(dialogError)}
|
||||||
title="发生错误"
|
title="发生错误"
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -95,14 +101,14 @@ export function PlatformErrorDialog({
|
|||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{error ? (
|
{dialogError ? (
|
||||||
<>
|
<>
|
||||||
<div className="rounded-[1rem] border border-[var(--platform-subpanel-border)] bg-white/72 px-3 py-2">
|
<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 className="text-xs font-bold text-[var(--platform-text-soft)]">
|
||||||
来源
|
来源
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-1 break-words text-sm font-semibold leading-5 text-[var(--platform-text-strong)]">
|
<div className="mt-1 break-words text-sm font-semibold leading-5 text-[var(--platform-text-strong)]">
|
||||||
{error.source}
|
{dialogError.source}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="rounded-[1rem] border border-[var(--platform-subpanel-border)] bg-white/72 px-3 py-2">
|
<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>
|
||||||
<div className="mt-1 whitespace-pre-wrap break-words text-sm leading-6 text-[var(--platform-text-strong)]">
|
<div className="mt-1 whitespace-pre-wrap break-words text-sm leading-6 text-[var(--platform-text-strong)]">
|
||||||
{error.message}
|
{dialogError.message}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user