|
- import BasicInfo, { type BasicInfoData } from '@/components/BasicInfo';
- import { ServiceRunStatus } from '@/enums';
- import { useComputingResource } from '@/hooks/useComputingResource';
- import { ServiceVersionData } from '@/pages/ModelDeployment/types';
- import { formatDate } from '@/utils/date';
- import { formatCodeConfig, formatModel } from '@/utils/format';
- import { Flex } from 'antd';
- import ModelDeployStatusCell from '../ModelDeployStatusCell';
-
- type BasicInfoProps = {
- info?: ServiceVersionData;
- };
-
- // 格式化状态
- const formatStatus = (status?: ServiceRunStatus) => {
- if (!status) {
- return undefined;
- }
-
- return (
- <Flex align="center" style={{ fontSize: '16px', lineHeight: 1.6 }}>
- {ModelDeployStatusCell(status)}
- </Flex>
- );
- };
-
- // 格式化环境变量
- const formatEnvText = (env?: Record<string, string>) => {
- if (!env || Object.keys(env).length === 0) {
- return undefined;
- }
-
- return Object.entries(env).map(([key, value]) => ({
- value: `${key}: ${value}`,
- }));
- };
-
- function VersionBasicInfo({ info }: BasicInfoProps) {
- const getResourceDescription = useComputingResource()[1];
-
- const datas: BasicInfoData[] = [
- {
- label: '服务名称',
- value: info?.service_name,
- },
- {
- label: '版本名称',
- value: info?.version,
- },
- {
- label: '代码配置',
- value: info?.code_config,
- format: formatCodeConfig,
- },
- {
- label: '镜像',
- value: info?.image,
- },
- {
- label: '状态',
- value: info?.run_state,
- format: formatStatus,
- },
- {
- label: '模型',
- value: info?.model,
- format: formatModel,
- },
- {
- label: '资源规格',
- value: info?.computing_resource_id,
- format: getResourceDescription,
- },
- {
- label: '挂载路径',
- value: info?.mount_path,
- },
- {
- label: 'API URL',
- value: info?.url,
- },
- {
- label: '文档地址',
- value: info?.doc_path,
- },
- {
- label: '副本数量',
- value: info?.replicas,
- },
- {
- label: '创建时间',
- value: info?.create_time,
- format: formatDate,
- },
- {
- label: '更新时间',
- value: info?.update_time,
- format: formatDate,
- },
- {
- label: '环境变量',
- value: info?.env_variables,
- format: formatEnvText,
- },
- {
- label: '描述',
- value: info?.description,
- },
- ];
-
- return (
- <BasicInfo
- datas={datas}
- labelWidth={66}
- labelAlign="justify"
- style={{ marginTop: 10 }}
- ></BasicInfo>
- );
- }
-
- export default VersionBasicInfo;
|