diff --git a/react-ui/src/components/FullScreenFrame/index.tsx b/react-ui/src/components/FullScreenFrame/index.tsx
index f93fcfae..7593c904 100644
--- a/react-ui/src/components/FullScreenFrame/index.tsx
+++ b/react-ui/src/components/FullScreenFrame/index.tsx
@@ -5,12 +5,21 @@ type FullScreenFrameProps = {
url: string;
className?: string;
style?: React.CSSProperties;
+ onload?: () => void;
+ onerror?: () => void;
};
-function FullScreenFrame({ url, className, style }: FullScreenFrameProps) {
+function FullScreenFrame({ url, className, style, onload, onerror }: FullScreenFrameProps) {
return (
- {url && }
+ {url && (
+
+ )}
);
}
diff --git a/react-ui/src/components/IFramePage/index.less b/react-ui/src/components/IFramePage/index.less
new file mode 100644
index 00000000..48c07f94
--- /dev/null
+++ b/react-ui/src/components/IFramePage/index.less
@@ -0,0 +1,5 @@
+.kf-iframe-page {
+ position: relative;
+ width: 100%;
+ height: 100%;
+}
diff --git a/react-ui/src/components/IFramePage/index.tsx b/react-ui/src/components/IFramePage/index.tsx
new file mode 100644
index 00000000..f1140136
--- /dev/null
+++ b/react-ui/src/components/IFramePage/index.tsx
@@ -0,0 +1,57 @@
+import FullScreenFrame from '@/components/FullScreenFrame';
+import KFSpin from '@/components/KFSpin';
+import { getLabelStudioUrl } from '@/services/developmentEnvironment';
+import { to } from '@/utils/promise';
+import classNames from 'classnames';
+import { useEffect, useState } from 'react';
+import './index.less';
+
+export enum IframePageType {
+ DatasetAnnotation = 'DatasetAnnotation', // 数据标注
+ AppDevelopment = 'AppDevelopment', // 应用开发
+}
+
+const getRequestAPI = (type: IframePageType): (() => Promise) => {
+ switch (type) {
+ case IframePageType.DatasetAnnotation:
+ return getLabelStudioUrl;
+ case IframePageType.AppDevelopment:
+ return () => Promise.resolve({ code: 200, data: 'http://172.20.32.181:30080/' });
+ }
+};
+
+type IframePageProps = {
+ type: IframePageType;
+ className?: string;
+ style?: React.CSSProperties;
+};
+
+function IframePage({ type, className, style }: IframePageProps) {
+ const [iframeUrl, setIframeUrl] = useState('');
+ const [loading, setLoading] = useState(false);
+ useEffect(() => {
+ requestIframeUrl();
+ }, []);
+ const requestIframeUrl = async () => {
+ setLoading(true);
+ const [res] = await to(getRequestAPI(type)());
+ if (res && res.data) {
+ setIframeUrl(res.data);
+ } else {
+ setLoading(false);
+ }
+ };
+
+ const hideLoading = () => {
+ setLoading(false);
+ };
+
+ return (
+
+ {loading && }
+
+
+ );
+}
+
+export default IframePage;
diff --git a/react-ui/src/pages/Application/index.tsx b/react-ui/src/pages/Application/index.tsx
index 77f70208..65a1efae 100644
--- a/react-ui/src/pages/Application/index.tsx
+++ b/react-ui/src/pages/Application/index.tsx
@@ -1,9 +1,7 @@
-import FullScreenFrame from '@/components/FullScreenFrame';
-import { useState } from 'react';
+import IframePage, { IframePageType } from '@/components/IFramePage';
function Application() {
- const [iframeUrl] = useState('http://172.20.32.181:30080/');
- return ;
+ return ;
}
export default Application;
diff --git a/react-ui/src/pages/DatasetPreparation/DatasetAnnotation/index.tsx b/react-ui/src/pages/DatasetPreparation/DatasetAnnotation/index.tsx
index 090d941e..f5badc92 100644
--- a/react-ui/src/pages/DatasetPreparation/DatasetAnnotation/index.tsx
+++ b/react-ui/src/pages/DatasetPreparation/DatasetAnnotation/index.tsx
@@ -1,20 +1,7 @@
-import FullScreenFrame from '@/components/FullScreenFrame';
-import { getLabelStudioUrl } from '@/services/developmentEnvironment';
-import { to } from '@/utils/promise';
-import { useEffect, useState } from 'react';
+import IframePage, { IframePageType } from '@/components/IFramePage';
function DatasetAnnotation() {
- const [iframeUrl, setIframeUrl] = useState('');
- useEffect(() => {
- requestIframeUrl();
- }, []);
- const requestIframeUrl = async () => {
- const [res] = await to(getLabelStudioUrl());
- if (res && res.data) {
- setIframeUrl(res.data);
- }
- };
- return ;
+ return ;
}
export default DatasetAnnotation;