|
|
|
@@ -58,6 +58,8 @@ type IframePageProps = { |
|
|
|
url?: string; |
|
|
|
/** 是否可以在页签上打开 */ |
|
|
|
openInTab?: boolean; |
|
|
|
/** 是否显示加载 */ |
|
|
|
showLoading?: boolean; |
|
|
|
/** 自定义样式类名 */ |
|
|
|
className?: string; |
|
|
|
/** 自定义样式 */ |
|
|
|
@@ -65,40 +67,54 @@ type IframePageProps = { |
|
|
|
}; |
|
|
|
|
|
|
|
/** 系统内嵌 iframe,目前系统有数据标注、应用开发、开发环境、GitLink 四个子系统,使用时可以添加其他子系统 */ |
|
|
|
function IframePage({ type, url, openInTab = false, className, style }: IframePageProps) { |
|
|
|
function IframePage({ |
|
|
|
type, |
|
|
|
url, |
|
|
|
showLoading = true, |
|
|
|
openInTab = false, |
|
|
|
className, |
|
|
|
style, |
|
|
|
}: IframePageProps) { |
|
|
|
const [iframeUrl, setIframeUrl] = useState(''); |
|
|
|
// const [loading, setLoading] = useState(false); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
const requestIframeUrl = async (type: IframePageType) => { |
|
|
|
// setLoading(true); |
|
|
|
Loading.show(); |
|
|
|
if (showLoading) { |
|
|
|
Loading.show(); |
|
|
|
} |
|
|
|
const [res] = await to(getRequestAPI(type)()); |
|
|
|
if (res && res.data) { |
|
|
|
setIframeUrl(res.data); |
|
|
|
} else { |
|
|
|
Loading.hide(); |
|
|
|
// setLoading(false); |
|
|
|
if (showLoading) { |
|
|
|
Loading.hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
if (type) { |
|
|
|
requestIframeUrl(type); |
|
|
|
} else if (url) { |
|
|
|
Loading.show(); |
|
|
|
if (showLoading) { |
|
|
|
Loading.show(); |
|
|
|
} |
|
|
|
|
|
|
|
setIframeUrl(url); |
|
|
|
} |
|
|
|
}, [type, url]); |
|
|
|
}, [type, url, showLoading]); |
|
|
|
|
|
|
|
const handleLoad = () => { |
|
|
|
// setLoading(false); |
|
|
|
Loading.hide(); |
|
|
|
if (showLoading) { |
|
|
|
Loading.hide(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const handleError = (error?: React.SyntheticEvent<HTMLIFrameElement, Event>) => { |
|
|
|
// setLoading(false); |
|
|
|
console.log('error', error); |
|
|
|
Loading.hide(); |
|
|
|
if (showLoading) { |
|
|
|
Loading.hide(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
return ( |
|
|
|
|