mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-11 22:09:44 +00:00
feat:1、Set language 2、Remove junk code
This commit is contained in:
@@ -2,6 +2,9 @@ import i18n from 'i18next';
|
|||||||
import { initReactI18next } from 'react-i18next';
|
import { initReactI18next } from 'react-i18next';
|
||||||
|
|
||||||
const en = {
|
const en = {
|
||||||
|
UploadData: 'Upload Data',
|
||||||
|
CodeEditor: 'Code Editor:',
|
||||||
|
openCodeEditor:'Open Code Editor',
|
||||||
Knowledge_Space: 'Knowledge',
|
Knowledge_Space: 'Knowledge',
|
||||||
space: 'space',
|
space: 'space',
|
||||||
Vector: 'Vector',
|
Vector: 'Vector',
|
||||||
@@ -234,6 +237,9 @@ export interface Resources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const zh: Resources['translation'] = {
|
const zh: Resources['translation'] = {
|
||||||
|
UploadData: '上传数据',
|
||||||
|
CodeEditor: '代码编辑:',
|
||||||
|
openCodeEditor: '打开代码编辑器',
|
||||||
Knowledge_Space: '知识库',
|
Knowledge_Space: '知识库',
|
||||||
space: '知识库',
|
space: '知识库',
|
||||||
Vector: '向量',
|
Vector: '向量',
|
||||||
|
@@ -18,9 +18,6 @@ import {
|
|||||||
RenderUpload,
|
RenderUpload,
|
||||||
RenderCodeEditor,
|
RenderCodeEditor,
|
||||||
} from './node-renderer';
|
} from './node-renderer';
|
||||||
import MonacoEditor from '@/components/chat/monaco-editor'
|
|
||||||
// C:\Users\Administrator\Desktop\ai\DB-GPT\web\components\chat\monaco-editor.tsx
|
|
||||||
import { convertKeysToCamelCase } from '@/utils/flow';
|
|
||||||
|
|
||||||
interface NodeParamHandlerProps {
|
interface NodeParamHandlerProps {
|
||||||
node: IFlowNode;
|
node: IFlowNode;
|
||||||
|
@@ -2,6 +2,8 @@ import React, { useState, useMemo } from 'react';
|
|||||||
import { Button, Modal } from 'antd';
|
import { Button, Modal } from 'antd';
|
||||||
import Editor from '@monaco-editor/react';
|
import Editor from '@monaco-editor/react';
|
||||||
import { IFlowNodeParameter } from '@/types/flow';
|
import { IFlowNodeParameter } from '@/types/flow';
|
||||||
|
import { convertKeysToCamelCase } from '@/utils/flow';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
data: IFlowNodeParameter;
|
data: IFlowNodeParameter;
|
||||||
@@ -10,6 +12,8 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const RenderCodeEditor = (params: Props) => {
|
export const RenderCodeEditor = (params: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { data, defaultValue, onChange } = params;
|
const { data, defaultValue, onChange } = params;
|
||||||
const attr = convertKeysToCamelCase(data.ui?.attr || {});
|
const attr = convertKeysToCamelCase(data.ui?.attr || {});
|
||||||
|
|
||||||
@@ -35,14 +39,12 @@ export const RenderCodeEditor = (params: Props) => {
|
|||||||
return '80%';
|
return '80%';
|
||||||
}, [data?.ui?.editor?.width]);
|
}, [data?.ui?.editor?.width]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ textAlign: 'center' }} className="p-2 text-sm">
|
<div style={{ textAlign: 'center' }} className="p-2 text-sm">
|
||||||
<Button type="primary" onClick={showModal}>
|
<Button type="primary" onClick={showModal}>
|
||||||
打开代码编辑器
|
{t('openCodeEditor')}
|
||||||
</Button>
|
</Button>
|
||||||
<Modal title="代码编辑:" width={modalWidth} open={isModalOpen} onOk={handleOk} onCancel={handleCancel}>
|
<Modal title={t('openCodeEditor')} width={modalWidth} open={isModalOpen} onOk={handleOk} onCancel={handleCancel}>
|
||||||
<Editor
|
<Editor
|
||||||
{...data?.ui?.attr}
|
{...data?.ui?.attr}
|
||||||
width={data?.ui?.editor?.width || '100%'}
|
width={data?.ui?.editor?.width || '100%'}
|
||||||
@@ -51,7 +53,7 @@ export const RenderCodeEditor = (params: Props) => {
|
|||||||
height={data?.ui?.editor?.height || 200}
|
height={data?.ui?.editor?.height || 200}
|
||||||
defaultLanguage={data?.ui?.language}
|
defaultLanguage={data?.ui?.language}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
theme='vs-dark' // 编辑器主题颜色
|
theme='vs-dark'
|
||||||
options={{
|
options={{
|
||||||
minimap: {
|
minimap: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
@@ -3,6 +3,8 @@ import { UploadOutlined } from '@ant-design/icons';
|
|||||||
import type { UploadProps } from 'antd';
|
import type { UploadProps } from 'antd';
|
||||||
import { Button, message, Upload } from 'antd';
|
import { Button, message, Upload } from 'antd';
|
||||||
import { convertKeysToCamelCase } from '@/utils/flow';
|
import { convertKeysToCamelCase } from '@/utils/flow';
|
||||||
|
import { IFlowNodeParameter } from '@/types/flow';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
const props: UploadProps = {
|
const props: UploadProps = {
|
||||||
name: 'file',
|
name: 'file',
|
||||||
@@ -10,31 +12,29 @@ const props: UploadProps = {
|
|||||||
headers: {
|
headers: {
|
||||||
authorization: 'authorization-text',
|
authorization: 'authorization-text',
|
||||||
},
|
},
|
||||||
onChange(info) {
|
|
||||||
if (info.file.status !== 'uploading') {
|
|
||||||
console.log(info.file, info.fileList);
|
|
||||||
}
|
|
||||||
if (info.file.status === 'done') {
|
|
||||||
message.success(`${info.file.name} file uploaded successfully`);
|
|
||||||
} else if (info.file.status === 'error') {
|
|
||||||
message.error(`${info.file.name} file upload failed.`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const RenderUpload: React.FC = (params) => (
|
type Props = {
|
||||||
const { data, defaultValue, onChange } = params;
|
data: IFlowNodeParameter;
|
||||||
|
defaultValue: any;
|
||||||
|
onChange: (value: any) => void;
|
||||||
|
};
|
||||||
|
|
||||||
const attr = convertKeysToCamelCase(data.ui?.attr || {});
|
export const RenderUpload = (params: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
const { data, defaultValue, onChange } = params;
|
||||||
<div style={{ textAlign: 'center' }} className="p-2 text-sm">
|
|
||||||
<Upload {...attr} {...props}>
|
|
||||||
<Button icon={<UploadOutlined />}>上传数据</Button>
|
|
||||||
</Upload>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
);
|
const attr = convertKeysToCamelCase(data.ui?.attr || {});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ textAlign: 'center' }} className="p-2 text-sm">
|
||||||
|
<Upload {...attr} {...props}>
|
||||||
|
<Button icon={<UploadOutlined />}>{t('UploadData')}</Button>
|
||||||
|
</Upload>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import axios from './ctx-axios';
|
import axios from './ctx-axios';
|
||||||
import { isPlainObject } from 'lodash';
|
import { isPlainObject } from 'lodash';
|
||||||
import 'codemirror/lib/codemirror.css';
|
|
||||||
import 'codemirror/theme/material.css'; // 引入你喜欢的主题
|
|
||||||
import 'codemirror/mode/javascript/javascript'; // 引入JavaScript语言模式
|
|
||||||
const DEFAULT_HEADERS = {
|
const DEFAULT_HEADERS = {
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user