11import React from 'react' ;
22import i18n from '@/i18n' ;
3- import { Button } from 'antd' ;
3+ import { Button , Popover } from 'antd' ;
44import { IBoundInfo } from '@/typings/workspace' ;
55import styles from './index.less' ;
66import Iconfont from '@/components/Iconfont' ;
77import SelectBoundInfo from '../SelectBoundInfo' ;
88import { formatSql } from '@/utils/sql' ;
9+ import { osNow } from '@/utils' ;
910
1011interface IProps {
1112 boundInfo : IBoundInfo ;
@@ -16,6 +17,19 @@ interface IProps {
1617 hasSaveBtn : boolean ;
1718}
1819
20+ const keyboardKey = ( function ( ) {
21+ if ( osNow ( ) . isMac ) {
22+ return {
23+ command : 'Cmd' ,
24+ Shift : 'Shift' ,
25+ } ;
26+ }
27+ return {
28+ command : 'Ctrl' ,
29+ Shift : 'Shift' ,
30+ } ;
31+ } ) ( ) ;
32+
1933const OperationLine = ( props : IProps ) => {
2034 const { boundInfo, saveConsole, editorRef, hasSaveBtn, executeSQL, setBoundInfo } = props ;
2135
@@ -37,18 +51,22 @@ const OperationLine = (props: IProps) => {
3751 return (
3852 < div className = { styles . consoleOptionsWrapper } >
3953 < div className = { styles . consoleOptionsLeft } >
40- < Button type = "primary" className = { styles . runButton } onClick = { ( ) => executeSQL ( ) } >
41- < Iconfont code = "" />
42- { i18n ( 'common.button.execute' ) }
43- </ Button >
44- { hasSaveBtn && (
45- < Button
46- type = "default"
47- className = { styles . saveButton }
48- onClick = { ( ) => saveConsole ( editorRef ?. current ?. getAllContent ( ) ) }
49- >
50- { i18n ( 'common.button.save' ) }
54+ < Popover mouseEnterDelay = { 0.8 } content = { [ keyboardKey . command , 'R' ] . join ( '+' ) } trigger = "hover" >
55+ < Button type = "primary" className = { styles . runButton } onClick = { ( ) => executeSQL ( ) } >
56+ < Iconfont code = "" />
57+ { i18n ( 'common.button.execute' ) }
5158 </ Button >
59+ </ Popover >
60+ { hasSaveBtn && (
61+ < Popover mouseEnterDelay = { 0.8 } content = { [ keyboardKey . command , 'S' ] . join ( '+' ) } trigger = "hover" >
62+ < Button
63+ type = "default"
64+ className = { styles . saveButton }
65+ onClick = { ( ) => saveConsole ( editorRef ?. current ?. getAllContent ( ) ) }
66+ >
67+ { i18n ( 'common.button.save' ) }
68+ </ Button >
69+ </ Popover >
5270 ) }
5371 < Button type = "default" onClick = { handleSQLFormat } >
5472 { i18n ( 'common.button.format' ) }
0 commit comments