You've already forked DataMate
refactor(data-management): 优化文本数据集类型判断逻辑
- 添加 TEXT_DATASET_TYPE_PREFIX 常量定义 - 新增 isTextDataset 工具函数用于判断文本数据集类型 - 使用 isTextDataset 函数替换原有的直接比较逻辑 - 提高代码可读性和类型判断的准确性
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
|||||||
import { useParams } from "react-router";
|
import { useParams } from "react-router";
|
||||||
|
|
||||||
const OFFICE_FILE_EXTENSIONS = [".doc", ".docx"];
|
const OFFICE_FILE_EXTENSIONS = [".doc", ".docx"];
|
||||||
|
const TEXT_DATASET_TYPE_PREFIX = DatasetType.TEXT;
|
||||||
const OFFICE_PREVIEW_POLL_INTERVAL = 2000;
|
const OFFICE_PREVIEW_POLL_INTERVAL = 2000;
|
||||||
const OFFICE_PREVIEW_POLL_MAX_TIMES = 60;
|
const OFFICE_PREVIEW_POLL_MAX_TIMES = 60;
|
||||||
|
|
||||||
@@ -86,6 +87,13 @@ export function useFilesOperation(dataset: Dataset) {
|
|||||||
};
|
};
|
||||||
}, [clearOfficePreviewPolling]);
|
}, [clearOfficePreviewPolling]);
|
||||||
|
|
||||||
|
const isTextDataset = (datasetType?: string) => {
|
||||||
|
if (!datasetType) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return datasetType.toUpperCase().startsWith(TEXT_DATASET_TYPE_PREFIX);
|
||||||
|
};
|
||||||
|
|
||||||
const fetchFiles = async (
|
const fetchFiles = async (
|
||||||
prefix?: string,
|
prefix?: string,
|
||||||
current?: number,
|
current?: number,
|
||||||
@@ -93,7 +101,7 @@ export function useFilesOperation(dataset: Dataset) {
|
|||||||
) => {
|
) => {
|
||||||
// 如果明确传了 prefix(包括空字符串),使用传入的值;否则使用当前 pagination.prefix
|
// 如果明确传了 prefix(包括空字符串),使用传入的值;否则使用当前 pagination.prefix
|
||||||
const targetPrefix = prefix !== undefined ? prefix : (pagination.prefix || '');
|
const targetPrefix = prefix !== undefined ? prefix : (pagination.prefix || '');
|
||||||
const shouldExcludeDerivedFiles = dataset?.datasetType === DatasetType.TEXT;
|
const shouldExcludeDerivedFiles = isTextDataset(dataset?.datasetType);
|
||||||
|
|
||||||
const params: DatasetFilesQueryParams = {
|
const params: DatasetFilesQueryParams = {
|
||||||
page: current !== undefined ? current : pagination.current,
|
page: current !== undefined ? current : pagination.current,
|
||||||
|
|||||||
Reference in New Issue
Block a user