Commit 311f4e5e authored by jaden's avatar jaden

fix: fix bugs

parent ed16e4be
......@@ -394,6 +394,7 @@ export function AIWrapper({
onPressEnter={() => !SendButton && handleButtonClick()}
value={inputValue}
onChange={value => {
console.log(value, 'value');
const el = input.current?.dom;
if (el) {
el.value = value;
......@@ -517,6 +518,7 @@ export function AIWrapper({
);
}
}, [currentAssistantMessage, check]);
console.log(currentAssistantMessage, 'currentAssistantMessage');
if (simpleMode) {
if (simpleMode === 'input') {
......@@ -700,13 +702,11 @@ export function AIWrapper({
ref={input}
value={inputValue}
onChange={value => {
setRecordValue(value);
const el = input.current?.dom;
console.log(value, recordValue, el, el.value);
if (el) el.value = value || '';
setRecordValue(value);
}}
onPressEnter={e => {
console.log('w22');
if (
e.key === 'Enter' &&
!e?.nativeEvent.isComposing &&
......@@ -740,7 +740,6 @@ export function AIWrapper({
// popupVisible: true,
}}
onSelect={(value: string) => {
console.log('w22');
const el = input.current?.dom;
if (el) {
el.value = value;
......
......@@ -6,7 +6,7 @@ import Editor from '@monaco-editor/react';
import graphState from '../hooks/use-graph-state';
import tableModel from '../hooks/table-model';
import { Typography } from '@arco-design/web-react';
import { map } from 'lodash';
import { get, map } from 'lodash';
import { sortBy } from 'lodash';
import { useEffect } from 'react';
import { useMemo } from 'react';
......@@ -207,14 +207,20 @@ export default function ImportModal({ showModal, onCloseModal, cb = _p => {}, ty
const [val, setValue] = useState('');
const [importType, setImportType] = useState('dbml');
// eslint-disable-next-line react-hooks/exhaustive-deps
const handleOk = async (changeValue, handleCb, failCall) => {
/**
* options: {
new: Boolean,
importType:string
}
*/
const handleOk = async (changeValue, handleCb, failCall, options = {}) => {
const value = changeValue || val;
if (!value) {
onCloseModal();
return;
}
try {
const result = await Parser.parse(value, importType);
const result = await Parser.parse(value, get(options, 'importType', importType));
const graph = result.schemas[0];
const tableDict = {};
const linkDict = {};
......@@ -294,11 +300,11 @@ export default function ImportModal({ showModal, onCloseModal, cb = _p => {}, ty
});
setTableDict(state => ({
...state,
...(options.new ? [] : state),
...tableDict,
}));
setLinkDict(state => ({
...state,
...(options.new ? [] : state),
...linkDict,
}));
......@@ -316,6 +322,7 @@ export default function ImportModal({ showModal, onCloseModal, cb = _p => {}, ty
if (importDBML) {
importDBML.current = handleOk;
}
//表示已经导,避免多次导入
const recordData = useRef();
useEffect(() => {
if (recordData.current !== data) {
......
......@@ -118,13 +118,21 @@ export default function ListNav({
),
});
}
importDBML.current(sqlNodes[0]?.textContent, ({ tableDict, linkDict }) => {
importDBML.current(
sqlNodes[0]?.textContent,
({ tableDict, linkDict }) => {
handlerImportGraph({
tableDict,
linkDict,
name: `${modelName.outerText}`,
});
});
},
undefined,
{
new: true,
importType: 'dbml',
}
);
}}
// renderMessageItem={props => <MessageItem {...props} />}
/>
......
......@@ -253,9 +253,16 @@ export default function Nav({ setShowModal, setShowDrawer, leave = () => {}, imp
<Menu.Item
key="import"
className="context-menu-item"
onClick={() => setShowModal('import')}
onClick={() => setShowModal('import', 2)}
>
<IconImport /> {t('Import Table')}
<IconImport /> {t('Import DDL')}
</Menu.Item>
<Menu.Item
key="import"
className="context-menu-item"
onClick={() => setShowModal('import', 1)}
>
<IconImport /> {t('Import DBML')}
</Menu.Item>
</Menu>
}
......
......@@ -37,6 +37,8 @@ i18n.use(LanguageDetector)
'AI未能理解您的输入, 请进一步明确您的输入。',
},
nav: {
'Import DBML': '导入 DBML',
'Import DDL': '导入 DDL',
'Apply Select Version': '应用所选版本',
'Exit Logs View': '退出日志视图',
Save: '保存',
......
......@@ -55,6 +55,7 @@ export default function Home() {
const [movingTable, setMovingTable] = useState();
const [showModal, setShowModal] = useState('');
const [addType, setAadType] = useState(1);
const [showDrawer, setShowDrawer] = useState('');
const [formChange, setFormChange] = useState(false);
const [editingLink, setEditingLink] = useState(null);
......@@ -422,7 +423,10 @@ export default function Home() {
</Head>
<Nav
setShowModal={setShowModal}
setShowModal={(kind, type = 1) => {
setShowModal(kind);
setAadType(type);
}}
setShowDrawer={setShowDrawer}
leave={saveCheck}
importDBML={importDBML}
......@@ -501,6 +505,7 @@ export default function Home() {
showModal={showModal}
onCloseModal={() => setShowModal('')}
importDBML={importDBML}
type={addType}
/>
<ExportModal showModal={showModal} onCloseModal={() => setShowModal('')} />
<LogsDrawer showDrawer={showDrawer} onCloseDrawer={() => setShowDrawer('')} />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment