From 3ddb926c5a77ac4510e7bbdc5a26e6f86b223e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E4=B8=AB=E8=AE=B2=E6=A2=B5?= Date: Wed, 30 Sep 2026 21:16:39 +0800 Subject: [PATCH] feat(query): add configurable result tab naming --- .../editor/EditorSettingsDialog.vue | 56 +++++++++-- .../src/components/layout/ContentArea.vue | 17 +++- apps/desktop/src/i18n/locales/az.ts | 7 ++ apps/desktop/src/i18n/locales/en.ts | 7 ++ apps/desktop/src/i18n/locales/es.ts | 7 ++ apps/desktop/src/i18n/locales/it.ts | 7 ++ apps/desktop/src/i18n/locales/ja.ts | 7 ++ apps/desktop/src/i18n/locales/ko.ts | 7 ++ apps/desktop/src/i18n/locales/pt-BR.ts | 7 ++ apps/desktop/src/i18n/locales/ru.ts | 7 ++ apps/desktop/src/i18n/locales/tr.ts | 7 ++ apps/desktop/src/i18n/locales/zh-CN.ts | 7 ++ apps/desktop/src/i18n/locales/zh-TW.ts | 7 ++ .../__tests__/tabs/tabPresentation.spec.ts | 96 ++++++++++++++++++- .../src/lib/app/openTabsPersistence.ts | 4 +- .../__tests__/settingsTransfer.spec.ts | 9 ++ .../src/lib/settings/editorSettingsDraft.ts | 2 + .../src/lib/settings/settingsSearch.ts | 2 + .../src/lib/settings/settingsTransfer.ts | 4 + apps/desktop/src/lib/tabs/tabPresentation.ts | 46 +++++---- apps/desktop/src/lib/tabs/tabResultCache.ts | 4 + .../queryStore.multiStatementError.spec.ts | 4 + .../stores/__tests__/settingsStore.spec.ts | 7 ++ apps/desktop/src/stores/queryStore.ts | 21 +++- apps/desktop/src/stores/settingsStore.ts | 16 ++++ apps/desktop/src/types/database.ts | 6 ++ 26 files changed, 332 insertions(+), 39 deletions(-) diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vue index 3fe44d99d3..2d0f8ff117 100644 --- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue +++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue @@ -92,6 +92,7 @@ import { type DataGridFilterEditorView, type DataGridToolbarLayout, type MultiStatementDefaultView, + type ResultTabNamingMode, type OpenTabsRestoreMode, type AppCloseUnsavedTabsMode, type SidebarObjectInfoMode, @@ -732,6 +733,8 @@ const editShowColumnCommentsInHeader = ref(settingsStore.editorSettings.showColu const editShowColumnTypesInHeader = ref(settingsStore.editorSettings.showColumnTypesInHeader); const editShowColumnHeaderTooltips = ref(settingsStore.editorSettings.showColumnHeaderTooltips); const editShowResultSourceDatabase = ref(settingsStore.editorSettings.showResultSourceDatabase); +const editResultTabNamingMode = ref(settingsStore.editorSettings.resultTabNamingMode); +const editResultTabPreferComments = ref(settingsStore.editorSettings.resultTabPreferComments); const editDataGridShowTransposeFieldMetadata = ref(settingsStore.editorSettings.dataGridShowTransposeFieldMetadata); const editColorizeDataGridCellTypes = ref(settingsStore.editorSettings.colorizeDataGridCellTypes); const editShowIndexIndicatorsInHeader = ref(settingsStore.editorSettings.showIndexIndicatorsInHeader); @@ -1082,6 +1085,8 @@ function currentEditorSettingsDraft(): EditorSettingsDraft { showColumnTypesInHeader: editShowColumnTypesInHeader.value, showColumnHeaderTooltips: editShowColumnHeaderTooltips.value, showResultSourceDatabase: editShowResultSourceDatabase.value, + resultTabNamingMode: editResultTabNamingMode.value, + resultTabPreferComments: editResultTabPreferComments.value, dataGridShowTransposeFieldMetadata: editDataGridShowTransposeFieldMetadata.value, colorizeDataGridCellTypes: editColorizeDataGridCellTypes.value, dataGridTypeColorSchemes: editDataGridTypeColorSchemes.value, @@ -1748,6 +1753,8 @@ function syncEditorSettingsDraftFromStore() { editShowColumnTypesInHeader.value = settingsStore.editorSettings.showColumnTypesInHeader; editShowColumnHeaderTooltips.value = settingsStore.editorSettings.showColumnHeaderTooltips; editShowResultSourceDatabase.value = settingsStore.editorSettings.showResultSourceDatabase; + editResultTabNamingMode.value = settingsStore.editorSettings.resultTabNamingMode; + editResultTabPreferComments.value = settingsStore.editorSettings.resultTabPreferComments; editDataGridShowTransposeFieldMetadata.value = settingsStore.editorSettings.dataGridShowTransposeFieldMetadata; editColorizeDataGridCellTypes.value = settingsStore.editorSettings.colorizeDataGridCellTypes; editDataGridTypeColorSchemes.value = cloneDataGridTypeColorSchemes(settingsStore.editorSettings.dataGridTypeColorSchemes); @@ -1889,6 +1896,8 @@ const editorSettingsDraftRefs: EditorSettingsDraftRefMap = { showColumnTypesInHeader: editShowColumnTypesInHeader, showColumnHeaderTooltips: editShowColumnHeaderTooltips, showResultSourceDatabase: editShowResultSourceDatabase, + resultTabNamingMode: editResultTabNamingMode, + resultTabPreferComments: editResultTabPreferComments, dataGridShowTransposeFieldMetadata: editDataGridShowTransposeFieldMetadata, colorizeDataGridCellTypes: editColorizeDataGridCellTypes, dataGridTypeColorSchemes: editDataGridTypeColorSchemes, @@ -2442,6 +2451,8 @@ function resetDefaultsForTab(tab: SettingsCategory) { editShowColumnTypesInHeader.value = DEFAULT_EDITOR_SETTINGS.showColumnTypesInHeader; editShowColumnHeaderTooltips.value = DEFAULT_EDITOR_SETTINGS.showColumnHeaderTooltips; editShowResultSourceDatabase.value = DEFAULT_EDITOR_SETTINGS.showResultSourceDatabase; + editResultTabNamingMode.value = DEFAULT_EDITOR_SETTINGS.resultTabNamingMode; + editResultTabPreferComments.value = DEFAULT_EDITOR_SETTINGS.resultTabPreferComments; editDataGridShowTransposeFieldMetadata.value = DEFAULT_EDITOR_SETTINGS.dataGridShowTransposeFieldMetadata; editColorizeDataGridCellTypes.value = DEFAULT_EDITOR_SETTINGS.colorizeDataGridCellTypes; // Back to the built-in palette, but keep the user's saved schemes available. @@ -8467,16 +8478,43 @@ onUnmounted(() => { -
-
- -

- {{ t("settings.showResultSourceDatabaseDescription") }} -

+
+
+
+ +

+ {{ t("settings.resultTabNamingModeDescription") }} +

+
+ +
+
+
+ +

{{ t("settings.resultTabPreferCommentsDescription") }}

+
+ +
+
+
+ +

+ {{ t("settings.showResultSourceDatabaseDescription") }} +

+
+
-
diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vue index 3c7e7f3657..46b6e0362b 100644 --- a/apps/desktop/src/components/layout/ContentArea.vue +++ b/apps/desktop/src/components/layout/ContentArea.vue @@ -501,8 +501,12 @@ const activeQueryError = computed(() => { const hasQueryOutput = computed(() => tabHasQueryOutput(props.activeTab)); // 结果集页签/列表的名称是否带库名,由编辑器设置控制(默认带库名) const includeResultSourceDatabase = computed(() => settingsStore.editorSettings.showResultSourceDatabase); -const visibleResultItems = computed(() => tabularResultItems(props.activeTab.results ?? (props.activeTab.result ? [props.activeTab.result] : undefined), { includeSourceDatabase: includeResultSourceDatabase.value })); -const tabularResults = computed(() => tabularResultItems(props.activeTab.results, { includeSourceDatabase: includeResultSourceDatabase.value })); +const resultTabNamingMode = computed(() => settingsStore.editorSettings.resultTabNamingMode); +const preferResultTabComments = computed(() => settingsStore.editorSettings.resultTabPreferComments); +const visibleResultItems = computed(() => + tabularResultItems(props.activeTab.results ?? (props.activeTab.result ? [props.activeTab.result] : undefined), { includeSourceDatabase: includeResultSourceDatabase.value, namingMode: resultTabNamingMode.value, preferComments: preferResultTabComments.value }), +); +const tabularResults = computed(() => tabularResultItems(props.activeTab.results, { includeSourceDatabase: includeResultSourceDatabase.value, namingMode: resultTabNamingMode.value, preferComments: preferResultTabComments.value })); const allResultExportSheets = computed(() => tabularResults.value.map((item) => ({ sheetName: item.label || t("tabs.resultN", { n: item.n }), @@ -514,10 +518,13 @@ const allResultExportSheets = computed(() => const resultRuns = computed(() => resultRunItems(props.activeTab, { includeSourceDatabase: includeResultSourceDatabase.value, + namingMode: resultTabNamingMode.value, + preferComments: preferResultTabComments.value, database: props.activeTab.database, databaseType: activeEffectiveDatabaseType.value, }), ); +const resultRunFallbackLabel = (sequence: number) => t(resultTabNamingMode.value === "ordinal" ? "tabs.resultN" : "tabs.runN", { n: sequence }); const activeResultGridCacheKey = computed(() => resultGridCacheKey(props.activeTab)); const activeResultGridColumnWidthCacheKey = computed(() => resultGridColumnWidthCacheKey(props.activeTab)); const activeResultGridInstanceKey = computed(() => resultGridInstanceKey(props.activeTab)); @@ -1824,7 +1831,7 @@ defineExpose({ @keydown="onResultRunTabKeydown($event, runIndex)" > - {{ run.title || run.sourceLabel || t("tabs.runN", { n: run.sequence }) }} + {{ run.title || run.sourceLabel || resultRunFallbackLabel(run.sequence) }} @@ -1854,7 +1861,7 @@ defineExpose({ - {{ run.title || run.sourceLabel || t("tabs.runN", { n: run.sequence }) }} + {{ run.title || run.sourceLabel || resultRunFallbackLabel(run.sequence) }}