Unverified Commit 1d97f07d authored by 高岩's avatar 高岩 Committed by GitHub

optimize clear console, add clear console at right click (#1513)

parent 79b4536d
...@@ -27,6 +27,7 @@ export type CodeShowFormProps = { ...@@ -27,6 +27,7 @@ export type CodeShowFormProps = {
theme?: string; theme?: string;
options?: any; options?: any;
code: string; code: string;
editorDidMountHandle: any;
}; };
const CodeShow = (props: CodeShowFormProps) => { const CodeShow = (props: CodeShowFormProps) => {
...@@ -44,6 +45,7 @@ const CodeShow = (props: CodeShowFormProps) => { ...@@ -44,6 +45,7 @@ const CodeShow = (props: CodeShowFormProps) => {
automaticLayout: true, automaticLayout: true,
}, },
code, code,
editorDidMountHandle,
} = props; } = props;
return (<> return (<>
...@@ -54,6 +56,7 @@ const CodeShow = (props: CodeShowFormProps) => { ...@@ -54,6 +56,7 @@ const CodeShow = (props: CodeShowFormProps) => {
value={code} value={code}
options={options} options={options}
theme='vs-dark' theme='vs-dark'
editorDidMount={editorDidMountHandle}
/> />
</>) </>)
}; };
......
...@@ -22,6 +22,8 @@ import {connect} from "umi"; ...@@ -22,6 +22,8 @@ import {connect} from "umi";
import React, {useEffect, useState} from "react"; import React, {useEffect, useState} from "react";
import CodeShow from "@/components/Common/CodeShow"; import CodeShow from "@/components/Common/CodeShow";
import {getConsoleInfo} from "@/pages/SettingCenter/ProcessList/service"; import {getConsoleInfo} from "@/pages/SettingCenter/ProcessList/service";
import { clearConsole } from "../../StudioEvent/DDL";
import {l} from "@/utils/intl";
const StudioMsg = (props: any) => { const StudioMsg = (props: any) => {
...@@ -45,9 +47,25 @@ const StudioMsg = (props: any) => { ...@@ -45,9 +47,25 @@ const StudioMsg = (props: any) => {
} }
} }
const editorDidMountHandle = (editor: any, monaco: any) => {
editor.addAction({
id: 'btn-studio-msg-clear', // menu id
label: l('pages.datastudio.editor.clearConsole'), // menu name
contextMenuGroupId: '9_cutcopypaste', // menu group
run: () => {
clearConsole().then((result) => {
setConsoleInfo("")
refreshConsoleInfo()
});
}, // 点击后执行的操作
})
};
return ( return (
<> <>
<CodeShow code={consoleInfo} language='java' height={height} theme="vs"/> <CodeShow code={consoleInfo} language='java' height={height} theme="vs" editorDidMountHandle={editorDidMountHandle}/>
</> </>
); );
}; };
......
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