Browse Source

Merge pull request '合并arm-build-zw' (#143) from arm-build-zw into arm-build

arm-build
cp3hnu 1 year ago
parent
commit
4e13e1a036
2 changed files with 6 additions and 5 deletions
  1. +6
    -4
      react-ui/src/components/IFramePage/index.tsx
  2. +0
    -1
      react-ui/src/pages/Authorize/index.tsx

+ 6
- 4
react-ui/src/components/IFramePage/index.tsx View File

@@ -4,6 +4,7 @@ import { getLabelStudioUrl } from '@/services/developmentEnvironment';
import { generateSign } from '@/utils'; import { generateSign } from '@/utils';
import { to } from '@/utils/promise'; import { to } from '@/utils/promise';
import SessionStorage from '@/utils/sessionStorage'; import SessionStorage from '@/utils/sessionStorage';
import { useModel } from '@umijs/max';
import classNames from 'classnames'; import classNames from 'classnames';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { createPortal } from 'react-dom'; import { createPortal } from 'react-dom';
@@ -16,13 +17,12 @@ export enum IframePageType {
GitLink = 'GitLink', GitLink = 'GitLink',
} }


const getRequestAPI = (type: IframePageType): (() => Promise<any>) => {
const getRequestAPI = (type: IframePageType, loginName: string): (() => Promise<any>) => {
switch (type) { switch (type) {
case IframePageType.DatasetAnnotation: case IframePageType.DatasetAnnotation:
return getLabelStudioUrl; return getLabelStudioUrl;
case IframePageType.AppDevelopment: { case IframePageType.AppDevelopment: {
// return () => Promise.resolve({ code: 200, data: 'http://172.20.32.185:30080/' }); // return () => Promise.resolve({ code: 200, data: 'http://172.20.32.185:30080/' });
const loginName = 'test3';
const sign = generateSign(loginName); const sign = generateSign(loginName);


return () => 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}`, data: `http://10.43.107.27:24078/uap/nudt/sso/login?name=${loginName}&sign=${sign}`,
}); });
} }

case IframePageType.DevEnv: case IframePageType.DevEnv:
return () => return () =>
Promise.resolve({ Promise.resolve({
@@ -52,6 +51,9 @@ type IframePageProps = {
function IframePage({ type, className, style }: IframePageProps) { function IframePage({ type, className, style }: IframePageProps) {
const [iframeUrl, setIframeUrl] = useState(''); const [iframeUrl, setIframeUrl] = useState('');
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const { initialState } = useModel('@@initialState');
const { currentUser } = initialState || {};

useEffect(() => { useEffect(() => {
requestIframeUrl(); requestIframeUrl();
return () => { return () => {
@@ -62,7 +64,7 @@ function IframePage({ type, className, style }: IframePageProps) {
}, []); }, []);
const requestIframeUrl = async () => { const requestIframeUrl = async () => {
setLoading(true); setLoading(true);
const [res] = await to(getRequestAPI(type)());
const [res] = await to(getRequestAPI(type, currentUser?.userName || '')());
if (res && res.data) { if (res && res.data) {
setIframeUrl(res.data); setIframeUrl(res.data);
} else { } else {


+ 0
- 1
react-ui/src/pages/Authorize/index.tsx View File

@@ -22,7 +22,6 @@ function Authorize() {
code, code,
}; };
const [res] = await to(loginByOauth2Req(params)); const [res] = await to(loginByOauth2Req(params));
debugger;
if (res && res.data) { if (res && res.data) {
const { access_token, expires_in } = res.data; const { access_token, expires_in } = res.data;
setSessionToken(access_token, access_token, expires_in); setSessionToken(access_token, access_token, expires_in);


Loading…
Cancel
Save