From 9c4ead5ea38045b7ae7ced7ec177d4c26bd0aa5f Mon Sep 17 00:00:00 2001 From: zhaowei Date: Mon, 21 Jul 2025 10:59:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/Home/components/Service/index.tsx | 42 +++++++++- .../Home/components/Statistics/index.tsx | 81 +++++++++++-------- react-ui/src/services/home/index.ts | 17 ++++ 3 files changed, 106 insertions(+), 34 deletions(-) create mode 100644 react-ui/src/services/home/index.ts diff --git a/react-ui/src/pages/Home/components/Service/index.tsx b/react-ui/src/pages/Home/components/Service/index.tsx index 343e5aec..4b97e48c 100644 --- a/react-ui/src/pages/Home/components/Service/index.tsx +++ b/react-ui/src/pages/Home/components/Service/index.tsx @@ -2,12 +2,16 @@ import ServiceImg1 from '@/assets/img/home/service1.png'; import ServiceImg2 from '@/assets/img/home/service2.png'; import ServiceImg3 from '@/assets/img/home/service3.png'; import ServiceImg4 from '@/assets/img/home/service4.png'; +import { type ServiceData } from '@/pages/ModelDeployment/types'; +import { getAssetPublicCountReq } from '@/services/home'; +import { to } from '@/utils/promise'; import { useNavigate } from '@umijs/max'; import { Flex } from 'antd'; +import { useEffect, useState } from 'react'; import BlockTitle from '../BlockTitle'; import styles from './index.less'; -const serviceData = [ +const serviceData1 = [ { id: 1, img: ServiceImg1, @@ -41,6 +45,40 @@ const serviceData = [ function ServiceBlock() { const navigate = useNavigate(); + const [serviceData, setServiceData] = useState([]); + useEffect(() => { + const getAssetPublicCount = async () => { + const [res] = await to(getAssetPublicCountReq()); + if (res && res.data) { + const { dataset, image, model, codeConfig, service } = res.data; + const items = [ + { + title: '数据集', + value: dataset, + }, + { + title: '模型', + value: model, + }, + { + title: '镜像', + value: image, + }, + { + title: '代码配置', + value: codeConfig, + }, + { + title: '服务', + value: service, + }, + ]; + //setServiceData(items); + } + }; + + getAssetPublicCount(); + }, []); return (
navigate('/dataset/modelDeployment')} > - {serviceData.map((item) => { + {serviceData1.map((item) => { return (
diff --git a/react-ui/src/pages/Home/components/Statistics/index.tsx b/react-ui/src/pages/Home/components/Statistics/index.tsx index 5f383c09..490a1e2a 100644 --- a/react-ui/src/pages/Home/components/Statistics/index.tsx +++ b/react-ui/src/pages/Home/components/Statistics/index.tsx @@ -3,46 +3,63 @@ import DatasetIcon from '@/assets/img/home/dataset.png'; import ImageIcon from '@/assets/img/home/image.png'; import ModelIcon from '@/assets/img/home/model.png'; import ServiceIcon from '@/assets/img/home/service.png'; +import { getAssetPublicCountReq } from '@/services/home'; +import { to } from '@/utils/promise'; +import { useEffect, useState } from 'react'; import styles from './index.less'; -const dataList = [ - { - icon: DatasetIcon, - name: '数据集', - count: 30, - }, - { - icon: ModelIcon, - name: '模型', - count: 30, - }, - { - icon: ImageIcon, - name: '镜像', - count: 30, - }, - { - icon: CodeIcon, - name: '代码', - count: 30, - }, - { - icon: ServiceIcon, - name: '服务', - count: 30, - }, -]; - function StatisticsBlock() { + const [assetCounts, setAssetCounts] = useState<{ title: string; value: number; icon: string }[]>( + [], + ); + useEffect(() => { + const getAssetPublicCount = async () => { + const [res] = await to(getAssetPublicCountReq()); + if (res && res.data) { + const { dataset, image, model, codeConfig, service } = res.data; + const items = [ + { + title: '数据集', + value: dataset, + icon: DatasetIcon, + }, + { + title: '模型', + value: model, + icon: ModelIcon, + }, + { + title: '镜像', + value: image, + icon: ImageIcon, + }, + { + title: '代码配置', + value: codeConfig, + icon: CodeIcon, + }, + { + title: '服务', + value: service, + icon: ServiceIcon, + }, + ]; + setAssetCounts(items); + } + }; + + getAssetPublicCount(); + }, []); + return (
- {dataList.map((item) => { + {assetCounts.map((item) => { return ( -
+
-
{item.count}
-
{item.name}
+
{item.value}
+
{item.title}
); diff --git a/react-ui/src/services/home/index.ts b/react-ui/src/services/home/index.ts new file mode 100644 index 00000000..57875d00 --- /dev/null +++ b/react-ui/src/services/home/index.ts @@ -0,0 +1,17 @@ +/* + * @Author: 赵伟 + * @Date: 2025-07-21 14:29:44 + * @Description: 首页 + */ + +import { request } from '@umijs/max'; + +// 获取公开的资源数量 +export function getAssetPublicCountReq() { + return request('/api/mmp/workspace/assetPublicCount', { + method: 'GET', + headers: { + isToken: false, + }, + }); +}