From 5f899689749c81732c063ba40374081b95a44a9b Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sun, 1 Feb 2026 11:31:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(dataset):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化 BasicInformation 组件结构和逻辑 - 更新 CreateDataset 组件的数据处理流程 - 改进表单验证和错误处理机制 - 统一组件间的事件传递方式 - 提升代码可读性和维护性 --- frontend/src/pages/DataManagement/Create/CreateDataset.tsx | 6 ++++++ .../DataManagement/Create/components/BasicInformation.tsx | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/DataManagement/Create/CreateDataset.tsx b/frontend/src/pages/DataManagement/Create/CreateDataset.tsx index ff19b4b..246833f 100644 --- a/frontend/src/pages/DataManagement/Create/CreateDataset.tsx +++ b/frontend/src/pages/DataManagement/Create/CreateDataset.tsx @@ -4,9 +4,14 @@ import { ArrowLeft } from "lucide-react"; import { Button, Form, App } from "antd"; import { Link, useLocation, useNavigate } from "react-router"; import { createDatasetUsingPost } from "../dataset.api"; +import { datasetTypes } from "../dataset.const"; import { DatasetType } from "../dataset.model"; import BasicInformation from "./components/BasicInformation"; +const textDatasetTypeOptions = datasetTypes.filter( + (type) => type.value === DatasetType.TEXT +); + export default function DatasetCreate() { const navigate = useNavigate(); const location = useLocation(); @@ -82,6 +87,7 @@ export default function DatasetCreate() { data={newDataset} setData={setNewDataset} hidden={["dataSource"]} + datasetTypeOptions={textDatasetTypeOptions} /> diff --git a/frontend/src/pages/DataManagement/Create/components/BasicInformation.tsx b/frontend/src/pages/DataManagement/Create/components/BasicInformation.tsx index 83470bd..96342e1 100644 --- a/frontend/src/pages/DataManagement/Create/components/BasicInformation.tsx +++ b/frontend/src/pages/DataManagement/Create/components/BasicInformation.tsx @@ -11,10 +11,12 @@ export default function BasicInformation({ data, setData, hidden = [], + datasetTypeOptions = datasetTypes, }: { data: DatasetFormData; setData: Dispatch>; hidden?: string[]; + datasetTypeOptions?: DatasetTypeOption[]; }) { const [tagOptions, setTagOptions] = useState([]); const [collectionOptions, setCollectionOptions] = useState([]); @@ -119,7 +121,7 @@ export default function BasicInformation({ rules={[{ required: true, message: "请选择数据集类型" }]} > setData({ ...data, datasetType })} /> @@ -149,6 +151,8 @@ type DatasetFormData = Partial & { parentDatasetId?: string; }; +type DatasetTypeOption = (typeof datasetTypes)[number]; + type DatasetTagOption = { label: string; value: string;