@@ -6,6 +6,9 @@ import ScrollLoading from '@/components/ScrollLoading';
66import historyService , { IHistoryRecord } from '@/service/history' ;
77import * as monaco from 'monaco-editor' ;
88import i18n from '@/i18n' ;
9+ import { copy } from '@/utils' ;
10+ import { createConsole } from '@/pages/main/workspace/store/console' ;
11+ import { Popover } from 'antd' ;
912
1013interface IProps {
1114 className ?: string ;
@@ -34,7 +37,8 @@ export default memo<IProps>((props) => {
3437 const promiseList = res . data . map ( ( item ) => {
3538 return new Promise ( ( resolve ) => {
3639 // 不换行
37- const ddl = ( item . ddl || '' ) ?. replace ( / \n / g, ' ' ) ;
40+ // const ddl = (item.ddl || '')?.replace(/\n/g, ' ');
41+ const ddl = item . ddl || '' ;
3842 monaco . editor . colorize ( ddl , 'sql' , { } ) . then ( ( _res ) => {
3943 resolve ( {
4044 ...item ,
@@ -49,6 +53,22 @@ export default memo<IProps>((props) => {
4953 } ) ;
5054 } ;
5155
56+ const copySql = ( text : IDatasource [ 'ddl' ] ) => {
57+ copy ( text || '' ) ;
58+ }
59+
60+ const openSql = ( data : IDatasource ) => {
61+ createConsole ( {
62+ ddl : data . ddl || '' ,
63+ dataSourceId : data . dataSourceId ! ,
64+ dataSourceName : data . dataSourceName ! ,
65+ databaseType : data . type ! ,
66+ databaseName : data . databaseName ! ,
67+ schemaName : data . schemaName ! ,
68+ // operationType: WorkspaceTabType,
69+ } )
70+ }
71+
5272 return (
5373 < div className = { classnames ( styles . output , className ) } >
5474 < div className = { styles . outputTitle } >
@@ -64,19 +84,29 @@ export default memo<IProps>((props) => {
6484 >
6585 < >
6686 { dataSource . map ( ( item , index ) => {
67- const nameList = [ item . databaseName , item . schemaName ] ;
87+ const nameList = [ item . dataSourceName , item . databaseName , item . schemaName ] ;
6888 return (
6989 < div key = { index } className = { styles . outputItem } >
7090 < div className = { styles . timeBox } >
71- < div className = { classnames ( styles . iconBox , { [ styles . failureIconBox ] : item . status !== 'success' } ) } >
72- < Iconfont code = "" />
73- </ div >
91+ < Iconfont classNameBox = { classnames ( styles . timeBoxIcon , { [ styles . failureIconBox ] : item . status !== 'success' } ) } box boxSize = { 20 } code = "" />
7492 < span className = { styles . timeSpan } > [{ item . gmtCreate } ]</ span >
7593 { /* {!!item.operationRows && <span>{item.operationRows} rows</span> } */ }
7694 { ! ! item . useTime && < span > { i18n ( 'common.text.executionTime' , item . useTime ) } </ span > }
7795 </ div >
78- < div className = { styles . sqlPlace } > { nameList . filter ( ( name ) => name ) . join ( ' > ' ) } </ div >
79- < div className = { styles . sqlBox } dangerouslySetInnerHTML = { { __html : item . highlightedCode } } />
96+ < div className = { styles . executedDatabaseBox } >
97+ < Popover mouseEnterDelay = { 0.8 } content = { i18n ( 'workspace.tips.openExecutiveLogging' ) } >
98+ < Iconfont classNameBox = { styles . iconBox } box boxSize = { 20 } code = "" onClick = { ( ) => { openSql ( item ) } } />
99+ </ Popover >
100+ < div className = { styles . executedDatabase } >
101+ { nameList . filter ( ( name ) => name ) . join ( ' > ' ) }
102+ </ div >
103+ </ div >
104+ < div className = { styles . sqlBox } >
105+ < Popover mouseEnterDelay = { 0.8 } content = { i18n ( 'common.button.copy' ) } >
106+ < Iconfont classNameBox = { styles . iconBox } box boxSize = { 20 } code = "" onClick = { ( ) => { copySql ( item . ddl ) } } />
107+ </ Popover >
108+ < div className = { styles . sqlContent } dangerouslySetInnerHTML = { { __html : item . highlightedCode } } />
109+ </ div >
80110 </ div >
81111 ) ;
82112 } ) }
0 commit comments