You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 2.7 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * @Author: 赵伟
  3. * @Date: 2024-04-16 13:58:08
  4. * @Description: 服务版本详情
  5. */
  6. import IframePage from '@/components/IFramePage';
  7. import KFIcon from '@/components/KFIcon';
  8. import PageTitle from '@/components/PageTitle';
  9. import { ServiceRunStatus } from '@/enums';
  10. import { getServiceVersionInfoReq } from '@/services/modelDeployment';
  11. import { to } from '@/utils/promise';
  12. import { useParams } from '@umijs/max';
  13. import { Tabs } from 'antd';
  14. import { useEffect, useState } from 'react';
  15. import ServerLog from '../components/ServerLog';
  16. import VersionBasicInfo from '../components/VersionBasicInfo';
  17. import { ServiceVersionData } from '../types';
  18. import styles from './index.less';
  19. export enum ModelDeploymentTabKey {
  20. Basic = 'Basic', // 基本信息
  21. Predict = 'Predict', // 预测
  22. Guide = 'Guide', // 调用指南
  23. Log = 'Log', // 服务日志
  24. }
  25. function ServiceVersionInfo() {
  26. const [versionInfo, setVersionInfo] = useState<ServiceVersionData | undefined>(undefined);
  27. const params = useParams();
  28. const id = params.id;
  29. useEffect(() => {
  30. // 获取服务版本详情
  31. const getServiceVersionInfo = async () => {
  32. const [res] = await to(getServiceVersionInfoReq(id));
  33. if (res && res.data) {
  34. setVersionInfo(res.data);
  35. }
  36. };
  37. if (id) {
  38. getServiceVersionInfo();
  39. }
  40. }, [id]);
  41. const tabItems = [
  42. {
  43. key: ModelDeploymentTabKey.Basic,
  44. label: '基本信息',
  45. icon: <KFIcon type="icon-jibenxinxi" />,
  46. children: <VersionBasicInfo info={versionInfo} />,
  47. },
  48. ];
  49. if (versionInfo?.run_state === ServiceRunStatus.Running) {
  50. if (versionInfo?.page_path) {
  51. tabItems.push({
  52. key: ModelDeploymentTabKey.Predict,
  53. label: '预测',
  54. icon: <KFIcon type="icon-yuce" />,
  55. children: <IframePage url={versionInfo?.page_path} showLoading={false}></IframePage>,
  56. });
  57. }
  58. if (versionInfo?.doc_path) {
  59. tabItems.push({
  60. key: ModelDeploymentTabKey.Guide,
  61. label: '调用指南',
  62. icon: <KFIcon type="icon-tiaoyongzhinan" />,
  63. children: <IframePage url={versionInfo?.doc_path}></IframePage>,
  64. });
  65. }
  66. }
  67. tabItems.push({
  68. key: ModelDeploymentTabKey.Log,
  69. label: '服务日志',
  70. icon: <KFIcon type="icon-fuwurizhi" />,
  71. children: <ServerLog info={versionInfo}></ServerLog>,
  72. });
  73. return (
  74. <div className={styles['service-version-info']}>
  75. <PageTitle title="服务版本详情"></PageTitle>
  76. <div className={styles['service-version-info__content']}>
  77. <div className={styles['service-version-info__content__tabs']}>
  78. <Tabs items={tabItems} />
  79. </div>
  80. </div>
  81. </div>
  82. );
  83. }
  84. export default ServiceVersionInfo;