You've already forked DataMate
refactor(DataManagement): 简化文件操作逻辑并移除文本数据集类型检查
- 移除了未使用的 DatasetType 导入 - 删除了 TEXT_DATASET_TYPE_PREFIX 常量定义 - 移除了 isTextDataset 工具函数 - 直接设置 excludeDerivedFiles 参数为 true,简化查询逻辑
This commit is contained in:
@@ -2,7 +2,6 @@ import type {
|
||||
Dataset,
|
||||
DatasetFile,
|
||||
} from "@/pages/DataManagement/dataset.model";
|
||||
import { DatasetType } from "@/pages/DataManagement/dataset.model";
|
||||
import { App } from "antd";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
@@ -25,7 +24,6 @@ import {
|
||||
import { useParams } from "react-router";
|
||||
|
||||
const OFFICE_FILE_EXTENSIONS = [".doc", ".docx"];
|
||||
const TEXT_DATASET_TYPE_PREFIX = DatasetType.TEXT;
|
||||
const OFFICE_PREVIEW_POLL_INTERVAL = 2000;
|
||||
const OFFICE_PREVIEW_POLL_MAX_TIMES = 60;
|
||||
|
||||
@@ -87,13 +85,6 @@ export function useFilesOperation(dataset: Dataset) {
|
||||
};
|
||||
}, [clearOfficePreviewPolling]);
|
||||
|
||||
const isTextDataset = (datasetType?: string) => {
|
||||
if (!datasetType) {
|
||||
return false;
|
||||
}
|
||||
return datasetType.toUpperCase().startsWith(TEXT_DATASET_TYPE_PREFIX);
|
||||
};
|
||||
|
||||
const fetchFiles = async (
|
||||
prefix?: string,
|
||||
current?: number,
|
||||
@@ -101,14 +92,13 @@ export function useFilesOperation(dataset: Dataset) {
|
||||
) => {
|
||||
// 如果明确传了 prefix(包括空字符串),使用传入的值;否则使用当前 pagination.prefix
|
||||
const targetPrefix = prefix !== undefined ? prefix : (pagination.prefix || '');
|
||||
const shouldExcludeDerivedFiles = isTextDataset(dataset?.datasetType);
|
||||
|
||||
const params: DatasetFilesQueryParams = {
|
||||
page: current !== undefined ? current : pagination.current,
|
||||
size: pageSize !== undefined ? pageSize : pagination.pageSize,
|
||||
isWithDirectory: true,
|
||||
prefix: targetPrefix,
|
||||
...(shouldExcludeDerivedFiles ? { excludeDerivedFiles: true } : {}),
|
||||
excludeDerivedFiles: true,
|
||||
};
|
||||
|
||||
const { data } = await queryDatasetFilesUsingGet(id!, params);
|
||||
|
||||
Reference in New Issue
Block a user