forked from findyourmagic/dber
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport_modal.js
More file actions
63 lines (61 loc) · 1.97 KB
/
export_modal.js
File metadata and controls
63 lines (61 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { Modal, Notification, Tabs } from '@arco-design/web-react';
import Editor from '@monaco-editor/react';
const TabPane = Tabs.TabPane;
/**
* It's a modal that displays the command to be exported
* @returns Modal component
*/
export default function ExportModal({ command, handlerExport, exportType, theme }) {
const copy = async () => {
try {
await window.navigator.clipboard.writeText(command);
Notification.success({
title: 'Copy Success',
});
} catch (e) {
console.log(e);
Notification.error({
title: 'Copy Failed',
});
}
};
return (
<Modal
title={null}
simple
visible={command}
autoFocus={false}
onOk={() => copy()}
okText="Copy"
cancelText="Close"
onCancel={() => handlerExport('')}
style={{ width: 'auto' }}
>
<Tabs
activeTab={exportType}
onChange={val => handlerExport(val)}
>
<TabPane key="dbml" title="DBML" />
<TabPane key="postgresql" title="PostgreSQL" />
<TabPane key="mysql" title="MySQL" />
<TabPane key="mssql" title="MSSQL" />
</Tabs>
<Editor
value={command}
language="sql"
width="680px"
height="80vh"
theme={theme === 'dark' ? 'vs-dark' : 'vs'}
options={{
readOnly: true,
minimap: { enabled: false },
scrollbar: { // 滚动条设置
verticalScrollbarSize: 6, // 竖滚动条
horizontalScrollbarSize: 6, // 横滚动条
},
lineNumbers: 'on', // 控制行号的出现on | off
}}
/>
</Modal>
);
}