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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(grid): copy a column comment from the result grid
HighBigSky03204b15fe7d
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vueindex 07c88ef335..aadaf95d1b 100644--- a/apps/desktop/src/components/grid/DataGrid.vue+++ b/apps/desktop/src/components/grid/DataGrid.vue@@ -11940,6 +11940,35 @@ function copyHeaderColumnOrSelected() {void copyHeaderColumn();}+// 「复制列注释」的目标列:显式多选时按选中列,否则用右键命中的那列。+function contextCommentActualColumnIndexes(): number[] {+ if (contextHeaderColumnIndex.value === null) return [];+ const visibleIdx = contextHeaderVisibleColIdx.value;+ if (visibleIdx !== null && selectedColumnIndexes.value.has(visibleIdx) && selectedColumnIndexes.value.size > 1) {+ return [...selectedColumnIndexes.value].map(actualColumnIndex);+ }+ return [contextHeaderColumnIndex.value];+}++// 只有解析到非空注释才提供入口:无元数据或聚合/别名列的注释为空,给一个永远复制空的菜单项只会误导。+const contextCopyableColumnComments = computed(() =>+ contextCommentActualColumnIndexes()+ .map((actualIdx) => resolvedColumnComment(props.result.columns[actualIdx] ?? "", actualIdx))+ .filter((comment): comment is string => !!comment),+);++async function copyContextColumnComment() {+ const comments = contextCopyableColumnComments.value;+ if (comments.length === 0) return;+ await copyText(comments.join("\n"));+}++async function copyColumnHeaderComment(column: string, actualIdx: number) {+ const comment = resolvedColumnComment(column, actualIdx);+ if (!comment) return;+ await copyText(comment);+}+const canCopyAlterColumnSql = computed(() => {if (!contextHeaderColumn.value || !props.tableMeta?.columns) return false;if (tableStructureCapabilities.value.alterStrategy !== "direct") return false;@@ -13871,6 +13900,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {headerColumn: !!contextHeaderColumn.value,contextColumn: !!contextColumn.value,canCopyAlterSql: canCopyAlterColumnSql.value,+ canCopyComment: contextCopyableColumnComments.value.length > 0,canFilter: canUseWhereSearch.value,hasSort: !!sortCol.value,sortMode: localSortMode.value,@@ -13889,6 +13919,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {count: selectedColumnNamesForCopy.value.length,}): t("grid.copyColumnName"),+ copyComment: t("grid.copyColumnComment"),copyNames: t("grid.copyColumnNames"),details: t("grid.openColumnDetailsDialog"),copyAlterSql: t("grid.copyAlterColumnSql"),@@ -13917,6 +13948,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {},actions: {copyName: copyHeaderColumnOrSelected,+ copyComment: copyContextColumnComment,copyNames: openCopyAllColumnNamesDialog,details: openContextColumnDetailDialog,copyAlterSql: copyAlterColumnSql,@@ -14793,6 +14825,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val:drag-class="columnHeaderDragClass(col.visibleColIdx)":column-style="columnHeaderStyle(col.visibleColIdx)":copy-column-name-label="t('grid.copyColumnName')"+ :copy-column-comment-label="t('grid.copyColumnComment')":column-name-label="t('grid.columnName')":column-type-label="t('grid.columnType')":column-comment-label="t('grid.columnComment')"@@ -14815,6 +14848,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val@resize-start="startColumnHeaderResize(col.visibleColIdx, $event)"@auto-fit="autoFitColumn(col.visibleColIdx)"@copy-name="copyText(col.name)"+ @copy-comment="copyColumnHeaderComment(col.name, col.actualColIdx)"><template #actions><spandiff --git a/apps/desktop/src/components/grid/DataGridColumnHeader.vue b/apps/desktop/src/components/grid/DataGridColumnHeader.vueindex bcb209331d..c6ea1348af 100644--- a/apps/desktop/src/components/grid/DataGridColumnHeader.vue+++ b/apps/desktop/src/components/grid/DataGridColumnHeader.vue@@ -25,6 +25,8 @@ const props = defineProps<{dragClass?: HTMLAttributes["class"];columnStyle?: CSSProperties;copyColumnNameLabel: string;+ /** 与 nullableLabel 等同属「按条件渲染」的文案,未传时按钮 title 为空。 */+ copyColumnCommentLabel?: string;columnNameLabel: string;columnTypeLabel: string;columnCommentLabel: string;@@ -60,6 +62,7 @@ const emit = defineEmits<{resizeStart: [event: MouseEvent];autoFit: [];copyName: [];+ copyComment: [];}>();</script>@@ -104,7 +107,12 @@ const emit = defineEmits<{</template><template v-if="tooltipColumnComment ?? columnComment"><span class="text-background-solid/70">{{ columnCommentLabel }}</span>- <span>{{ tooltipColumnComment ?? columnComment }}</span>+ <span class="flex min-w-0 items-start gap-2">+ <span class="min-w-0 flex-1 break-words">{{ tooltipColumnComment ?? columnComment }}</span>+ <button data-column-header-copy-comment type="button" class="flex h-5 w-5 shrink-0 items-center justify-center rounded hover:bg-background/10" :title="copyColumnCommentLabel" @click.stop="emit('copyComment')">+ <Copy class="h-3 w-3" />+ </button>+ </span></template><template v-if="columnNullability"><span class="text-background-solid/70">{{ nullableLabel }}</span>diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex 26e059f865..3a44828f0b 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -2529,6 +2529,7 @@ export default withEnglishFallback({setNull: "NULL təyin et",restoreOriginalValue: "Orijinalı bərpa et",copyColumnName: "Sütunun adını kopyala",+ copyColumnComment: "Sütunun şərhini kopyala",columnDragChipMany: "{names} ({count} sütun)",copyAlterColumnSql: "SQL ALTER kimi kopyala",alterSqlCopied: "SQL ALTER mübadilə buferinə kopyalandı",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex f843e22324..87b8387448 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -3300,6 +3300,7 @@ export default {setNull: "Set NULL",restoreOriginalValue: "Restore Original",copyColumnName: "Copy Column Name",+ copyColumnComment: "Copy Column Comment",columnDragChipMany: "{names} ({count} columns)",copyAlterColumnSql: "Copy as SQL ALTER",alterSqlCopied: "SQL ALTER copied to clipboard",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 3a78bc806e..478ff92f33 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -2958,6 +2958,7 @@ export default withEnglishFallback({setNull: "Establecer NULL",restoreOriginalValue: "Restaurar original",copyColumnName: "Copiar nombre de columna",+ copyColumnComment: "Copiar comentario de columna",columnDragChipMany: "{names} ({count} columnas)",copySqlCondition: "Copiar condición SQL",copyQuerySql: "Copiar SQL",diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.tsindex 992fdeeae9..a1b2589e5a 100644--- a/apps/desktop/src/i18n/locales/id.ts+++ b/apps/desktop/src/i18n/locales/id.ts@@ -2836,6 +2836,7 @@ export default withEnglishFallback({setNull: "Atur NULL",restoreOriginalValue: "Pulihkan Asli",copyColumnName: "Salin Nama Kolom",+ copyColumnComment: "Salin Komentar Kolom",columnDragChipMany: "{names} ({count} kolom)",copyAlterColumnSql: "Salin sebagai SQL ALTER",alterSqlCopied: "SQL ALTER disalin ke clipboard",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 263e72a5fb..58f7497ee5 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -2852,6 +2852,7 @@ export default withEnglishFallback({setNull: "Imposta NULL",restoreOriginalValue: "Ripristina Originale",copyColumnName: "Copia Nome Colonna",+ copyColumnComment: "Copia Commento Colonna",columnDragChipMany: "{names} ({count} colonne)",copyAlterColumnSql: "Copia come SQL ALTER",alterSqlCopied: "SQL ALTER copiato negli appunti",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex f3b101fee0..1900bef03b 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -2856,6 +2856,7 @@ export default withEnglishFallback({setNull: "NULLに設定",restoreOriginalValue: "元の値に戻す",copyColumnName: "列名をコピー",+ copyColumnComment: "列コメントをコピー",columnDragChipMany: "{names}(全{count}列)",copyAlterColumnSql: "SQL ALTERとしてコピー",alterSqlCopied: "SQL ALTERをクリップボードにコピーしました",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex ef8fa20c4a..2002df83e3 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -2899,6 +2899,7 @@ export default withEnglishFallback({setNull: "NULL 설정",restoreOriginalValue: "원래대로 복원",copyColumnName: "컬럼 이름 복사",+ copyColumnComment: "컬럼 주석 복사",columnDragChipMany: "{names} (총 {count}개)",copyAlterColumnSql: "SQL ALTER로 복사",alterSqlCopied: "SQL ALTER를 클립보드에 복사했습니다",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex 20fd24e396..540d496b1e 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -2852,6 +2852,7 @@ export default withEnglishFallback({setNull: "Definir NULL",restoreOriginalValue: "Restaurar Original",copyColumnName: "Copiar Nome da Coluna",+ copyColumnComment: "Copiar Comentário da Coluna",columnDragChipMany: "{names} ({count} colunas)",copyAlterColumnSql: "Copiar como SQL ALTER",alterSqlCopied: "SQL ALTER copiado para a área de transferência",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex 44e3eac195..d3dc2e16fc 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -3038,6 +3038,7 @@ export default withEnglishFallback({setNull: "Установить NULL",restoreOriginalValue: "Восстановить оригинал",copyColumnName: "Копировать имя столбца",+ copyColumnComment: "Копировать комментарий столбца",columnDragChipMany: "{names} ({count} столбцов)",copyAlterColumnSql: "Копировать как SQL ALTER",alterSqlCopied: "SQL ALTER скопирован в буфер обмена",diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.tsindex ce132fff1a..08b5bf8ed3 100644--- a/apps/desktop/src/i18n/locales/th.ts+++ b/apps/desktop/src/i18n/locales/th.ts@@ -3238,6 +3238,7 @@ export default withEnglishFallback({setNull: "ตั้งเป็น NULL",restoreOriginalValue: "คืนค่าต้นฉบับ",copyColumnName: "คัดลอกชื่อคอลัมน์",+ copyColumnComment: "คัดลอกคอมเมนต์คอลัมน์",columnDragChipMany: "{names} ({count} คอลัมน์)",copyAlterColumnSql: "คัดลอกเป็น SQL ALTER",alterSqlCopied: "คัดลอก SQL ALTER ไปยัง Clipboard แล้ว",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex b76504966a..5094cdfc4d 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -2522,6 +2522,7 @@ export default withEnglishFallback({setNull: "NULL Yap",restoreOriginalValue: "Özgün Değeri Geri Yükle",copyColumnName: "Sütun Adını Kopyala",+ copyColumnComment: "Sütun Açıklamasını Kopyala",columnDragChipMany: "{names} ({count} sütun)",copyAlterColumnSql: "SQL ALTER Olarak Kopyala",alterSqlCopied: "SQL ALTER panoya kopyalandı",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex 95e6ee43e1..b559081222 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -3234,6 +3234,7 @@ export default withEnglishFallback({setNull: "设为 NULL",restoreOriginalValue: "恢复原值",copyColumnName: "复制列名",+ copyColumnComment: "复制列注释",columnDragChipMany: "{names} 等 {count} 列",copyAlterColumnSql: "复制为SQL ALTER",alterSqlCopied: "SQL ALTER 已复制到剪贴板",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex e285043300..a17333b6b3 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -2847,6 +2847,7 @@ export default withEnglishFallback({setNull: "設為 NULL",restoreOriginalValue: "復原資料",copyColumnName: "複製欄位名稱",+ copyColumnComment: "複製欄位註解",columnDragChipMany: "{names} 等 {count} 欄",copyAlterColumnSql: "複製為 SQL ALTER",alterSqlCopied: "SQL ALTER 已複製到剪貼簿",diff --git a/apps/desktop/src/lib/__tests__/dataGrid/dataGridContextMenu.spec.ts b/apps/desktop/src/lib/__tests__/dataGrid/dataGridContextMenu.spec.tsindex 0e3db1f4c1..49528e99b7 100644--- a/apps/desktop/src/lib/__tests__/dataGrid/dataGridContextMenu.spec.ts+++ b/apps/desktop/src/lib/__tests__/dataGrid/dataGridContextMenu.spec.ts@@ -60,9 +60,9 @@ describe("dataGridContextMenu", () => {hasSort: true,sortMode: "database",databaseSortEnabled: false,- labels: { copyName: "copy name", copyNames: "copy names", details: "details", copyAlterSql: "alter", databaseAscending: "db asc", databaseDescending: "db desc", localAscending: "local asc", localDescending: "local desc", clearSort: "clear sort" },+ labels: { copyName: "copy name", copyComment: "copy comment", copyNames: "copy names", details: "details", copyAlterSql: "alter", databaseAscending: "db asc", databaseDescending: "db desc", localAscending: "local asc", localDescending: "local desc", clearSort: "clear sort" },icons: { copy: icon, columnDetails: icon, database: icon, ascending: icon, descending: icon, clearSort: icon },- actions: { copyName: action, copyNames: action, details: action, copyAlterSql: action, sort: action },+ actions: { copyName: action, copyComment: action, copyNames: action, details: action, copyAlterSql: action, sort: action },filterSubmenu: filter,});expect(items.map((item) => item.label)).toEqual(["local asc", "local desc", "clear sort", "", "filter"]);@@ -111,9 +111,9 @@ describe("dataGridContextMenu", () => {canFilter: true,hasSort: true,sortMode: "database",- labels: { copyName: "copy name", copyNames: "copy names", details: "details", copyAlterSql: "alter", databaseAscending: "db asc", databaseDescending: "db desc", localAscending: "local asc", localDescending: "local desc", clearSort: "clear sort" },+ labels: { copyName: "copy name", copyComment: "copy comment", copyNames: "copy names", details: "details", copyAlterSql: "alter", databaseAscending: "db asc", databaseDescending: "db desc", localAscending: "local asc", localDescending: "local desc", clearSort: "clear sort" },icons: { copy: icon, columnDetails: icon, database: icon, ascending: icon, descending: icon, clearSort: icon },- actions: { copyName: action, copyNames: action, details: action, copyAlterSql: action, sort: action },+ actions: { copyName: action, copyComment: action, copyNames: action, details: action, copyAlterSql: action, sort: action },filterSubmenu: filter,});expect(columnItems.map((item) => item.label)).toContain("filter");@@ -150,7 +150,17 @@ describe("dataGridContextMenu", () => {expect(rowItems.find((item) => item.label === "delete")?.variant).toBe("destructive");});- function columnMenuItems(overrides: { headerColumn?: boolean; contextColumn?: boolean; contextVisibleColIdx?: number; hasColumnSelection?: boolean; selectedColumnCount?: number; visibleColumnCount?: number; hiddenColumnCount?: number; canHideIdenticalColumns?: boolean }) {+ function columnMenuItems(overrides: {+ headerColumn?: boolean;+ contextColumn?: boolean;+ contextVisibleColIdx?: number;+ hasColumnSelection?: boolean;+ selectedColumnCount?: number;+ visibleColumnCount?: number;+ hiddenColumnCount?: number;+ canHideIdenticalColumns?: boolean;+ canCopyComment?: boolean;+ }) {const action = vi.fn();const filter = createDataGridFilterSubmenu({label: "filter",@@ -164,6 +174,7 @@ describe("dataGridContextMenu", () => {headerColumn: overrides.headerColumn ?? true,contextColumn: overrides.contextColumn ?? false,canCopyAlterSql: false,+ canCopyComment: overrides.canCopyComment ?? false,canFilter: false,hasSort: false,sortMode: "database",@@ -174,6 +185,7 @@ describe("dataGridContextMenu", () => {hiddenColumnCount: 0,labels: {copyName: "copy name",+ copyComment: "copy comment",copyNames: "copy names",details: "details",copyAlterSql: "alter",@@ -191,12 +203,33 @@ describe("dataGridContextMenu", () => {showAllColumnsMenu: "show all columns",},icons: { copy: icon, columnDetails: icon, database: icon, ascending: icon, descending: icon, clearSort: icon },- actions: { copyName: action, copyNames: action, details: action, copyAlterSql: action, sort: action, freezeToColumn: action, freezeSelectedColumns: action, unfreezeColumns: action, hideColumn: action, hideSelectedColumns: action, hideIdenticalColumns: action, showAllColumnsMenu: action },+ actions: {+ copyName: action,+ copyComment: action,+ copyNames: action,+ details: action,+ copyAlterSql: action,+ sort: action,+ freezeToColumn: action,+ freezeSelectedColumns: action,+ unfreezeColumns: action,+ hideColumn: action,+ hideSelectedColumns: action,+ hideIdenticalColumns: action,+ showAllColumnsMenu: action,+ },filterSubmenu: filter,...overrides,});}+ it("offers copy-column-comment right below copy-column-name only when the column has a comment", () => {+ expect(columnMenuItems({}).map((item) => item.label)).not.toContain("copy comment");++ const labels = columnMenuItems({ canCopyComment: true }).map((item) => item.label);+ expect(labels.indexOf("copy comment")).toBe(labels.indexOf("copy name") + 1);+ });+it("offers hide-this-column on a header and hides the recovery entry until a column is hidden", () => {const labels = columnMenuItems({}).map((item) => item.label);@@ -346,6 +379,7 @@ describe("dataGridContextMenu", () => {sortMode: "database",labels: {copyName: "copy name",+ copyComment: "copy comment",copyNames: "copy names",details: "details",copyAlterSql: "alter",@@ -378,6 +412,7 @@ describe("dataGridContextMenu", () => {sortMode: "database",labels: {copyName: "copy name",+ copyComment: "copy comment",copyNames: "copy names",details: "details",copyAlterSql: "alter",diff --git a/apps/desktop/src/lib/dataGrid/dataGridContextMenu.ts b/apps/desktop/src/lib/dataGrid/dataGridContextMenu.tsindex be64126f6a..a6747d4e1d 100644--- a/apps/desktop/src/lib/dataGrid/dataGridContextMenu.ts+++ b/apps/desktop/src/lib/dataGrid/dataGridContextMenu.ts@@ -115,6 +115,8 @@ export function createDataGridColumnContextMenuItems(options: {headerColumn: boolean;contextColumn: boolean;canCopyAlterSql: boolean;+ /** 当前列(或选中列)解析到了非空注释时才提供「复制列注释」。 */+ canCopyComment?: boolean;canFilter: boolean;hasSort: boolean;sortMode: "database" | "local";@@ -130,13 +132,14 @@ export function createDataGridColumnContextMenuItems(options: {hiddenColumnCount?: number;canHideIdenticalColumns?: boolean;labels: Record<- "copyName" | "copyNames" | "details" | "copyAlterSql" | "databaseAscending" | "databaseDescending" | "localAscending" | "localDescending" | "clearSort" | "freezeToColumn" | "freezeSelectedColumns" | "unfreezeColumns" | "hideColumn" | "hideSelectedColumns" | "showAllColumnsMenu",+ "copyName" | "copyComment" | "copyNames" | "details" | "copyAlterSql" | "databaseAscending" | "databaseDescending" | "localAscending" | "localDescending" | "clearSort" | "freezeToColumn" | "freezeSelectedColumns" | "unfreezeColumns" | "hideColumn" | "hideSelectedColumns" | "showAllColumnsMenu",string> &Partial<Record<"freezeCurrentColumn" | "unfreezeCurrentColumn" | "hideIdenticalColumns", string>>;icons: Pick<DataGridContextMenuIcons, "copy" | "columnDetails" | "database" | "ascending" | "descending" | "clearSort">;actions: {copyName: () => void;+ copyComment: () => void;copyNames: () => void;details: () => void;copyAlterSql: () => void;@@ -157,6 +160,8 @@ export function createDataGridColumnContextMenuItems(options: {const items: DataGridContextMenuItem[] = [];if (options.headerColumn) {items.push({ label: options.labels.copyName, action: options.actions.copyName, icon: options.icons.copy });+ // 只有解析到注释时才给出入口:无元数据的查询结果里永远为空,展示反而误导。+ if (options.canCopyComment) items.push({ label: options.labels.copyComment, action: options.actions.copyComment, icon: options.icons.copy });items.push({ label: options.labels.copyNames, action: options.actions.copyNames, icon: options.icons.copy });items.push({ label: options.labels.details, action: options.actions.details, icon: options.icons.columnDetails });if (options.canCopyAlterSql) items.push({ label: options.labels.copyAlterSql, action: options.actions.copyAlterSql, icon: options.icons.copy });