mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-20 10:45:52 +00:00
Python Sandbox (#4380)
* Python3 Sandbox (#3944) * update python box (#4251) * update python box * Adjust the height of the NodeCode border. * update python sandbox and add test systemcall bash * update sandbox * add VERSION_RELEASE (#4376) * save empty docx * fix pythonbox log error * fix: js template --------- Co-authored-by: dogfar <37035781+dogfar@users.noreply.github.com> Co-authored-by: gggaaallleee <91131304+gggaaallleee@users.noreply.github.com> Co-authored-by: gggaaallleee <1293587368@qq.com>
This commit is contained in:
@@ -4,15 +4,31 @@ import { Button, ModalBody, ModalFooter, useDisclosure } from '@chakra-ui/react'
|
||||
import MyModal from '../../MyModal';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
|
||||
type Props = Omit<EditorProps, 'resize'> & {};
|
||||
type Props = Omit<EditorProps, 'resize'> & { language?: string };
|
||||
function getLanguage(language: string | undefined): string {
|
||||
let fullName: string;
|
||||
switch (language) {
|
||||
case 'py':
|
||||
fullName = 'python';
|
||||
break;
|
||||
case 'js':
|
||||
fullName = 'typescript';
|
||||
break;
|
||||
default:
|
||||
fullName = `typescript`;
|
||||
break;
|
||||
}
|
||||
return fullName;
|
||||
}
|
||||
|
||||
const CodeEditor = (props: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
|
||||
const { language, ...otherProps } = props;
|
||||
const fullName = getLanguage(language);
|
||||
return (
|
||||
<>
|
||||
<MyEditor {...props} resize onOpenModal={onOpen} />
|
||||
<MyEditor {...props} resize onOpenModal={onOpen} language={fullName} />
|
||||
<MyModal
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
@@ -23,7 +39,7 @@ const CodeEditor = (props: Props) => {
|
||||
isCentered
|
||||
>
|
||||
<ModalBody flex={'1 0 0'} overflow={'auto'}>
|
||||
<MyEditor {...props} bg={'myGray.50'} height={'100%'} />
|
||||
<MyEditor {...props} bg={'myGray.50'} height={'100%'} language={fullName} />
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button mr={2} onClick={onClose} px={6}>
|
||||
|
Reference in New Issue
Block a user