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