小红书工作台顶部槽位改用 if/else 摊开
- ArtifactsPane 把表单 / 读取中 / 读失败留白 / 自动重试的四路链式三元抽成 formSlot,JSX 只剩一个插槽
This commit is contained in:
+27
-17
@@ -1,4 +1,5 @@
|
||||
import { openUrl } from '@tauri-apps/plugin-opener';
|
||||
import type { ReactNode } from 'react';
|
||||
|
||||
import type { XhsMinitoolExportState } from '../../state/useXhsMinitoolExport';
|
||||
import { saveXhsMinitoolFileToDisk } from '../../state/xhsMinitoolDownload';
|
||||
@@ -69,29 +70,38 @@ export function ArtifactsPane({
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 左半顶部槽位:整张表单 / 一行读取中 / 什么都不放(读失败由弹窗拿着现场)/ 一行自动重试兜底。
|
||||
* 四种形状差得远,用 if/else 摊开算好,JSX 里只留一个 `{formSlot}`,别把控制流埋进链式三元。
|
||||
*/
|
||||
let formSlot: ReactNode = null;
|
||||
if (form) {
|
||||
formSlot = (
|
||||
<FormCard
|
||||
form={form}
|
||||
fieldError={minitool.fieldError}
|
||||
projectPath={projectPath}
|
||||
onChange={minitool.updateField}
|
||||
onDownloadIcon={downloadIcon}
|
||||
onAskAgentToFill={() => void minitool.fillForm()}
|
||||
/>
|
||||
);
|
||||
} else if (!minitool.readSettled) {
|
||||
formSlot = <p className="text-xs text-[#988476]">正在读取导出信息…</p>;
|
||||
} else if (!failure) {
|
||||
// 读失败时上面不重复一句话:失败弹窗拿着宿主的现场和下一步。
|
||||
formSlot = (
|
||||
<p className="text-xs text-[#988476]">没能读到导出信息,正在自动重试…</p>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex h-full min-h-0 min-w-0 flex-col border-[#e2cbb8] bg-[#fffdf9]/40 md:border-r"
|
||||
aria-label="导出内容区"
|
||||
>
|
||||
<div className="flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-3">
|
||||
{form ? (
|
||||
<FormCard
|
||||
form={form}
|
||||
fieldError={minitool.fieldError}
|
||||
projectPath={projectPath}
|
||||
onChange={minitool.updateField}
|
||||
onDownloadIcon={downloadIcon}
|
||||
onAskAgentToFill={() => void minitool.fillForm()}
|
||||
/>
|
||||
) : !minitool.readSettled ? (
|
||||
<p className="text-xs text-[#988476]">正在读取导出信息…</p>
|
||||
) : // 读失败时上面不重复一句话:失败弹窗拿着宿主的现场和下一步。
|
||||
failure ? null : (
|
||||
<p className="text-xs text-[#988476]">
|
||||
没能读到导出信息,正在自动重试…
|
||||
</p>
|
||||
)}
|
||||
{formSlot}
|
||||
|
||||
<section
|
||||
className="rounded-2xl border border-[#e2cbb8] bg-[#fffaf5] p-4"
|
||||
|
||||
Reference in New Issue
Block a user