diff --git a/frontend/packages/market/src/const/serviceHub/type.ts b/frontend/packages/market/src/const/serviceHub/type.ts index 6e02a06b..605efa3f 100644 --- a/frontend/packages/market/src/const/serviceHub/type.ts +++ b/frontend/packages/market/src/const/serviceHub/type.ts @@ -54,9 +54,12 @@ export type ServiceHubTableListItem = { tags?: EntityItem[] catalogue: EntityItem apiNum: number - subscribeNum: number + subscriberNum: number description: string logo: string + enableMcp: boolean + serviceKind: 'ai' | 'rest' + invokeCount: number } export type ApplyServiceProps = { diff --git a/frontend/packages/market/src/pages/serviceHub/ServiceHubList.tsx b/frontend/packages/market/src/pages/serviceHub/ServiceHubList.tsx index a415fd33..1c9e9f3e 100644 --- a/frontend/packages/market/src/pages/serviceHub/ServiceHubList.tsx +++ b/frontend/packages/market/src/pages/serviceHub/ServiceHubList.tsx @@ -12,6 +12,8 @@ import { useNavigate, useParams } from 'react-router-dom' import { VirtuosoGrid } from 'react-virtuoso' import { CategorizesType, ServiceHubTableListItem } from '../../const/serviceHub/type.ts' import ServiceHubGroup from './ServiceHubGroup.tsx' +import { SERVICE_KIND_OPTIONS } from '@core/const/system/const.tsx' +import { Icon } from '@iconify/react/dist/iconify.js' export enum SERVICE_HUB_LIST_ACTIONS { GET_CATEGORIES = 'GET_CATEGORIES', @@ -103,7 +105,7 @@ const ServiceHubList: FC = () => { dispatch({ type: SERVICE_HUB_LIST_ACTIONS.LIST_LOADING, payload: true }) fetchData>('catalogue/services', { method: 'GET', - eoTransformKeys: ['api_num', 'subscriber_num'] + eoTransformKeys: ['api_num', 'subscriber_num', 'enable_mcp', 'service_kind', 'invoke_count'] }) .then((response) => { const { code, data, msg } = response @@ -154,13 +156,14 @@ const ServiceHubList: FC = () => {
showDocumentDetail(item)} > {item.description || $t('暂无服务描述')} +
) @@ -229,23 +232,70 @@ const CardTitle = (service: ServiceHubTableListItem) => { > {service.catalogue?.name || '-'} - - - - - {service.apiNum ?? '-'} - - - - - - - - {service.subscriberNum ?? '-'} - - + + {SERVICE_KIND_OPTIONS.find((x) => x.value === service.serviceKind)?.label || '-'} + + {service?.enableMcp && ( + + MCP + + )} ) } + +// 格式化调用次数,添加K和M单位 +const formatInvokeCount = (count: number | null | undefined): string => { + if (count === null || count === undefined) return '-' + if (count >= 1000000) { + const value = Math.floor(count / 100000) / 10 + return `${value}M` + } + if (count >= 1000) { + const value = Math.floor(count / 100) / 10 + return `${value}K` + } + return count.toString() +} + +const CardAction = (props: { service: ServiceHubTableListItem }) => { + const { service } = props + return ( +
+ + + + {service.apiNum ?? '-'} + + + + + + + + {service.subscriberNum ?? '-'} + + + + + + + + {formatInvokeCount(service.invokeCount)} + + +
+ ) +}