|
|
|
@@ -4,6 +4,7 @@ import { getLabelStudioUrl } from '@/services/developmentEnvironment'; |
|
|
|
import { generateSign } from '@/utils'; |
|
|
|
import { to } from '@/utils/promise'; |
|
|
|
import SessionStorage from '@/utils/sessionStorage'; |
|
|
|
import { useModel } from '@umijs/max'; |
|
|
|
import classNames from 'classnames'; |
|
|
|
import { useEffect, useState } from 'react'; |
|
|
|
import { createPortal } from 'react-dom'; |
|
|
|
@@ -16,13 +17,12 @@ export enum IframePageType { |
|
|
|
GitLink = 'GitLink', |
|
|
|
} |
|
|
|
|
|
|
|
const getRequestAPI = (type: IframePageType): (() => Promise<any>) => { |
|
|
|
const getRequestAPI = (type: IframePageType, loginName: string): (() => Promise<any>) => { |
|
|
|
switch (type) { |
|
|
|
case IframePageType.DatasetAnnotation: |
|
|
|
return getLabelStudioUrl; |
|
|
|
case IframePageType.AppDevelopment: { |
|
|
|
// return () => Promise.resolve({ code: 200, data: 'http://172.20.32.185:30080/' }); |
|
|
|
const loginName = 'test3'; |
|
|
|
const sign = generateSign(loginName); |
|
|
|
|
|
|
|
return () => |
|
|
|
@@ -31,7 +31,6 @@ const getRequestAPI = (type: IframePageType): (() => Promise<any>) => { |
|
|
|
data: `http://10.43.107.27:24078/uap/nudt/sso/login?name=${loginName}&sign=${sign}`, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
case IframePageType.DevEnv: |
|
|
|
return () => |
|
|
|
Promise.resolve({ |
|
|
|
@@ -52,6 +51,9 @@ type IframePageProps = { |
|
|
|
function IframePage({ type, className, style }: IframePageProps) { |
|
|
|
const [iframeUrl, setIframeUrl] = useState(''); |
|
|
|
const [loading, setLoading] = useState(false); |
|
|
|
const { initialState } = useModel('@@initialState'); |
|
|
|
const { currentUser } = initialState || {}; |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
requestIframeUrl(); |
|
|
|
return () => { |
|
|
|
@@ -62,7 +64,7 @@ function IframePage({ type, className, style }: IframePageProps) { |
|
|
|
}, []); |
|
|
|
const requestIframeUrl = async () => { |
|
|
|
setLoading(true); |
|
|
|
const [res] = await to(getRequestAPI(type)()); |
|
|
|
const [res] = await to(getRequestAPI(type, currentUser?.userName || '')()); |
|
|
|
if (res && res.data) { |
|
|
|
setIframeUrl(res.data); |
|
|
|
} else { |
|
|
|
|