Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(editor): display configured execute shortcut

Melody Ruchdf95288aab93
diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vue
index 254d487578..9a58d8953e 100644
--- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue
+++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue
@@ -275,6 +275,11 @@ const editCustomThemes = ref<CustomTheme[]>([...settingsStore.editorSettings.cus
const editActiveCustomThemeId = ref(settingsStore.editorSettings.activeCustomThemeId);
const showThemeCustomizer = ref(false);
const editExecuteMode = ref(settingsStore.editorSettings.executeMode);
+const editShortcuts = ref(normalizeShortcutSettings(settingsStore.editorSettings.shortcuts));
+function translateWithExecuteShortcut(key: string): string {
+ return t(key, { shortcut: formatShortcutDisplay(editShortcuts.value.executeSql) });
+}
+const executeModeLabel = computed(() => translateWithExecuteShortcut("settings.executeMode"));
const editExecuteAllOnBlankLine = ref(settingsStore.editorSettings.executeAllOnBlankLine);
const editShowExecutionTargetPicker = ref(settingsStore.editorSettings.showExecutionTargetPicker);
const editShowStatementRunButtons = ref(settingsStore.editorSettings.showStatementRunButtons);
@@ -379,7 +384,6 @@ function setSqlVariableSyntaxToggle(key: keyof SqlVariableSyntaxToggles, value:
const tableColumnTemplateSectionRef = ref<HTMLElement | null>(null);
const draggedTableColumnTemplateRowId = ref<string | null>(null);
let tableColumnTemplatePointerDragCleanup: (() => void) | null = null;
-const editShortcuts = ref(normalizeShortcutSettings(settingsStore.editorSettings.shortcuts));
const editSqlFormatter = ref<SqlFormatterSettings>(normalizeSqlFormatterSettings(settingsStore.editorSettings.sqlFormatter));
const sqlFormatterConfigValid = ref(true);
const editingShortcutId = ref<ShortcutActionId | null>(null);
@@ -1474,7 +1478,7 @@ const settingsSearchEntries = computed(() =>
isWeb,
visibleCategories: new Set(settingsCategoryNav.value.map((category) => category.value)),
},
- t,
+ translateWithExecuteShortcut,
settingsSearchCategoryLabels.value,
),
);
@@ -3681,10 +3685,10 @@ onUnmounted(() => {
<div class="grid gap-4 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
<div class="space-y-2">
- <Label>{{ t("settings.executeMode") }}</Label>
+ <Label>{{ executeModeLabel }}</Label>
<Select :model-value="editExecuteMode" @update:model-value="onExecuteModeChange">
<SelectTrigger>
- <SelectValue :placeholder="t('settings.executeMode')" />
+ <SelectValue :placeholder="executeModeLabel" />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">{{ t("settings.executeModeAll") }}</SelectItem>
diff --git a/apps/desktop/src/components/layout/EditorToolbar.vue b/apps/desktop/src/components/layout/EditorToolbar.vue
index a98fcbc1f4..344f85557d 100644
--- a/apps/desktop/src/components/layout/EditorToolbar.vue
+++ b/apps/desktop/src/components/layout/EditorToolbar.vue
@@ -9,6 +9,7 @@ import TruncatedTextTooltip from "@/components/ui/TruncatedTextTooltip.vue";
import DatabaseIcon from "@/components/icons/DatabaseIcon.vue";
import ProductionContextBadge from "@/components/common/ProductionContextBadge.vue";
import { useConnectionStore } from "@/stores/connectionStore";
+import { useSettingsStore } from "@/stores/settingsStore";
import { catalogDatabaseOptionsKey, databaseAfterCatalogChange, normalizedQueryTabCatalog, queryCatalogSelectorVisible, selectedQueryCatalogName, useDatabaseOptions } from "@/composables/useDatabaseOptions";
import { useSchemaOptions } from "@/composables/useSchemaOptions";
import { connectionIconType } from "@/lib/connection/connectionPresentation";
@@ -20,6 +21,7 @@ import { supportsQueryExecution } from "@/lib/database/databaseFeatureSupport";
import { connectionIsDorisFamilyCatalogCapable } from "@/lib/database/databaseFeatureSupport";
import { hexToRgba } from "@/lib/common/color";
import { productionContextForDatabase } from "@/lib/database/productionSafety";
+import { formatShortcutDisplay } from "@/lib/editor/shortcutDisplay";
import type { QueryTab, ConnectionConfig } from "@/types/database";
const props = defineProps<{
@@ -63,6 +65,7 @@ const emit = defineEmits<{
const { t } = useI18n();
const connectionStore = useConnectionStore();
+const settingsStore = useSettingsStore();
const { databaseOptions, loadingDatabaseOptions, loadDatabaseOptions, catalogOptions, loadingCatalogOptions, loadCatalogOptions, catalogDatabaseOptions, loadingCatalogDatabaseOptions, loadCatalogDatabaseOptions } = useDatabaseOptions();
const { loadSchemaOptions, getSchemaOptionsForDb, isLoadingSchemas, isSchemaAware } = useSchemaOptions();
@@ -122,6 +125,8 @@ const supportsTransaction = computed(() => supportsTransactionFeature(props.acti
const hasDefaultDatabaseOption = computed(() => activeDatabaseOptions.value.includes(""));
const schemaDatabaseKey = computed(() => props.activeTab.database || (isSingleDb.value ? "_" : ""));
const saveTooltip = computed(() => (props.activeTab.objectSource ? t("objects.saveSource") : t("toolbar.saveSql")));
+const executeShortcutDisplay = computed(() => formatShortcutDisplay(settingsStore.editorSettings.shortcuts.executeSql));
+const executeShortcutTooltip = computed(() => t("toolbar.executeShortcut", { shortcut: executeShortcutDisplay.value }));
// DM calls it autotrace, Postgres EXPLAIN ANALYZE, SQL Server the actual execution
// plan (SET STATISTICS XML); all three execute the statement.
const supportsExplainAnalyze = computed(() => {
@@ -261,7 +266,7 @@ async function changeCatalog(selectedCatalog: string) {
<Play v-else class="h-3.5 w-3.5" />
</Button>
</TooltipTrigger>
- <TooltipContent>{{ activeTab.isExecuting ? t("toolbar.stopQuery") : t("toolbar.executeShortcut") }}</TooltipContent>
+ <TooltipContent>{{ activeTab.isExecuting ? t("toolbar.stopQuery") : executeShortcutTooltip }}</TooltipContent>
</Tooltip>
<Tooltip v-if="supportsExplain">
<TooltipTrigger as-child>
diff --git a/apps/desktop/src/i18n/__tests__/executeShortcutHint.spec.ts b/apps/desktop/src/i18n/__tests__/executeShortcutHint.spec.ts
new file mode 100644
index 0000000000..92dbd38cb2
--- /dev/null
+++ b/apps/desktop/src/i18n/__tests__/executeShortcutHint.spec.ts
@@ -0,0 +1,50 @@
+import { readFileSync } from "node:fs";
+import { describe, expect, it } from "vitest";
+import i18n, { setLocale } from "@/i18n";
+import { formatShortcutDisplay } from "@/lib/editor/shortcutDisplay";
+
+// https://github.com/t8y2/dbx/issues/6199
+// "设置为 Windows 但编辑器提示仍为 Mac" — the toolbar's Execute-button tooltip and the
+// Editor Settings "Execute Mode" label hardcode "(Cmd+Enter)" in every locale, including
+// English, so the hints can disagree with both the current platform and a customized binding.
+
+const toolbarSource = readFileSync(new URL("../../components/layout/EditorToolbar.vue", import.meta.url), "utf8");
+const settingsDialogSource = readFileSync(new URL("../../components/editor/EditorSettingsDialog.vue", import.meta.url), "utf8");
+
+describe("execute-shortcut hints reflect the configured binding", () => {
+ it.each([
+ ["MacIntel", "Mod+Enter", "⌘ ↵"],
+ ["Win32", "Mod+Enter", "Ctrl + ↵"],
+ ["Linux x86_64", "Mod+Enter", "Ctrl + ↵"],
+ ["Win32", "Shift+Mod+Enter", "Ctrl + Shift + ↵"],
+ ])("formats %s shortcuts for the active platform", (platform, shortcut, expected) => {
+ expect(formatShortcutDisplay(shortcut, platform)).toBe(expected);
+ });
+
+ it("interpolates the formatted shortcut into toolbar and settings labels", async () => {
+ const shortcut = formatShortcutDisplay("Shift+Mod+Enter", "Win32");
+
+ await setLocale("en");
+ expect(i18n.global.t("toolbar.executeShortcut", { shortcut })).toBe("Execute selection/query (Ctrl + Shift + ↵)");
+ expect(i18n.global.t("settings.executeMode", { shortcut })).toBe("Execute Mode (Ctrl + Shift + ↵)");
+
+ await setLocale("zh-CN");
+ expect(i18n.global.t("toolbar.executeShortcut", { shortcut })).toBe("执行选中/全部 (Ctrl + Shift + ↵)");
+ expect(i18n.global.t("settings.executeMode", { shortcut })).toBe("执行模式 (Ctrl + Shift + ↵)");
+ await setLocale("en");
+ });
+
+ it("EditorToolbar.vue uses the saved executeSql shortcut", () => {
+ expect(toolbarSource).toContain("formatShortcutDisplay(settingsStore.editorSettings.shortcuts.executeSql)");
+ expect(toolbarSource).toMatch(/t\(\s*"toolbar\.executeShortcut"\s*,\s*\{\s*shortcut:\s*executeShortcutDisplay\.value/);
+ });
+
+ it("EditorSettingsDialog.vue uses the currently edited executeSql shortcut", () => {
+ expect(settingsDialogSource).toMatch(/function translateWithExecuteShortcut\([^)]*\)[^}]*formatShortcutDisplay\(editShortcuts\.value\.executeSql\)/);
+ expect(settingsDialogSource).toContain('translateWithExecuteShortcut("settings.executeMode")');
+ });
+
+ it("EditorSettingsDialog.vue uses the same edited shortcut in settings search", () => {
+ expect(settingsDialogSource).toMatch(/resolveSettingsSearchEntries\(\s*\[[^\]]*\]\s*,\s*\{[^}]*\}\s*,\s*translateWithExecuteShortcut\s*,/s);
+ });
+});
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index eed4c8da71..854bb13a2c 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -144,7 +144,7 @@ export default {
newConnection: "New Connection",
newQuery: "New Query",
execute: "Execute",
- executeShortcut: "Execute selection/query (Cmd+Enter)",
+ executeShortcut: "Execute selection/query ({shortcut})",
stopQuery: "Stop query",
explainPlan: "Explain plan",
stopExplain: "Stop explain",
@@ -5855,7 +5855,7 @@ export default {
resetAllDefaults: "Reset All Defaults",
save: "Save",
cancel: "Cancel",
- executeMode: "Execute Mode (Cmd+Enter)",
+ executeMode: "Execute Mode ({shortcut})",
executeModeAll: "Execute all SQL",
executeModeCurrent: "Execute statement at cursor",
executeAllOnBlankLine: "Execute all SQL from blank lines",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 79a7e427fc..c1c67d89d5 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -145,7 +145,7 @@ export default withEnglishFallback({
newConnection: "Nueva conexión",
newQuery: "Nueva consulta",
execute: "Ejecutar",
- executeShortcut: "Ejecutar selección/consulta (Cmd+Enter)",
+ executeShortcut: "Ejecutar selección/consulta ({shortcut})",
stopQuery: "Detener consulta",
explainPlan: "Plan de ejecución",
stopExplain: "Detener análisis",
@@ -5574,7 +5574,7 @@ export default withEnglishFallback({
resetAllDefaults: "Restablecer todos los valores por defecto",
save: "Guardar",
cancel: "Cancelar",
- executeMode: "Modo de ejecución (Cmd+Enter)",
+ executeMode: "Modo de ejecución ({shortcut})",
executeModeAll: "Ejecutar todo el SQL",
executeModeCurrent: "Ejecutar sentencia en el cursor",
executeAllOnBlankLine: "Ejecutar todo el SQL desde líneas en blanco",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 95037de0ca..a5701f5637 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -144,7 +144,7 @@ export default withEnglishFallback({
newConnection: "Nuova Connessione",
newQuery: "Nuova Query",
execute: "Esegui",
- executeShortcut: "Esegui selezione/query (Cmd+Enter)",
+ executeShortcut: "Esegui selezione/query ({shortcut})",
stopQuery: "Interrompi query",
explainPlan: "Spiega piano",
stopExplain: "Interrompi spiegazione",
@@ -5574,7 +5574,7 @@ export default withEnglishFallback({
resetAllDefaults: "Ripristina Tutti i Predefiniti",
save: "Salva",
cancel: "Annulla",
- executeMode: "Modalità Esecuzione (Cmd+Enter)",
+ executeMode: "Modalità Esecuzione ({shortcut})",
executeModeAll: "Esegui tutto l'SQL",
executeModeCurrent: "Esegui istruzione al cursore",
executeAllOnBlankLine: "Esegui tutto l'SQL dalle righe vuote",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index 6992817268..de31dea169 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -145,7 +145,7 @@ export default withEnglishFallback({
newConnection: "新しい接続",
newQuery: "新しいクエリ",
execute: "実行",
- executeShortcut: "選択範囲/クエリを実行 (Cmd+Enter)",
+ executeShortcut: "選択範囲/クエリを実行 ({shortcut})",
stopQuery: "クエリを停止",
explainPlan: "実行計画を表示",
stopExplain: "実行計画の表示を停止",
@@ -5601,7 +5601,7 @@ export default withEnglishFallback({
resetAllDefaults: "すべての設定をリセット",
save: "保存",
cancel: "キャンセル",
- executeMode: "実行モード (Cmd+Enter)",
+ executeMode: "実行モード ({shortcut})",
executeModeAll: "すべてのSQLを実行",
executeModeCurrent: "カーソル位置の文を実行",
executeAllOnBlankLine: "空行ではすべてのSQLを実行",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 61b3cf81ec..b2e70e82a9 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -145,7 +145,7 @@ export default withEnglishFallback({
newConnection: "새 연결",
newQuery: "새 쿼리",
execute: "실행",
- executeShortcut: "선택 영역/쿼리 실행 (Cmd+Enter)",
+ executeShortcut: "선택 영역/쿼리 실행 ({shortcut})",
stopQuery: "쿼리 중지",
explainPlan: "실행 계획",
stopExplain: "실행 계획 중지",
@@ -5333,7 +5333,7 @@ export default withEnglishFallback({
resetAllDefaults: "모든 기본값 재설정",
save: "저장",
cancel: "취소",
- executeMode: "실행 모드 (Cmd+Enter)",
+ executeMode: "실행 모드 ({shortcut})",
executeModeAll: "모든 SQL 실행",
executeModeCurrent: "커서 위치의 구문 실행",
executeAllOnBlankLine: "빈 줄에서 모든 SQL 실행",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index 7703e7e4b0..4dc338b25f 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -145,7 +145,7 @@ export default withEnglishFallback({
newConnection: "Nova Conexão",
newQuery: "Nova Consulta",
execute: "Executar",
- executeShortcut: "Executar seleção/consulta (Cmd+Enter)",
+ executeShortcut: "Executar seleção/consulta ({shortcut})",
stopQuery: "Parar consulta",
explainPlan: "Explicar plano",
stopExplain: "Parar explicação",
@@ -5576,7 +5576,7 @@ export default withEnglishFallback({
resetAllDefaults: "Redefinir todos os padrões",
save: "Salvar",
cancel: "Cancelar",
- executeMode: "Modo de execução (Cmd+Enter)",
+ executeMode: "Modo de execução ({shortcut})",
executeModeAll: "Executar todo o SQL",
executeModeCurrent: "Executar instrução no cursor",
executeAllOnBlankLine: "Executar todo o SQL em linhas em branco",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index ac58e35d1b..80da6cc15a 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -69,7 +69,7 @@ export default withEnglishFallback({
newConnection: "新建连接",
newQuery: "新建查询",
execute: "执行",
- executeShortcut: "执行选中/全部 (Cmd+Enter)",
+ executeShortcut: "执行选中/全部 ({shortcut})",
stopQuery: "停止执行",
explainPlan: "执行计划",
stopExplain: "停止执行计划",
@@ -5841,7 +5841,7 @@ export default withEnglishFallback({
resetAllDefaults: "恢复所有默认设置",
save: "保存",
cancel: "取消",
- executeMode: "执行模式 (Cmd+Enter)",
+ executeMode: "执行模式 ({shortcut})",
executeModeAll: "执行全部 SQL",
executeModeCurrent: "执行光标所在语句",
executeAllOnBlankLine: "空白位置执行全部 SQL",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 9adc50ba58..36ab794b48 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -145,7 +145,7 @@ export default withEnglishFallback({
newConnection: "建立連線",
newQuery: "建立查詢",
execute: "執行",
- executeShortcut: "執行選取/全部 (Cmd+Enter)",
+ executeShortcut: "執行選取/全部 ({shortcut})",
stopQuery: "停止執行",
explainPlan: "執行計畫",
stopExplain: "停止執行計畫",
@@ -4910,7 +4910,7 @@ export default withEnglishFallback({
resetAllDefaults: "還原所有預設設定",
save: "儲存",
cancel: "取消",
- executeMode: "執行模式 (Cmd+Enter)",
+ executeMode: "執行模式 ({shortcut})",
executeModeAll: "執行全部 SQL",
executeModeCurrent: "執行指標所在語句",
executeAllOnBlankLine: "空白位置執行全部 SQL",