From 0dba604cd385b42a8180e8d9c9c7b6477f12e162 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 29 Jan 2026 14:37:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor(KnowledgeItemEditor):=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E7=9F=A5=E8=AF=86=E9=A1=B9=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 提取创建模式判断逻辑为独立变量 isCreateMode - 使用条件渲染替代原有的 data?.id 判断 - 将表单字段按照创建和编辑模式进行分组重构 - 优化文件上传和替换功能的显示逻辑 - 改进代码可读性和维护性 --- .../components/KnowledgeItemEditor.tsx | 177 +++++++++--------- 1 file changed, 91 insertions(+), 86 deletions(-) diff --git a/frontend/src/pages/KnowledgeManagement/components/KnowledgeItemEditor.tsx b/frontend/src/pages/KnowledgeManagement/components/KnowledgeItemEditor.tsx index e4d4c1d..77a89ba 100644 --- a/frontend/src/pages/KnowledgeManagement/components/KnowledgeItemEditor.tsx +++ b/frontend/src/pages/KnowledgeManagement/components/KnowledgeItemEditor.tsx @@ -51,7 +51,8 @@ export default function KnowledgeItemEditor({ const isFileItem = data?.contentType === KnowledgeContentType.FILE || data?.sourceType === KnowledgeSourceType.FILE_UPLOAD; - const contentTypeLabel = !data?.id + const isCreateMode = !data?.id; + const contentTypeLabel = isCreateMode ? "文件" : data?.contentType === KnowledgeContentType.MARKDOWN ? "Markdown" @@ -294,22 +295,7 @@ export default function KnowledgeItemEditor({ okButtonProps={{ disabled: readOnly }} >
-
- - - - - + + + - - - - -
-
- - - - - - -
-
- - - - - + + + + +
+
+ + + + + + +
+
+ + + + +