You've already forked DataMate
refactor(KnowledgeManagement): 优化知识集详情页面文件记录渲染逻辑
- 将重复的条件判断提取为变量 isFileRecord - 使用立即执行函数简化 JSX 结构 - 统一文件类型记录的操作按钮渲染方式 - 提高代码可读性和维护性
This commit is contained in:
@@ -335,8 +335,13 @@ const KnowledgeSetDetail = () => {
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
{(record.contentType === KnowledgeContentType.FILE ||
|
{(() => {
|
||||||
record.sourceType === KnowledgeSourceType.FILE_UPLOAD) && (
|
const isFileRecord =
|
||||||
|
record.contentType === KnowledgeContentType.FILE ||
|
||||||
|
record.sourceType === KnowledgeSourceType.FILE_UPLOAD;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{isFileRecord && (
|
||||||
<Tooltip title="预览">
|
<Tooltip title="预览">
|
||||||
<Button
|
<Button
|
||||||
type="text"
|
type="text"
|
||||||
@@ -347,8 +352,7 @@ const KnowledgeSetDetail = () => {
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
{(record.contentType === KnowledgeContentType.FILE ||
|
{isFileRecord && (
|
||||||
record.sourceType === KnowledgeSourceType.FILE_UPLOAD) && (
|
|
||||||
<Tooltip title="下载文件">
|
<Tooltip title="下载文件">
|
||||||
<Button
|
<Button
|
||||||
type="text"
|
type="text"
|
||||||
@@ -358,6 +362,7 @@ const KnowledgeSetDetail = () => {
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
|
{isFileRecord && (
|
||||||
<Button
|
<Button
|
||||||
type="text"
|
type="text"
|
||||||
icon={<EditOutlined />}
|
icon={<EditOutlined />}
|
||||||
@@ -368,8 +373,16 @@ const KnowledgeSetDetail = () => {
|
|||||||
});
|
});
|
||||||
setItemEditorOpen(true);
|
setItemEditorOpen(true);
|
||||||
}}
|
}}
|
||||||
disabled={isReadOnly || record.rawStatus === KnowledgeStatusType.ARCHIVED || record.rawStatus === KnowledgeStatusType.DEPRECATED}
|
disabled={
|
||||||
|
isReadOnly ||
|
||||||
|
record.rawStatus === KnowledgeStatusType.ARCHIVED ||
|
||||||
|
record.rawStatus === KnowledgeStatusType.DEPRECATED
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
<Button
|
<Button
|
||||||
type="text"
|
type="text"
|
||||||
danger
|
danger
|
||||||
|
|||||||
Reference in New Issue
Block a user