From 53dc40411306dc86c3a025342ae1953ee90c7b99 Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Thu, 6 Jun 2024 11:18:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=BC=94=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/package.json | 1 + .../components/ResourceIntro/index.less | 23 +- .../components/ResourceIntro/index.tsx | 85 ++- .../components/ResourceVersion/index.tsx | 50 +- .../DatasetAnnotation/index.tsx | 2 +- .../Model/components/GraphLegand/index.less | 17 + .../Model/components/GraphLegand/index.tsx | 55 ++ .../components/ModelEvolution/index.less | 18 + .../Model/components/ModelEvolution/index.tsx | 484 ++++++++++++++++++ .../Model/components/NodeTooltips/index.less | 56 ++ .../Model/components/NodeTooltips/index.tsx | 73 +++ .../Pipeline/components/ModelMenu/index.less | 12 +- .../Pipeline/components/ModelMenu/index.tsx | 1 + .../pages/Pipeline/editPipeline/index.less | 9 +- .../Workspace/components/QuickStart/index.tsx | 4 +- react-ui/src/requestConfig.ts | 1 + react-ui/src/services/dataset/index.js | 8 + react-ui/src/types.ts | 7 +- react-ui/src/utils/index.ts | 99 +++- react-ui/src/utils/ui.tsx | 2 + 20 files changed, 934 insertions(+), 73 deletions(-) create mode 100644 react-ui/src/pages/Model/components/GraphLegand/index.less create mode 100644 react-ui/src/pages/Model/components/GraphLegand/index.tsx create mode 100644 react-ui/src/pages/Model/components/NodeTooltips/index.less create mode 100644 react-ui/src/pages/Model/components/NodeTooltips/index.tsx diff --git a/react-ui/package.json b/react-ui/package.json index 1534f11..ac2bc99 100644 --- a/react-ui/package.json +++ b/react-ui/package.json @@ -57,6 +57,7 @@ "@ant-design/pro-components": "^2.4.4", "@ant-design/use-emotion-css": "1.0.4", "@antv/g6": "^4.8.24", + "@antv/hierarchy": "^0.6.12", "@umijs/route-utils": "^4.0.1", "antd": "^5.4.4", "classnames": "^2.3.2", diff --git a/react-ui/src/pages/Dataset/components/ResourceIntro/index.less b/react-ui/src/pages/Dataset/components/ResourceIntro/index.less index cff0a9e..3c4fcae 100644 --- a/react-ui/src/pages/Dataset/components/ResourceIntro/index.less +++ b/react-ui/src/pages/Dataset/components/ResourceIntro/index.less @@ -2,13 +2,10 @@ height: 100%; &__top { - display: flex; - flex-direction: column; - justify-content: space-between; width: 100%; height: 110px; margin-bottom: 10px; - padding: 25px 30px; + padding: 20px 30px 0; background-image: url(/assets/images/dataset-back.png); background-repeat: no-repeat; background-position: top center; @@ -17,7 +14,7 @@ &__name { margin-bottom: 12px; color: @text-color; - font-size: 20; + font-size: 20px; } &__tag { @@ -36,6 +33,22 @@ background: #ffffff; border-radius: 10px; box-shadow: 0px 2px 12px rgba(180, 182, 191, 0.09); + + :global { + .ant-tabs { + height: 100%; + .ant-tabs-content-holder { + height: 100%; + .ant-tabs-content { + height: 100%; + .ant-tabs-tabpane { + height: 100%; + overflow-y: auto; + } + } + } + } + } } &__title { diff --git a/react-ui/src/pages/Dataset/components/ResourceIntro/index.tsx b/react-ui/src/pages/Dataset/components/ResourceIntro/index.tsx index 813abdb..0a0717f 100644 --- a/react-ui/src/pages/Dataset/components/ResourceIntro/index.tsx +++ b/react-ui/src/pages/Dataset/components/ResourceIntro/index.tsx @@ -1,3 +1,4 @@ +import ModelEvolution from '@/pages/Model/components/ModelEvolution'; import { to } from '@/utils/promise'; import { useParams, useSearchParams } from '@umijs/max'; import { Flex, Tabs } from 'antd'; @@ -12,14 +13,19 @@ type ResourceIntroProps = { const ResourceIntro = ({ resourceType }: ResourceIntroProps) => { const [info, setInfo] = useState({} as ResourceData); - const locationParams = useParams(); //新版本获取路由参数接口 + const locationParams = useParams(); const [searchParams] = useSearchParams(); + const [versionList, setVersionList] = useState([]); + const [version, setVersion] = useState(undefined); const isPublic = searchParams.get('isPublic') === 'true'; + const defaultTab = searchParams.get('tab') || '1'; + let versionParam = searchParams.get('version'); const resourceId = Number(locationParams.id); - const name = resourceConfig[resourceType].name; + const typeName = resourceConfig[resourceType].name; // 数据集/模型 useEffect(() => { getModelByDetail(); + getVersionList(); }, []); // 获取详情 @@ -31,10 +37,39 @@ const ResourceIntro = ({ resourceType }: ResourceIntroProps) => { } }; + // 获取版本列表 + const getVersionList = async () => { + const request = resourceConfig[resourceType].getVersions; + const [res] = await to(request(resourceId)); + if (res && res.data && res.data.length > 0) { + setVersionList( + res.data.map((item: string) => { + return { + label: item, + value: item, + }; + }), + ); + if (versionParam) { + setVersion(versionParam); + versionParam = null; + } else { + setVersion(res.data[0]); + } + } else { + setVersion(undefined); + } + }; + + // 版本变化 + const handleVersionChange = (value: string) => { + setVersion(value); + }; + const items = [ { key: '1', - label: `${name}简介`, + label: `${typeName}简介`, children: ( <>
简介
@@ -44,18 +79,38 @@ const ResourceIntro = ({ resourceType }: ResourceIntroProps) => { }, { key: '2', - label: `${name}文件/版本`, + label: `${typeName}文件/版本`, children: ( ), }, ]; + if (resourceType === ResourceType.Model) { + items.push({ + key: '3', + label: `模型演化`, + children: ( + + ), + }); + } + const infoTypePropertyName = resourceConfig[resourceType] .infoTypePropertyName as keyof ResourceData; const infoTagPropertyName = resourceConfig[resourceType] @@ -64,21 +119,25 @@ const ResourceIntro = ({ resourceType }: ResourceIntroProps) => { return (
- {info.name} +
{info.name}
- {name} id:{info.id} -
-
- {info[infoTypePropertyName] || '--'} -
-
- {info[infoTagPropertyName] || '--'} + {typeName} id:{info.id}
+ {info[infoTypePropertyName] && ( +
+ {info[infoTypePropertyName] || '--'} +
+ )} + {info[infoTagPropertyName] && ( +
+ {info[infoTagPropertyName] || '--'} +
+ )}
- +
); diff --git a/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx b/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx index 08035fd..ec35387 100644 --- a/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx +++ b/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx @@ -2,14 +2,13 @@ import CommonTableCell from '@/components/CommonTableCell'; import DateTableCell from '@/components/DateTableCell'; import KFIcon from '@/components/KFIcon'; import AddVersionModal from '@/pages/Dataset/components/AddVersionModal'; -import { ResourceType } from '@/pages/Dataset/config'; +import { ResourceFileData, ResourceType, resourceConfig } from '@/pages/Dataset/config'; import { downLoadZip } from '@/utils/downloadfile'; import { openAntdModal } from '@/utils/modal'; import { to } from '@/utils/promise'; import { modalConfirm } from '@/utils/ui'; import { App, Button, Flex, Select, Table } from 'antd'; import { useEffect, useState } from 'react'; -import { ResourceFileData, resourceConfig } from '../../config'; import styles from './index.less'; type ResourceVersionProps = { @@ -17,42 +16,32 @@ type ResourceVersionProps = { resourceId: number; resourceName: string; isPublic: boolean; + versionList: { label: string; value: string }[]; + version?: string; + getVersionList: () => void; + onVersionChange: (version: string) => void; }; function ResourceVersion({ resourceType, resourceId, resourceName, isPublic, + versionList, + version, + getVersionList, + onVersionChange, }: ResourceVersionProps) { - const [versionList, setVersionList] = useState([]); - const [version, setVersion] = useState(undefined); const [fileList, setFileList] = useState([]); const { message } = App.useApp(); + // 获取版本文件列表 useEffect(() => { - getVersionList(); - }, []); - - // 获取版本列表 - const getVersionList = async () => { - const request = resourceConfig[resourceType].getVersions; - const [res] = await to(request(resourceId)); - if (res && res.data && res.data.length > 0) { - setVersionList( - res.data.map((item: string) => { - return { - label: item, - value: item, - }; - }), - ); - setVersion(res.data[0]); - getFileList(res.data[0]); + if (version) { + getFileList(version); } else { - setVersion(undefined); setFileList([]); } - }; + }, [resourceId, version]); // 获取版本下的文件列表 const getFileList = async (version: string) => { @@ -120,16 +109,6 @@ function ResourceVersion({ downLoadZip(`${url}/${record.id}`); }; - // 版本变化 - const handleChange = (value: string) => { - if (value) { - getFileList(value); - setVersion(value); - } else { - setVersion(undefined); - } - }; - const columns = [ { title: '序号', @@ -194,8 +173,7 @@ function ResourceVersion({ placeholder="请选择版本号" style={{ width: '160px', marginRight: '20px' }} value={version} - allowClear - onChange={handleChange} + onChange={onVersionChange} options={versionList} />