Commit 311f4e5e authored by jaden's avatar jaden

fix: fix bugs

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