| @@ -83,15 +83,21 @@ function IframePage({ type, openInTab = false, className, style }: IframePagePro | |||||
| requestIframeUrl(); | requestIframeUrl(); | ||||
| }, [type]); | }, [type]); | ||||
| const hideLoading = () => { | |||||
| const handleLoad = () => { | |||||
| // setLoading(false); | // setLoading(false); | ||||
| Loading.hide(); | Loading.hide(); | ||||
| }; | }; | ||||
| const handleError = (error?: React.SyntheticEvent<HTMLIFrameElement, Event>) => { | |||||
| // setLoading(false); | |||||
| console.log('error', error); | |||||
| Loading.hide(); | |||||
| }; | |||||
| return ( | return ( | ||||
| <div className={classNames('kf-iframe-page', className)} style={style}> | <div className={classNames('kf-iframe-page', className)} style={style}> | ||||
| {/* {loading && createPortal(<KFSpin size="large" />, document.body)} */} | {/* {loading && createPortal(<KFSpin size="large" />, document.body)} */} | ||||
| <FullScreenFrame url={iframeUrl} onLoad={hideLoading} onError={hideLoading} /> | |||||
| <FullScreenFrame url={iframeUrl} onLoad={handleLoad} onError={handleError} /> | |||||
| {openInTab && <FloatButton onClick={() => window.open(iframeUrl, '_blank')} />} | {openInTab && <FloatButton onClick={() => window.open(iframeUrl, '_blank')} />} | ||||
| </div> | </div> | ||||
| ); | ); | ||||
| @@ -24,11 +24,11 @@ export enum ResourceSelectorType { | |||||
| } | } | ||||
| // 数据集、模型列表转为树形结构 | // 数据集、模型列表转为树形结构 | ||||
| const convertDatasetToTreeData = (list: ResourceData[]): TreeDataNode[] => { | |||||
| const convertDatasetToTreeData = (list: ResourceData[], isPublic: boolean): TreeDataNode[] => { | |||||
| return list.map((v) => ({ | return list.map((v) => ({ | ||||
| ...v, | ...v, | ||||
| key: `${v.id}`, | key: `${v.id}`, | ||||
| title: v.name, | |||||
| title: isPublic ? `${v.name} (${v.owner})` : v.name, | |||||
| isLeaf: false, | isLeaf: false, | ||||
| checkable: false, | checkable: false, | ||||
| })); | })); | ||||
| @@ -106,7 +106,7 @@ export class DatasetSelector implements SelectorTypeInfo { | |||||
| const res = await getDatasetList({ is_public: isPublic, page: 0, size: 2000 }); | const res = await getDatasetList({ is_public: isPublic, page: 0, size: 2000 }); | ||||
| if (res && res.data) { | if (res && res.data) { | ||||
| const list = res.data.content || []; | const list = res.data.content || []; | ||||
| return convertDatasetToTreeData(list); | |||||
| return convertDatasetToTreeData(list, isPublic); | |||||
| } else { | } else { | ||||
| return Promise.reject('获取数据集列表失败'); | return Promise.reject('获取数据集列表失败'); | ||||
| } | } | ||||
| @@ -158,7 +158,7 @@ export class ModelSelector implements SelectorTypeInfo { | |||||
| const res = await getModelList({ is_public: isPublic, page: 0, size: 2000 }); | const res = await getModelList({ is_public: isPublic, page: 0, size: 2000 }); | ||||
| if (res && res.data) { | if (res && res.data) { | ||||
| const list = res.data.content || []; | const list = res.data.content || []; | ||||
| return convertDatasetToTreeData(list); | |||||
| return convertDatasetToTreeData(list, isPublic); | |||||
| } else { | } else { | ||||
| return Promise.reject('获取模型列表失败'); | return Promise.reject('获取模型列表失败'); | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| import FullScreenFrame from '@/components/FullScreenFrame'; | import FullScreenFrame from '@/components/FullScreenFrame'; | ||||
| import KFIcon from '@/components/KFIcon'; | import KFIcon from '@/components/KFIcon'; | ||||
| import PageTitle from '@/components/PageTitle'; | import PageTitle from '@/components/PageTitle'; | ||||
| import { ServiceRunStatus } from '@/enums'; | |||||
| import { getServiceVersionInfoReq } from '@/services/modelDeployment'; | import { getServiceVersionInfoReq } from '@/services/modelDeployment'; | ||||
| import { to } from '@/utils/promise'; | import { to } from '@/utils/promise'; | ||||
| import { useParams } from '@umijs/max'; | import { useParams } from '@umijs/max'; | ||||
| @@ -50,18 +51,6 @@ function ServiceVersionInfo() { | |||||
| icon: <KFIcon type="icon-jibenxinxi" />, | icon: <KFIcon type="icon-jibenxinxi" />, | ||||
| children: <VersionBasicInfo info={versionInfo} />, | children: <VersionBasicInfo info={versionInfo} />, | ||||
| }, | }, | ||||
| { | |||||
| key: ModelDeploymentTabKey.Predict, | |||||
| label: '预测', | |||||
| icon: <KFIcon type="icon-yuce" />, | |||||
| children: ( | |||||
| <div style={{ height: '100%', width: '100%' }}> | |||||
| {versionInfo?.page_path && ( | |||||
| <FullScreenFrame url={versionInfo?.page_path}></FullScreenFrame> | |||||
| )} | |||||
| </div> | |||||
| ), | |||||
| }, | |||||
| { | { | ||||
| key: ModelDeploymentTabKey.Guide, | key: ModelDeploymentTabKey.Guide, | ||||
| label: '调用指南', | label: '调用指南', | ||||
| @@ -76,6 +65,21 @@ function ServiceVersionInfo() { | |||||
| }, | }, | ||||
| ]; | ]; | ||||
| if (versionInfo?.run_state === ServiceRunStatus.Running) { | |||||
| tabItems.splice(1, 0, { | |||||
| key: ModelDeploymentTabKey.Predict, | |||||
| label: '预测', | |||||
| icon: <KFIcon type="icon-yuce" />, | |||||
| children: ( | |||||
| <div style={{ height: '100%', width: '100%' }}> | |||||
| {versionInfo?.page_path && ( | |||||
| <FullScreenFrame url={versionInfo?.page_path}></FullScreenFrame> | |||||
| )} | |||||
| </div> | |||||
| ), | |||||
| }); | |||||
| } | |||||
| return ( | return ( | ||||
| <div className={styles['service-version-info']}> | <div className={styles['service-version-info']}> | ||||
| <PageTitle title="服务版本详情"></PageTitle> | <PageTitle title="服务版本详情"></PageTitle> | ||||