@@ -31,8 +31,10 @@ const queryResultAsJSON = ref('')
3131const columns = ref ([] as string [])
3232const queryTip = ref (' ' )
3333const loadingStores = ref (true )
34+ const globalLoading = ref (false )
3435const showOverflowTooltip = ref (true )
3536const complexEditor = ref (false )
37+ const sqlEditorView = ref (null as any )
3638const dataFormat = ref (' table' )
3739const dataFormatOptions = [' table' , ' json' ]
3840const queryDataMeta = ref ({} as QueryDataMeta )
@@ -241,7 +243,10 @@ const executeWithQuery = async (sql: string) => {
241243 query .value .sql = sql
242244
243245 try {
244- const data = await API .DataQueryAsync (query .value );
246+ globalLoading .value = true
247+ const data = await API .DataQueryAsync (query .value , () => {
248+ globalLoading .value = false
249+ });
245250 switch (kind .value ) {
246251 case ExtensionKind .ExtensionKindORM :
247252 case ExtensionKind .ExtensionKindCassandra :
@@ -289,26 +294,37 @@ watch(largeContent, (e) => {
289294 largeContentDialogVisible .value = e !== ' '
290295})
291296
292- Magic .AdvancedKeys ([{
293- Keys: [' Ctrl+E' , ' Ctrl+Enter' ],
294- Func: executeQuery ,
295- Description: ' Execute query'
296- }, {
297- Keys: [' Ctrl+Shift+O' ],
298- Func : () => {
297+ const sqlEditorReady = (editor : any ) => {
298+ sqlEditorView .value = editor .view
299+ }
300+
301+ const executeWithSelectedQuery = () => {
302+ const selectedTextObj = sqlEditorView .value .state .selection .main
303+ const selectedText = sqlEditorView .value .state .sliceDoc (selectedTextObj .from , selectedTextObj .to )
304+ if (selectedText !== ' ' ) {
305+ showNativeSQL .value = false
306+ executeWithQuery (selectedText )
307+ }
308+ }
309+
310+ const executeQueryWithoutShowingNativeSQL = () => {
299311 showNativeSQL .value = false
300312 executeWithQuery (sqlQuery .value )
301- },
302- Description: ' Execute query without showing native SQL'
303- }])
313+ }
314+
315+ Magic .LoadMagicKeys (import .meta .url , new Map ([
316+ [" executeQuery" , executeQuery ],
317+ [" executeWithSelectedQuery" , executeWithSelectedQuery ],
318+ [" executeQueryWithoutShowingNativeSQL" , executeQueryWithoutShowingNativeSQL ],
319+ ]))
304320 </script >
305321
306322<template >
307323 <div >
308324 <div class =" page-header" >
309325 <span class =" page-title" >{{t('title.dataManager')}}</span >
310326 </div >
311- <el-container style =" height : calc (100vh - 80px );" >
327+ <el-container style =" height : calc (100vh - 80px );" v-loading = " globalLoading " >
312328 <el-aside v-if =" kind === 'atest-store-orm' || kind === 'atest-store-iotdb' || kind === 'atest-store-cassandra' || kind === 'atest-store-elasticsearch' || kind === 'atest-store-opengemini'" >
313329 <el-scrollbar >
314330 <el-select v-model =" queryDataMeta.currentDatabase" placeholder =" Select database"
@@ -380,6 +396,7 @@ Magic.AdvancedKeys([{
380396 </el-row >
381397 </el-form >
382398 <Codemirror
399+ @ready =" sqlEditorReady"
383400 v-model =" sqlQuery"
384401 v-if =" complexEditor"
385402 style =" height : var (--sql-editor-height );"
0 commit comments