You've already forked DataMate
refactor(DataManagement): 重构数据管理详情页面组件
- 移除 Overview 组件中的文件列表多选配置功能 - 添加 DatasetFileRow 类型定义并更新相关类型注解 - 修改 Overview 组件属性接口,增加 onUpload 回调函数 - 更新表格渲染函数中的类型注解,统一使用 DatasetFileRow 类型 - 简化按钮点击事件处理函数的参数传递 - 在 DatasetDetail 页面中移除顶部工具栏的上传按钮 - 将上传功能集成到 Overview 组件的文件操作区域 - 通过回调函数实现
This commit is contained in:
@@ -3,7 +3,6 @@ import { Breadcrumb, App, Tabs, Table, Tag } from "antd";
|
|||||||
import {
|
import {
|
||||||
ReloadOutlined,
|
ReloadOutlined,
|
||||||
DownloadOutlined,
|
DownloadOutlined,
|
||||||
UploadOutlined,
|
|
||||||
EditOutlined,
|
EditOutlined,
|
||||||
DeleteOutlined,
|
DeleteOutlined,
|
||||||
PlusOutlined,
|
PlusOutlined,
|
||||||
@@ -226,12 +225,6 @@ export default function DatasetDetail() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
|
||||||
key: "upload",
|
|
||||||
label: "导入数据",
|
|
||||||
icon: <UploadOutlined />,
|
|
||||||
onClick: () => setShowUploadDialog(true),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: "export",
|
key: "export",
|
||||||
label: "导出",
|
label: "导出",
|
||||||
@@ -353,7 +346,12 @@ export default function DatasetDetail() {
|
|||||||
<Tabs activeKey={activeTab} items={tabList} onChange={setActiveTab} />
|
<Tabs activeKey={activeTab} items={tabList} onChange={setActiveTab} />
|
||||||
<div className="h-full overflow-auto">
|
<div className="h-full overflow-auto">
|
||||||
{activeTab === "overview" && (
|
{activeTab === "overview" && (
|
||||||
<Overview dataset={dataset} filesOperation={filesOperation} fetchDataset={fetchDataset}/>
|
<Overview
|
||||||
|
dataset={dataset}
|
||||||
|
filesOperation={filesOperation}
|
||||||
|
fetchDataset={fetchDataset}
|
||||||
|
onUpload={() => setShowUploadDialog(true)}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{activeTab === "children" && (
|
{activeTab === "children" && (
|
||||||
<div className="pt-4">
|
<div className="pt-4">
|
||||||
|
|||||||
@@ -2,14 +2,25 @@ import { App, Button, Descriptions, DescriptionsProps, Modal, Table, Input } fro
|
|||||||
import { formatBytes, formatDateTime } from "@/utils/unit";
|
import { formatBytes, formatDateTime } from "@/utils/unit";
|
||||||
import { Download, Trash2, Folder, File } from "lucide-react";
|
import { Download, Trash2, Folder, File } from "lucide-react";
|
||||||
import { datasetTypeMap } from "../../dataset.const";
|
import { datasetTypeMap } from "../../dataset.const";
|
||||||
|
import type { DatasetFile } from "@/pages/DataManagement/dataset.model";
|
||||||
|
|
||||||
export default function Overview({ dataset, filesOperation, fetchDataset }) {
|
type DatasetFileRow = DatasetFile & {
|
||||||
|
fileSize?: number;
|
||||||
|
fileCount?: number;
|
||||||
|
uploadTime?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Overview({
|
||||||
|
dataset,
|
||||||
|
filesOperation,
|
||||||
|
fetchDataset,
|
||||||
|
onUpload,
|
||||||
|
}) {
|
||||||
const { modal, message } = App.useApp();
|
const { modal, message } = App.useApp();
|
||||||
const {
|
const {
|
||||||
fileList,
|
fileList,
|
||||||
pagination,
|
pagination,
|
||||||
selectedFiles,
|
selectedFiles,
|
||||||
setSelectedFiles,
|
|
||||||
previewVisible,
|
previewVisible,
|
||||||
previewFileName,
|
previewFileName,
|
||||||
previewContent,
|
previewContent,
|
||||||
@@ -23,17 +34,6 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) {
|
|||||||
handleDeleteDirectory,
|
handleDeleteDirectory,
|
||||||
} = filesOperation;
|
} = filesOperation;
|
||||||
|
|
||||||
// 文件列表多选配置
|
|
||||||
const rowSelection = {
|
|
||||||
onChange: (selectedRowKeys: React.Key[], selectedRows: any[]) => {
|
|
||||||
setSelectedFiles(selectedRowKeys as number[]);
|
|
||||||
console.log(
|
|
||||||
`selectedRowKeys: ${selectedRowKeys}`,
|
|
||||||
"selectedRows: ",
|
|
||||||
selectedRows
|
|
||||||
);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
// 基本信息
|
// 基本信息
|
||||||
const items: DescriptionsProps["items"] = [
|
const items: DescriptionsProps["items"] = [
|
||||||
{
|
{
|
||||||
@@ -96,7 +96,7 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) {
|
|||||||
dataIndex: "fileName",
|
dataIndex: "fileName",
|
||||||
key: "fileName",
|
key: "fileName",
|
||||||
fixed: "left",
|
fixed: "left",
|
||||||
render: (text: string, record: any) => {
|
render: (text: string, record: DatasetFileRow) => {
|
||||||
const isDirectory = record.id.startsWith('directory-');
|
const isDirectory = record.id.startsWith('directory-');
|
||||||
const iconSize = 16;
|
const iconSize = 16;
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) {
|
|||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
onClick={(e) => {
|
onClick={() => {
|
||||||
const currentPath = filesOperation.pagination.prefix || '';
|
const currentPath = filesOperation.pagination.prefix || '';
|
||||||
// 文件夹路径必须以斜杠结尾
|
// 文件夹路径必须以斜杠结尾
|
||||||
const newPath = `${currentPath}${record.fileName}/`;
|
const newPath = `${currentPath}${record.fileName}/`;
|
||||||
@@ -130,7 +130,7 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) {
|
|||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
onClick={(e) => {}}
|
onClick={() => {}}
|
||||||
>
|
>
|
||||||
{content}
|
{content}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -142,7 +142,7 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) {
|
|||||||
dataIndex: "fileSize",
|
dataIndex: "fileSize",
|
||||||
key: "fileSize",
|
key: "fileSize",
|
||||||
width: 150,
|
width: 150,
|
||||||
render: (text: number, record: any) => {
|
render: (text: number, record: DatasetFileRow) => {
|
||||||
const isDirectory = record.id.startsWith('directory-');
|
const isDirectory = record.id.startsWith('directory-');
|
||||||
if (isDirectory) {
|
if (isDirectory) {
|
||||||
return formatBytes(record.fileSize || 0);
|
return formatBytes(record.fileSize || 0);
|
||||||
@@ -155,7 +155,7 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) {
|
|||||||
dataIndex: "fileCount",
|
dataIndex: "fileCount",
|
||||||
key: "fileCount",
|
key: "fileCount",
|
||||||
width: 120,
|
width: 120,
|
||||||
render: (text: number, record: any) => {
|
render: (text: number, record: DatasetFileRow) => {
|
||||||
const isDirectory = record.id.startsWith('directory-');
|
const isDirectory = record.id.startsWith('directory-');
|
||||||
if (!isDirectory) {
|
if (!isDirectory) {
|
||||||
return "-";
|
return "-";
|
||||||
@@ -175,7 +175,7 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) {
|
|||||||
key: "action",
|
key: "action",
|
||||||
width: 180,
|
width: 180,
|
||||||
fixed: "right",
|
fixed: "right",
|
||||||
render: (_, record) => {
|
render: (_, record: DatasetFileRow) => {
|
||||||
const isDirectory = record.id.startsWith('directory-');
|
const isDirectory = record.id.startsWith('directory-');
|
||||||
|
|
||||||
if (isDirectory) {
|
if (isDirectory) {
|
||||||
@@ -254,36 +254,41 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) {
|
|||||||
{/* 文件列表 */}
|
{/* 文件列表 */}
|
||||||
<div className="flex items-center justify-between mt-8 mb-2">
|
<div className="flex items-center justify-between mt-8 mb-2">
|
||||||
<h2 className="text-base font-semibold">文件列表</h2>
|
<h2 className="text-base font-semibold">文件列表</h2>
|
||||||
<Button
|
<div className="flex items-center gap-2">
|
||||||
type="primary"
|
<Button size="small" onClick={() => onUpload?.()}>
|
||||||
size="small"
|
文件上传
|
||||||
onClick={() => {
|
</Button>
|
||||||
let dirName = "";
|
<Button
|
||||||
modal.confirm({
|
type="primary"
|
||||||
title: "新建文件夹",
|
size="small"
|
||||||
content: (
|
onClick={() => {
|
||||||
<Input
|
let dirName = "";
|
||||||
autoFocus
|
modal.confirm({
|
||||||
placeholder="请输入文件夹名称"
|
title: "新建文件夹",
|
||||||
onChange={(e) => {
|
content: (
|
||||||
dirName = e.target.value?.trim();
|
<Input
|
||||||
}}
|
autoFocus
|
||||||
/>
|
placeholder="请输入文件夹名称"
|
||||||
),
|
onChange={(e) => {
|
||||||
okText: "确定",
|
dirName = e.target.value?.trim();
|
||||||
cancelText: "取消",
|
}}
|
||||||
onOk: async () => {
|
/>
|
||||||
if (!dirName) {
|
),
|
||||||
message.warning("请输入文件夹名称");
|
okText: "确定",
|
||||||
return Promise.reject();
|
cancelText: "取消",
|
||||||
}
|
onOk: async () => {
|
||||||
await handleCreateDirectory(dirName);
|
if (!dirName) {
|
||||||
},
|
message.warning("请输入文件夹名称");
|
||||||
});
|
return Promise.reject();
|
||||||
}}
|
}
|
||||||
>
|
await handleCreateDirectory(dirName);
|
||||||
新建文件夹
|
},
|
||||||
</Button>
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
新建文件夹
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{selectedFiles.length > 0 && (
|
{selectedFiles.length > 0 && (
|
||||||
<div className="flex items-center gap-2 p-3 bg-blue-50 rounded-lg border border-blue-200">
|
<div className="flex items-center gap-2 p-3 bg-blue-50 rounded-lg border border-blue-200">
|
||||||
|
|||||||
Reference in New Issue
Block a user