You've already forked DataMate
feat(data-management): 添加数据集类型判断并控制按行分割功能显示
- 从 dataset.model 中导入 DatasetType 类型定义 - 新增 isTextDataset 变量用于判断当前数据集是否为文本类型 - 将按行分割配置项包裹在条件渲染中,仅在文本数据集时显示 - 保持原有非文本文件禁用逻辑不变
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { Select, Input, Form, Radio, Modal, Button, UploadFile, Switch, Tooltip } from "antd";
|
import { Select, Input, Form, Radio, Modal, Button, UploadFile, Switch, Tooltip } from "antd";
|
||||||
import { InboxOutlined, QuestionCircleOutlined } from "@ant-design/icons";
|
import { InboxOutlined, QuestionCircleOutlined } from "@ant-design/icons";
|
||||||
import { dataSourceOptions } from "../../dataset.const";
|
import { dataSourceOptions } from "../../dataset.const";
|
||||||
import { Dataset, DataSource } from "../../dataset.model";
|
import { Dataset, DatasetType, DataSource } from "../../dataset.model";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { queryTasksUsingGet } from "@/pages/DataCollection/collection.apis";
|
import { queryTasksUsingGet } from "@/pages/DataCollection/collection.apis";
|
||||||
import { updateDatasetByIdUsingPut } from "../../dataset.api";
|
import { updateDatasetByIdUsingPut } from "../../dataset.api";
|
||||||
@@ -159,6 +159,7 @@ export default function ImportConfiguration({
|
|||||||
if (files.length === 0) return false;
|
if (files.length === 0) return false;
|
||||||
return files.some((file) => !isTextUploadFile(file));
|
return files.some((file) => !isTextUploadFile(file));
|
||||||
}, [importConfig.files]);
|
}, [importConfig.files]);
|
||||||
|
const isTextDataset = data?.datasetType === DatasetType.TEXT;
|
||||||
|
|
||||||
// 本地上传文件相关逻辑
|
// 本地上传文件相关逻辑
|
||||||
|
|
||||||
@@ -363,26 +364,28 @@ export default function ImportConfiguration({
|
|||||||
>
|
>
|
||||||
<Switch />
|
<Switch />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
{isTextDataset && (
|
||||||
label={
|
<Form.Item
|
||||||
<span>
|
label={
|
||||||
按分行分割{" "}
|
<span>
|
||||||
<Tooltip
|
按分行分割{" "}
|
||||||
title={
|
<Tooltip
|
||||||
hasNonTextFile
|
title={
|
||||||
? "已选择非文本文件,无法按行分割"
|
hasNonTextFile
|
||||||
: "选中后,文本文件的每一行将被分割成独立文件"
|
? "已选择非文本文件,无法按行分割"
|
||||||
}
|
: "选中后,文本文件的每一行将被分割成独立文件"
|
||||||
>
|
}
|
||||||
<QuestionCircleOutlined style={{ color: "#999" }} />
|
>
|
||||||
</Tooltip>
|
<QuestionCircleOutlined style={{ color: "#999" }} />
|
||||||
</span>
|
</Tooltip>
|
||||||
}
|
</span>
|
||||||
name="splitByLine"
|
}
|
||||||
valuePropName="checked"
|
name="splitByLine"
|
||||||
>
|
valuePropName="checked"
|
||||||
<Switch disabled={hasNonTextFile} />
|
>
|
||||||
</Form.Item>
|
<Switch disabled={hasNonTextFile} />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="上传文件"
|
label="上传文件"
|
||||||
name="files"
|
name="files"
|
||||||
|
|||||||
Reference in New Issue
Block a user