|
|
|
@@ -3,6 +3,7 @@ import KFSpin from '@/components/KFSpin'; |
|
|
|
import { getLabelStudioUrl } from '@/services/developmentEnvironment'; |
|
|
|
import { to } from '@/utils/promise'; |
|
|
|
import SessionStorage from '@/utils/sessionStorage'; |
|
|
|
import { FloatButton } from 'antd'; |
|
|
|
import classNames from 'classnames'; |
|
|
|
import { useEffect, useState } from 'react'; |
|
|
|
import { createPortal } from 'react-dom'; |
|
|
|
@@ -13,6 +14,7 @@ export enum IframePageType { |
|
|
|
AppDevelopment = 'AppDevelopment', // 应用开发 |
|
|
|
DevEnv = 'DevEnv', // 开发环境 |
|
|
|
GitLink = 'GitLink', // git link |
|
|
|
Aim = 'Aim', // 实验对比 |
|
|
|
} |
|
|
|
|
|
|
|
const getRequestAPI = (type: IframePageType): (() => Promise<any>) => { |
|
|
|
@@ -29,12 +31,20 @@ const getRequestAPI = (type: IframePageType): (() => Promise<any>) => { |
|
|
|
}); |
|
|
|
case IframePageType.GitLink: // git link |
|
|
|
return () => Promise.resolve({ code: 200, data: 'http://172.20.32.201:4000' }); |
|
|
|
case IframePageType.Aim: // Aim |
|
|
|
return () => |
|
|
|
Promise.resolve({ |
|
|
|
code: 200, |
|
|
|
data: SessionStorage.getItem(SessionStorage.aimUrlKey) || '', |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
type IframePageProps = { |
|
|
|
/** 子系统 */ |
|
|
|
type: IframePageType; |
|
|
|
/** 是否可以在页签上打开 */ |
|
|
|
openInTab: boolean; |
|
|
|
/** 自定义样式类名 */ |
|
|
|
className?: string; |
|
|
|
/** 自定义样式 */ |
|
|
|
@@ -42,7 +52,7 @@ type IframePageProps = { |
|
|
|
}; |
|
|
|
|
|
|
|
/** 系统内嵌 iframe,目前系统有数据标注、应用开发、开发环境、GitLink 四个子系统,使用时可以添加其他子系统 */ |
|
|
|
function IframePage({ type, className, style }: IframePageProps) { |
|
|
|
function IframePage({ type, openInTab = true, className, style }: IframePageProps) { |
|
|
|
const [iframeUrl, setIframeUrl] = useState(''); |
|
|
|
const [loading, setLoading] = useState(false); |
|
|
|
|
|
|
|
@@ -65,6 +75,7 @@ function IframePage({ type, className, style }: IframePageProps) { |
|
|
|
<div className={classNames('kf-iframe-page', className)} style={style}> |
|
|
|
{loading && createPortal(<KFSpin size="large" />, document.body)} |
|
|
|
<FullScreenFrame url={iframeUrl} onLoad={hideLoading} onError={hideLoading} /> |
|
|
|
{openInTab && <FloatButton onClick={() => window.open(iframeUrl, '_blank')} />} |
|
|
|
</div> |
|
|
|
); |
|
|
|
} |
|
|
|
|