Browse Source

fix: 预测有两个loading

pull/250/head
zhaowei 10 months ago
parent
commit
d1c41934b0
2 changed files with 28 additions and 12 deletions
  1. +27
    -11
      react-ui/src/components/IFramePage/index.tsx
  2. +1
    -1
      react-ui/src/pages/ModelDeployment/VersionInfo/index.tsx

+ 27
- 11
react-ui/src/components/IFramePage/index.tsx View File

@@ -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 (


+ 1
- 1
react-ui/src/pages/ModelDeployment/VersionInfo/index.tsx View File

@@ -58,7 +58,7 @@ function ServiceVersionInfo() {
key: ModelDeploymentTabKey.Predict,
label: '预测',
icon: <KFIcon type="icon-yuce" />,
children: <IframePage url={versionInfo?.page_path}></IframePage>,
children: <IframePage url={versionInfo?.page_path} showLoading={false}></IframePage>,
});
}



Loading…
Cancel
Save