feat(app): add new query shortcut

This commit is contained in:
t8y2
2026-05-21 10:34:04 +08:00
parent ab6c73c687
commit 888d3d8890
8 changed files with 44 additions and 2 deletions
+7
View File
@@ -38,6 +38,7 @@ import {
isCloseTabShortcut,
isExecuteSqlShortcut,
isFocusSearchShortcut,
isNewQueryShortcut,
isObjectSourceSaveShortcutTarget,
isRefreshDataShortcut,
isSaveShortcut,
@@ -587,6 +588,12 @@ function handleKeydown(e: KeyboardEvent) {
contentAreaRef.value?.refreshData();
return;
}
if (isNewQueryShortcut(e, shortcuts)) {
e.preventDefault();
e.stopPropagation();
void newQuery();
return;
}
if (isCloseTabShortcut(e, shortcuts)) {
e.preventDefault();
if (showDriverStore.value) {
+1
View File
@@ -1198,6 +1198,7 @@ export default {
redisScanPageSizeOption: "{count} keys",
shortcutExecuteSql: "Execute SQL",
shortcutSaveSql: "Save SQL",
shortcutNewQuery: "New query",
shortcutCloseTab: "Close tab",
shortcutFocusSearch: "Focus search",
shortcutRefreshData: "Refresh data",
+1
View File
@@ -1097,6 +1097,7 @@ export default {
redisScanPageSizeOption: "{count} claves",
shortcutExecuteSql: "Ejecutar SQL",
shortcutSaveSql: "Guardar SQL",
shortcutNewQuery: "Nueva consulta",
shortcutCloseTab: "Cerrar pestaña",
shortcutFocusSearch: "Enfocar búsqueda",
shortcutRefreshData: "Actualizar datos",
+1
View File
@@ -1176,6 +1176,7 @@ export default {
redisScanPageSizeOption: "{count} 个 Key",
shortcutExecuteSql: "执行 SQL",
shortcutSaveSql: "保存 SQL",
shortcutNewQuery: "新建查询",
shortcutCloseTab: "关闭标签页",
shortcutFocusSearch: "聚焦搜索",
shortcutRefreshData: "刷新数据",
@@ -76,6 +76,10 @@ export function isCloseTabShortcut(event: ShortcutLikeEvent, shortcuts?: Partial
return matchesShortcut(event, actionShortcut("closeTab", shortcuts));
}
export function isNewQueryShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
return matchesShortcut(event, actionShortcut("newQuery", shortcuts));
}
export function isFocusSearchShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
return matchesShortcut(event, actionShortcut("focusSearch", shortcuts));
}
+14 -1
View File
@@ -1,4 +1,11 @@
export type ShortcutActionId = "executeSql" | "saveSql" | "closeTab" | "focusSearch" | "refreshData" | "cancelSearch";
export type ShortcutActionId =
| "executeSql"
| "saveSql"
| "newQuery"
| "closeTab"
| "focusSearch"
| "refreshData"
| "cancelSearch";
export type ShortcutScope = "global" | "editor" | "search";
@@ -24,6 +31,12 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
scope: "editor",
defaultShortcut: "Mod+S",
},
{
id: "newQuery",
labelKey: "settings.shortcutNewQuery",
scope: "global",
defaultShortcut: "Mod+T",
},
{
id: "closeTab",
labelKey: "settings.shortcutCloseTab",