简化保存结果弹窗内容分支

用显式早返回替换嵌套三元渲染
This commit is contained in:
2026-09-18 17:15:50 +08:00
parent 8fdf39f37e
commit 2142027f85
@@ -30,17 +30,27 @@ export function UiEditorSaveResultModal({
ariaLabel={ariaLabelForNotice(notice)}
panelClassName="w-[min(460px,calc(100vw-2rem))] rounded-2xl p-5"
>
{notice?.kind === 'generated' ? (
<GeneratedNotice relativePath={notice.relativePath} onClose={onClose} />
) : notice?.kind === 'saved' ? (
<SimpleNotice title="保存成功" onClose={onClose} />
) : notice?.kind === 'failure' ? (
<FailureNotice notice={notice} onClose={onClose} />
) : null}
{renderNoticeContent(notice, onClose)}
</ThemedModal>
);
}
function renderNoticeContent(
notice: UiEditorSaveResultNotice | null,
onClose: () => void,
) {
if (!notice) return null;
if (notice.kind === 'generated') {
return (
<GeneratedNotice relativePath={notice.relativePath} onClose={onClose} />
);
}
if (notice.kind === 'saved') {
return <SimpleNotice title="保存成功" onClose={onClose} />;
}
return <FailureNotice notice={notice} onClose={onClose} />;
}
function GeneratedNotice({
relativePath,
onClose,