From d1c41934b0a6055cc9490df40d9731ef0df5a14f Mon Sep 17 00:00:00 2001 From: zhaowei Date: Mon, 26 May 2025 10:23:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A2=84=E6=B5=8B=E6=9C=89=E4=B8=A4?= =?UTF-8?q?=E4=B8=AAloading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/components/IFramePage/index.tsx | 38 +++++++++++++------ .../ModelDeployment/VersionInfo/index.tsx | 2 +- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/react-ui/src/components/IFramePage/index.tsx b/react-ui/src/components/IFramePage/index.tsx index 8832b049..1982c816 100644 --- a/react-ui/src/components/IFramePage/index.tsx +++ b/react-ui/src/components/IFramePage/index.tsx @@ -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) => { - // setLoading(false); console.log('error', error); - Loading.hide(); + if (showLoading) { + Loading.hide(); + } }; return ( diff --git a/react-ui/src/pages/ModelDeployment/VersionInfo/index.tsx b/react-ui/src/pages/ModelDeployment/VersionInfo/index.tsx index 6809ed88..23d836f5 100644 --- a/react-ui/src/pages/ModelDeployment/VersionInfo/index.tsx +++ b/react-ui/src/pages/ModelDeployment/VersionInfo/index.tsx @@ -58,7 +58,7 @@ function ServiceVersionInfo() { key: ModelDeploymentTabKey.Predict, label: '预测', icon: , - children: , + children: , }); }