File tree Expand file tree Collapse file tree
pages/main/workspace/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { defineConfig } from 'umi' ;
22import { extractYarnConfig } from './src/utils/webpack' ;
33const MonacoWebpackPlugin = require ( 'monaco-editor-webpack-plugin' ) ;
4- const UMI_PublicPath = process . env . UMI_PublicPath || './static/front/' ;
54const yarn_config = extractYarnConfig ( process . argv ) ;
5+ const publicPath = yarn_config . public_path || './static/front/' ;
66
77const chainWebpack = ( config : any , { webpack } : any ) => {
88 config . plugin ( 'monaco-editor' ) . use ( MonacoWebpackPlugin , [
@@ -13,7 +13,7 @@ const chainWebpack = (config: any, { webpack }: any) => {
1313} ;
1414
1515export default defineConfig ( {
16- publicPath : UMI_PublicPath ,
16+ publicPath : publicPath ,
1717 chainWebpack,
1818 define : {
1919 'process.env.UMI_ENV' : process . env . UMI_ENV ,
Original file line number Diff line number Diff line change 1+ @import ' ../../styles/var.less' ;
2+
3+ .box {
4+ display : flex ;
5+ flex-direction : column ;
6+ justify-content : center ;
7+ align-items : center ;
8+
9+ .letterpress {
10+ display : flex ;
11+ justify-content : center ;
12+ align-items : center ;
13+ font-size : 80px ;
14+ font-weight : 900 ;
15+ color : var (--color-text );
16+ opacity : 0.15 ;
17+ overflow : hidden ;
18+ margin-bottom : 30px ;
19+ }
20+
21+ .shortcutsItem {
22+ display : flex ;
23+ justify-content : center ;
24+ font-size : 14px ;
25+ margin : 10px 0px ;
26+ color : var (--color-text-tertiary );
27+
28+ .title {
29+ margin-right : 10px ;
30+ }
31+ }
32+
33+ .plusSign {
34+ margin : 0px 4px ;
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ import React , { memo , Fragment } from 'react' ;
2+ import i18n from '@/i18n' ;
3+ import styles from './index.less' ;
4+ import classnames from 'classnames' ;
5+ import { OSnow } from '@/utils'
6+
7+ interface IProps {
8+ className ?: string ;
9+ }
10+
11+ const keyboardKey = ( function ( ) {
12+ if ( OSnow ( ) . isMac ) {
13+ return {
14+ command : 'Cmd'
15+ }
16+ }
17+ return {
18+ command : 'Ctrl'
19+ }
20+ } ( ) )
21+
22+ const shortcutsList = [
23+ {
24+ title : i18n ( 'common.text.saveConsole' ) ,
25+ keys : [
26+ keyboardKey . command ,
27+ 'S'
28+ ]
29+ } ,
30+ {
31+ title : i18n ( 'common.text.refreshPage' ) ,
32+ keys : [
33+ keyboardKey . command ,
34+ 'R'
35+ ]
36+ } ,
37+ {
38+ title : i18n ( 'common.button.createConsole' ) ,
39+ keys : [
40+ keyboardKey . command ,
41+ 'T'
42+ ]
43+ } ,
44+ {
45+ title : i18n ( 'common.text.executeSelectedSQL' ) ,
46+ keys : [
47+ keyboardKey . command ,
48+ 'Enter'
49+ ]
50+ } ,
51+ ]
52+
53+ export default memo < IProps > ( function ShortcutKey ( props ) {
54+ const { className } = props ;
55+ return < div className = { classnames ( styles . box , className ) } >
56+ < div className = { styles . letterpress } >
57+ Chat2DB
58+ </ div >
59+ < div className = { styles . shortcuts } >
60+ {
61+ shortcutsList . map ( ( t , i ) => {
62+ return < div key = { i } className = { styles . shortcutsItem } >
63+ < div className = { styles . title } >
64+ { t . title }
65+ </ div >
66+ < div >
67+ { t . keys . map ( ( item , i ) => {
68+ return < Fragment key = { i } >
69+ < span >
70+ { item }
71+ </ span >
72+ {
73+ i + 1 < t . keys . length &&
74+ < span className = { styles . plusSign } >
75+ +
76+ </ span >
77+ }
78+ </ Fragment >
79+ } ) }
80+ </ div >
81+ </ div >
82+ } )
83+ }
84+ </ div >
85+ </ div >
86+ } )
Original file line number Diff line number Diff line change @@ -25,4 +25,10 @@ export enum ConsoleOpenedStatus {
2525export enum ConsoleStatus {
2626 DRAFT = 'DRAFT' ,
2727 RELEASE = 'RELEASE' ,
28- }
28+ }
29+
30+ export enum OSType {
31+ WIN = 'Win' ,
32+ MAC = 'Mac' ,
33+ RESTS = 'rests' ,
34+ }
Original file line number Diff line number Diff line change @@ -68,4 +68,7 @@ export default {
6868 'common.button.copyErrorTips' :
6969 '(The interface information and detailed parameters will be copied here. If there are sensitive parameters, please parse JSON first and then send them)' ,
7070 'common.tips.formatError' : 'Formatting failed, please check whether the sql is correct' ,
71+ 'common.text.executeSelectedSQL' : 'Execute selected SQL' ,
72+ 'common.text.refreshPage' : 'Refresh page' ,
73+ 'common.text.saveConsole' : 'Save console' ,
7174} ;
Original file line number Diff line number Diff line change @@ -66,4 +66,7 @@ export default {
6666 'common.button.copyError' : '复制错误报告' ,
6767 'common.button.copyErrorTips' : '(这里会复制接口信息以及详细参数,如有敏感参数,请先解析JSON处理后在发送)' ,
6868 'common.tips.formatError' : '格式化失败,请看sql是否正确' ,
69+ 'common.text.executeSelectedSQL' : '执行选中SQL' ,
70+ 'common.text.refreshPage' : '刷新页面' ,
71+ 'common.text.saveConsole' : '保存控制台' ,
6972} ;
Original file line number Diff line number Diff line change @@ -82,6 +82,16 @@ const WorkspaceLeft = memo<IProps>(function (props) {
8282 addConsole ( ) ;
8383 }
8484
85+ useEffect ( ( ) => {
86+ document . addEventListener ( 'keydown' , ( e ) => {
87+ console . log ( e . metaKey , e . key === 't' )
88+ if ( ( e . ctrlKey || e . metaKey ) && e . key === 't' ) {
89+ e . preventDefault ( ) ;
90+ addConsole ( ) ;
91+ }
92+ } , false )
93+ } , [ ] )
94+
8595 return (
8696 < div className = { classnames ( styles . box , className ) } >
8797 < RenderSaveBox > </ RenderSaveBox >
Original file line number Diff line number Diff line change 4646 display : flex ;
4747 justify-content : center ;
4848 align-items : center ;
49- font-size : 120px ;
50- font-weight : 900 ;
51- color : var (--color-text );
52- opacity : 0.15 ;
53- overflow : hidden ;
5449}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { IConsole, ICreateConsole } from '@/typings';
77import historyService from '@/service/history' ;
88import Tabs , { IOption } from '@/components/Tabs' ;
99import LoadingContent from '@/components/Loading/LoadingContent' ;
10+ import ShortcutKey from '@/components/ShortcutKey' ;
1011import WorkspaceRightItem from '../WorkspaceRightItem' ;
1112import { IWorkspaceModelState , IWorkspaceModelType } from '@/models/workspace' ;
1213import { IAIState } from '@/models/ai' ;
@@ -188,8 +189,8 @@ const WorkspaceRight = memo<IProps>(function (props) {
188189 // }
189190 } ;
190191
191- function render ( ) {
192- return < div className = { styles . ears } > Chat2DB </ div > ;
192+ function renderEmpty ( ) {
193+ return < div className = { styles . ears } > < ShortcutKey /> </ div > ;
193194 }
194195
195196 function editableNameOnBlur ( t : IOption ) {
@@ -221,7 +222,7 @@ const WorkspaceRight = memo<IProps>(function (props) {
221222
222223 return (
223224 < div className = { classnames ( styles . box , className ) } >
224- < LoadingContent data = { openConsoleList } handleEmpty empty = { render ( ) } >
225+ < LoadingContent data = { openConsoleList } handleEmpty empty = { renderEmpty ( ) } >
225226 < div className = { styles . tabBox } >
226227 < Tabs
227228 className = { styles . tabs }
Original file line number Diff line number Diff line change 1- import { ThemeType } from '@/constants' ;
1+ import { ThemeType , OSType } from '@/constants' ;
22import { ITreeNode } from '@/typings' ;
33import clipboardCopy from 'copy-to-clipboard' ;
44import lodash from 'lodash' ;
@@ -216,3 +216,17 @@ export function getApplicationMessage() {
216216 }
217217}
218218
219+ // os is mac or windows
220+ export function OSnow ( ) : {
221+ isMac : boolean ;
222+ isWin : boolean ;
223+ } {
224+ const agent = navigator . userAgent . toLowerCase ( ) ;
225+ const isMac = / m a c i n t o s h | m a c o s x / i. test ( navigator . userAgent ) ;
226+ const isWin = agent . indexOf ( "win32" ) >= 0 || agent . indexOf ( "wow32" ) >= 0 || agent . indexOf ( "win64" ) >= 0 || agent . indexOf ( "wow64" ) >= 0
227+ return {
228+ isMac,
229+ isWin
230+ }
231+ }
232+
You can’t perform that action at this time.
0 commit comments