|
|
@@ -53,7 +53,9 @@ const getRequestAPI = (type: IframePageType): (() => Promise<any>) => { |
|
|
|
|
|
|
|
|
type IframePageProps = { |
|
|
type IframePageProps = { |
|
|
/** 子系统 */ |
|
|
/** 子系统 */ |
|
|
type: IframePageType; |
|
|
|
|
|
|
|
|
type?: IframePageType; |
|
|
|
|
|
/** url */ |
|
|
|
|
|
url?: string; |
|
|
/** 是否可以在页签上打开 */ |
|
|
/** 是否可以在页签上打开 */ |
|
|
openInTab?: boolean; |
|
|
openInTab?: boolean; |
|
|
/** 自定义样式类名 */ |
|
|
/** 自定义样式类名 */ |
|
|
@@ -63,13 +65,13 @@ type IframePageProps = { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** 系统内嵌 iframe,目前系统有数据标注、应用开发、开发环境、GitLink 四个子系统,使用时可以添加其他子系统 */ |
|
|
/** 系统内嵌 iframe,目前系统有数据标注、应用开发、开发环境、GitLink 四个子系统,使用时可以添加其他子系统 */ |
|
|
function IframePage({ type, openInTab = false, className, style }: IframePageProps) { |
|
|
|
|
|
|
|
|
function IframePage({ type, url, openInTab = false, className, style }: IframePageProps) { |
|
|
const [iframeUrl, setIframeUrl] = useState(''); |
|
|
const [iframeUrl, setIframeUrl] = useState(''); |
|
|
// const [loading, setLoading] = useState(false); |
|
|
// const [loading, setLoading] = useState(false); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
const requestIframeUrl = async () => { |
|
|
|
|
|
//setLoading(true); |
|
|
|
|
|
|
|
|
const requestIframeUrl = async (type: IframePageType) => { |
|
|
|
|
|
// setLoading(true); |
|
|
Loading.show(); |
|
|
Loading.show(); |
|
|
const [res] = await to(getRequestAPI(type)()); |
|
|
const [res] = await to(getRequestAPI(type)()); |
|
|
if (res && res.data) { |
|
|
if (res && res.data) { |
|
|
@@ -80,8 +82,13 @@ function IframePage({ type, openInTab = false, className, style }: IframePagePro |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
requestIframeUrl(); |
|
|
|
|
|
}, [type]); |
|
|
|
|
|
|
|
|
if (type) { |
|
|
|
|
|
requestIframeUrl(type); |
|
|
|
|
|
} else if (url) { |
|
|
|
|
|
Loading.show(); |
|
|
|
|
|
setIframeUrl(url); |
|
|
|
|
|
} |
|
|
|
|
|
}, [type, url]); |
|
|
|
|
|
|
|
|
const handleLoad = () => { |
|
|
const handleLoad = () => { |
|
|
// setLoading(false); |
|
|
// setLoading(false); |
|
|
@@ -97,7 +104,7 @@ function IframePage({ type, openInTab = false, className, style }: IframePagePro |
|
|
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={handleLoad} onError={handleError} /> |
|
|
|
|
|
|
|
|
{iframeUrl && <FullScreenFrame url={iframeUrl} onLoad={handleLoad} onError={handleError} />} |
|
|
{openInTab && <FloatButton onClick={() => window.open(iframeUrl, '_blank')} />} |
|
|
{openInTab && <FloatButton onClick={() => window.open(iframeUrl, '_blank')} />} |
|
|
</div> |
|
|
</div> |
|
|
); |
|
|
); |
|
|
|