Browse Source

feat: 火石平台调试

pull/142/head
cp3hnu 1 year ago
parent
commit
ca5d206c85
2 changed files with 35 additions and 2 deletions
  1. +13
    -2
      react-ui/src/components/IFramePage/index.tsx
  2. +22
    -0
      react-ui/src/utils/index.ts

+ 13
- 2
react-ui/src/components/IFramePage/index.tsx View File

@@ -1,6 +1,7 @@
import FullScreenFrame from '@/components/FullScreenFrame';
import KFSpin from '@/components/KFSpin';
import { getLabelStudioUrl } from '@/services/developmentEnvironment';
import { generateSign } from '@/utils';
import { to } from '@/utils/promise';
import SessionStorage from '@/utils/sessionStorage';
import classNames from 'classnames';
@@ -19,8 +20,18 @@ const getRequestAPI = (type: IframePageType): (() => Promise<any>) => {
switch (type) {
case IframePageType.DatasetAnnotation:
return getLabelStudioUrl;
case IframePageType.AppDevelopment:
return () => Promise.resolve({ code: 200, data: 'http://172.20.32.185:30080/' });
case IframePageType.AppDevelopment: {
// return () => Promise.resolve({ code: 200, data: 'http://172.20.32.185:30080/' });
const loginName = 'test3';
const sign = generateSign(loginName);

return () =>
Promise.resolve({
code: 200,
data: `http://10.43.107.27:24078/uap/nudt/sso/login?name=${loginName}&sign=${sign}`,
});
}

case IframePageType.DevEnv:
return () =>
Promise.resolve({


+ 22
- 0
react-ui/src/utils/index.ts View File

@@ -6,6 +6,7 @@

import { PageEnum } from '@/enums/pagesEnums';
import G6 from '@antv/g6';
import CryptoJS from 'crypto-js';

// 生成 8 位随机数
export function s8() {
@@ -241,3 +242,24 @@ export const tableSorter = (a: any, b: any) => {
}
return 0;
};

// 生成火石平台 sign
export const generateSign = (loginName: string) => {
// 16-character custom password
const key = '8c4ddb8cb50ade0e';

const content = `${loginName}-${Math.floor(Date.now() / 1000)}`;

// Generate the AES key (16 bytes for AES-128 or 32 bytes for AES-256)
const byteKey = CryptoJS.enc.Utf8.parse(key);

// Encrypt the content
const encrypted = CryptoJS.AES.encrypt(content, byteKey, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
});

const encryptedHex = encrypted.ciphertext.toString(CryptoJS.enc.Hex);

return encryptedHex;
};

Loading…
Cancel
Save