简化保存结果弹窗内容分支
用显式早返回替换嵌套三元渲染
This commit is contained in:
+17
-7
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user