✨ feat(shortcuts): 添加打开设置的键盘快捷键
新增 openSettings 快捷键,默认绑定 Mod+,,用于触发设置对话框。 包含所有语言包的翻译、键盘快捷键文档更新,以及测试用例。
This commit is contained in:
parent
19139a9b34
commit
178a800ce8
|
|
@ -47,6 +47,7 @@ import {
|
|||
isModRShortcut,
|
||||
isNewQueryShortcut,
|
||||
isObjectSourceSaveShortcutTarget,
|
||||
isOpenSettingsShortcut,
|
||||
isResetZoomShortcut,
|
||||
isRefreshDataShortcut,
|
||||
isSaveShortcut,
|
||||
|
|
@ -760,6 +761,12 @@ function handleKeydown(e: KeyboardEvent) {
|
|||
|
||||
const shortcuts = settingsStore.editorSettings.shortcuts;
|
||||
|
||||
if (isOpenSettingsShortcut(e, shortcuts)) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
showSettingsDialog.value = true;
|
||||
return;
|
||||
}
|
||||
if (isFocusSearchShortcut(e, shortcuts)) {
|
||||
const focused = contentAreaRef.value?.focusSearch() || appSidebarRef.value?.focusSearch();
|
||||
if (focused) {
|
||||
|
|
|
|||
|
|
@ -1863,6 +1863,7 @@ export default {
|
|||
shortcutCopyCurrentRow: "Copy current data row",
|
||||
shortcutDeleteCurrentRow: "Delete current data row",
|
||||
shortcutNewQuery: "New query",
|
||||
shortcutOpenSettings: "Open settings",
|
||||
shortcutCloseTab: "Close tab",
|
||||
shortcutFocusSearch: "Focus search",
|
||||
shortcutZoomInUi: "Zoom in UI",
|
||||
|
|
|
|||
|
|
@ -1653,6 +1653,7 @@ export default {
|
|||
shortcutCopyCurrentRow: "Copiar fila de datos actual",
|
||||
shortcutDeleteCurrentRow: "Eliminar fila de datos actual",
|
||||
shortcutNewQuery: "Nueva consulta",
|
||||
shortcutOpenSettings: "Abrir configuración",
|
||||
shortcutCloseTab: "Cerrar pestaña",
|
||||
shortcutFocusSearch: "Enfocar búsqueda",
|
||||
shortcutZoomInUi: "Ampliar interfaz",
|
||||
|
|
|
|||
|
|
@ -1799,6 +1799,7 @@ export default {
|
|||
shortcutCopyCurrentRow: "Copia riga dati corrente",
|
||||
shortcutDeleteCurrentRow: "Elimina riga dati corrente",
|
||||
shortcutNewQuery: "Nuova query",
|
||||
shortcutOpenSettings: "Apri impostazioni",
|
||||
shortcutCloseTab: "Chiudi scheda",
|
||||
shortcutFocusSearch: "Focalizza ricerca",
|
||||
shortcutZoomInUi: "Ingrandisci UI",
|
||||
|
|
|
|||
|
|
@ -1788,6 +1788,7 @@ export default {
|
|||
shortcutCopyCurrentRow: "Copiar linha de dados atual",
|
||||
shortcutDeleteCurrentRow: "Excluir linha de dados atual",
|
||||
shortcutNewQuery: "Nova consulta",
|
||||
shortcutOpenSettings: "Abrir configurações",
|
||||
shortcutCloseTab: "Fechar aba",
|
||||
shortcutFocusSearch: "Focar na pesquisa",
|
||||
shortcutZoomInUi: "Aumentar zoom da UI",
|
||||
|
|
|
|||
|
|
@ -1816,6 +1816,7 @@ export default {
|
|||
shortcutCopyCurrentRow: "复制当前数据行",
|
||||
shortcutDeleteCurrentRow: "删除当前数据行",
|
||||
shortcutNewQuery: "新建查询",
|
||||
shortcutOpenSettings: "打开设置",
|
||||
shortcutCloseTab: "关闭标签页",
|
||||
shortcutFocusSearch: "聚焦搜索",
|
||||
shortcutZoomInUi: "放大全局界面",
|
||||
|
|
|
|||
|
|
@ -1692,6 +1692,7 @@ export default {
|
|||
shortcutCopyCurrentRow: "複製目前資料列",
|
||||
shortcutDeleteCurrentRow: "刪除目前資料列",
|
||||
shortcutNewQuery: "建立查詢",
|
||||
shortcutOpenSettings: "開啟設定",
|
||||
shortcutCloseTab: "關閉分頁",
|
||||
shortcutFocusSearch: "聚焦搜尋",
|
||||
shortcutZoomInUi: "放大全域介面",
|
||||
|
|
|
|||
|
|
@ -80,6 +80,10 @@ export function isNewQueryShortcut(event: ShortcutLikeEvent, shortcuts?: Partial
|
|||
return matchesShortcut(event, actionShortcut("newQuery", shortcuts));
|
||||
}
|
||||
|
||||
export function isOpenSettingsShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
|
||||
return matchesShortcut(event, actionShortcut("openSettings", shortcuts));
|
||||
}
|
||||
|
||||
export function isFocusSearchShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
|
||||
return matchesShortcut(event, actionShortcut("focusSearch", shortcuts));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ export type ShortcutActionId =
|
|||
| "copyCurrentRow"
|
||||
| "deleteCurrentRow"
|
||||
| "newQuery"
|
||||
| "openSettings"
|
||||
| "closeTab"
|
||||
| "focusSearch"
|
||||
| "zoomInUi"
|
||||
|
|
@ -64,6 +65,12 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
|
|||
scope: "global",
|
||||
defaultShortcut: "Mod+T",
|
||||
},
|
||||
{
|
||||
id: "openSettings",
|
||||
labelKey: "settings.shortcutOpenSettings",
|
||||
scope: "global",
|
||||
defaultShortcut: "Mod+,",
|
||||
},
|
||||
{
|
||||
id: "closeTab",
|
||||
labelKey: "settings.shortcutCloseTab",
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ DBX 为常用操作提供可配置的键盘快捷键。使用默认快捷键或
|
|||
|---|---|
|
||||
| `Ctrl+N` / `Cmd+N` | 新建查询标签页 |
|
||||
| `Ctrl+Shift+F` / `Cmd+Shift+F` | 聚焦侧边栏搜索 |
|
||||
| `Ctrl+,` / `Cmd+,` | 打开设置 |
|
||||
| `Ctrl+W` / `Cmd+W` | 关闭当前标签页 |
|
||||
| `鼠标中键`(点击标签页) | 关闭标签页 |
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ DBX provides configurable keyboard shortcuts for common actions. Use the default
|
|||
|---|---|
|
||||
| `Ctrl+N` / `Cmd+N` | New query tab |
|
||||
| `Ctrl+Shift+F` / `Cmd+Shift+F` | Focus sidebar search |
|
||||
| `Ctrl+,` / `Cmd+,` | Open settings |
|
||||
| `Ctrl+W` / `Cmd+W` | Close current tab |
|
||||
| `Middle Click` (on tab) | Close tab |
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {
|
|||
isModRShortcut,
|
||||
isNewQueryShortcut,
|
||||
isObjectSourceSaveShortcutTarget,
|
||||
isOpenSettingsShortcut,
|
||||
isResetZoomShortcut,
|
||||
isRefreshDataShortcut,
|
||||
isSaveShortcut,
|
||||
|
|
@ -65,6 +66,22 @@ test("matches custom shortcut settings for opening a new query", () => {
|
|||
);
|
||||
});
|
||||
|
||||
test("matches Mod+Comma for opening settings", () => {
|
||||
assert.equal(isOpenSettingsShortcut({ key: ",", metaKey: true }), true);
|
||||
assert.equal(isOpenSettingsShortcut({ key: ",", ctrlKey: true }), true);
|
||||
assert.equal(isOpenSettingsShortcut({ key: ",", altKey: true }), false);
|
||||
});
|
||||
|
||||
test("matches custom shortcut settings for opening settings", () => {
|
||||
assert.equal(isOpenSettingsShortcut({ key: ",", metaKey: true }, { openSettings: "Shift+Mod+P" } as any), false);
|
||||
assert.equal(
|
||||
isOpenSettingsShortcut({ key: "p", ctrlKey: true, shiftKey: true } as any, {
|
||||
openSettings: "Shift+Mod+P",
|
||||
} as any),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("ignores Enter without modifier", () => {
|
||||
assert.equal(isExecuteSqlShortcut({ key: "Enter" }), false);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ test("defaults shortcut settings", () => {
|
|||
assert.equal(settings.shortcuts.copyCurrentRow, "Mod+D");
|
||||
assert.equal(settings.shortcuts.deleteCurrentRow, "Delete");
|
||||
assert.equal(settings.shortcuts.newQuery, "Mod+T");
|
||||
assert.equal(settings.shortcuts.openSettings, "Mod+,");
|
||||
assert.equal(settings.shortcuts.focusSearch, "Mod+F");
|
||||
assert.equal(settings.shortcuts.zoomInUi, "Mod+=");
|
||||
assert.equal(settings.shortcuts.zoomOutUi, "Mod+-");
|
||||
|
|
@ -72,6 +73,7 @@ test("keeps saved shortcut overrides", () => {
|
|||
copyCurrentRow: "Alt+Shift+D",
|
||||
deleteCurrentRow: "Backspace",
|
||||
newQuery: "Shift+Mod+N",
|
||||
openSettings: "Shift+Mod+P",
|
||||
zoomInUi: "Alt+Mod+=",
|
||||
} as any,
|
||||
});
|
||||
|
|
@ -80,6 +82,7 @@ test("keeps saved shortcut overrides", () => {
|
|||
assert.equal(settings.shortcuts.copyCurrentRow, "Alt+Shift+D");
|
||||
assert.equal(settings.shortcuts.deleteCurrentRow, "Backspace");
|
||||
assert.equal(settings.shortcuts.newQuery, "Shift+Mod+N");
|
||||
assert.equal(settings.shortcuts.openSettings, "Shift+Mod+P");
|
||||
assert.equal(settings.shortcuts.zoomInUi, "Alt+Mod+=");
|
||||
assert.equal(settings.shortcuts.saveSql, "Mod+S");
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue