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。

feat(grid): hint when copying a partially loaded result

弈秋c7fa862792ed
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue
index 539f3db97a..a5f2c6e833 100644
--- a/apps/desktop/src/components/grid/DataGrid.vue
+++ b/apps/desktop/src/components/grid/DataGrid.vue
@@ -8794,6 +8794,15 @@ const {
fullExportResult: props.fullExportResult,
queryResultExportRequest: props.queryResultExportRequest,
hasCompleteLocalResult,
+ partialLoadCopyInfo: computed(() =>
+ hasCompleteLocalResult.value
+ ? null
+ : {
+ loadedRows: props.result.rows.length,
+ totalRows: typeof displayedTotalRowCount.value === "number" ? displayedTotalRowCount.value : null,
+ hasMore: props.result.has_more === true || props.result.truncated === true,
+ },
+ ),
completeLocalResult: computed(() => (hasCompleteLocalResult.value ? props.result : undefined)),
allExportResults: computed(() => props.allExportResults),
currentResultLabel: computed(() => props.result.sourceLabel),
diff --git a/apps/desktop/src/composables/useDataGridExport.ts b/apps/desktop/src/composables/useDataGridExport.ts
index 8959d04c94..9c824ff2e6 100644
--- a/apps/desktop/src/composables/useDataGridExport.ts
+++ b/apps/desktop/src/composables/useDataGridExport.ts
@@ -38,6 +38,7 @@ import { translateBackendError } from "@/i18n/backend-errors";
import XlsxHeaderDialog from "@/components/export/XlsxHeaderDialog.vue";
import i18n from "@/i18n";
import { buildXlsxHeaderOverrides, hasXlsxHeaderComments, xlsxHeaderUsesCommentRows, type XlsxExportOptions, type XlsxHeaderMode } from "@/lib/export/xlsxHeader";
+import { isPartiallyLoadedCopy, partialLoadCopyHintKey, type PartialLoadCopyInfo } from "@/lib/dataGrid/copyPartialLoadHint";
/**
* Format metadata for backend table exports. Each entry maps a format key
@@ -160,6 +161,8 @@ export interface UseDataGridExportOptions {
* slow query is never re-run just to export rows that are already on screen.
*/
hasCompleteLocalResult?: ComputedRef<boolean>;
+ /** Present when the grid cannot guarantee the whole result set is loaded; drives the partial-copy hint. */
+ partialLoadCopyInfo?: ComputedRef<PartialLoadCopyInfo | null>;
/**
* The raw in-memory QueryResult to use for "export all" when
* hasCompleteLocalResult is true. Exports the original query result (all
@@ -245,6 +248,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
fullExportResult,
queryResultExportRequest,
hasCompleteLocalResult,
+ partialLoadCopyInfo,
completeLocalResult,
allExportResults,
currentResultLabel,
@@ -872,6 +876,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
},
buildMongoInsert: buildMongoExtractorInsert,
buildMongoUpdate: buildMongoExtractorUpdate,
+ partialLoadInfo: partialLoadCopyInfo,
canBuildMongoUpdate: canBuildMongoExtractorUpdate,
externalCellValue: (value, columnIndex) => {
const externalValue = options.externalCellValue?.(value as CellValue, columnIndex);
@@ -885,7 +890,11 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
const rows = (await resolveVisibleRowValues(displayItems.value.filter((item) => !item.isDraft))).map((item) => item.data);
// formatTsv 引用处理解码后文本中可能出现的制表符/换行;内部副本仍用原始 rows(hex)保证回粘无损。
const decodedRows = rows.map((row) => row.map((cell, index) => externalCellValue(binaryClipboardCellValue(cell, index), index)));
- await copyText(formatTsv(columns.value, decodedRows), { rows, header: columns.value });
+ const copied = await copyText(formatTsv(columns.value, decodedRows), { rows, header: columns.value });
+ const partialLoadInfo = options.partialLoadCopyInfo?.value;
+ if (copied && partialLoadInfo && isPartiallyLoadedCopy(partialLoadInfo)) {
+ toast(t(partialLoadCopyHintKey(partialLoadInfo), { loaded: partialLoadInfo.loadedRows, total: partialLoadInfo.totalRows ?? undefined }), 5000);
+ }
}
// --- Export functions ---
diff --git a/apps/desktop/src/composables/useDataGridExtractor.ts b/apps/desktop/src/composables/useDataGridExtractor.ts
index 511f24a6b4..cf05479d9a 100644
--- a/apps/desktop/src/composables/useDataGridExtractor.ts
+++ b/apps/desktop/src/composables/useDataGridExtractor.ts
@@ -24,6 +24,7 @@ import { binaryCellClipboardText } from "@/lib/dataGrid/binaryCellDownload";
import { formatError } from "@/lib/backend/errorUtils";
import { parseJsonPreservingLargeNumbers, stringifyJsonPreservingLargeNumbers } from "@/lib/common/safeJsonFormat";
import { tableMetaWithoutOptionalDatabaseQualifier } from "@/lib/table/tableSelectSql";
+import { isPartiallyLoadedCopy, partialLoadCopyHintKey, type PartialLoadCopyInfo } from "@/lib/dataGrid/copyPartialLoadHint";
import type { DatabaseType } from "@/types/database";
interface ExtractorRowItem {
@@ -73,6 +74,8 @@ interface UseDataGridExtractorOptions {
contextSelectionIsSynthetic: ComputedRef<boolean> | Ref<boolean>;
copyText: (text: string, gridCopy?: { rows: readonly (readonly unknown[])[]; header?: readonly unknown[] }) => Promise<boolean>;
externalCellValue?: (value: unknown, columnIndex: number) => unknown;
+ /** Present when the grid cannot guarantee the whole result set is loaded; drives the partial-copy hint. */
+ partialLoadInfo?: ComputedRef<PartialLoadCopyInfo | null>;
canCopySqlInsert: (request: DataGridExtractRequest) => boolean;
buildMongoInsert: (extractorOptions: DataGridExtractorOptions, rowLimit?: number) => Promise<string | undefined>;
buildMongoUpdate?: (request: DataGridExtractRequest, rowLimit?: number) => Promise<string | undefined>;
@@ -433,6 +436,10 @@ export function useDataGridExtractor(options: UseDataGridExtractorOptions) {
const copied = await options.copyText(result.text, gridCopy);
if (!copied) return false;
showWarnings(result.warnings, result.omittedColumns);
+ const partialLoadInfo = options.partialLoadInfo?.value;
+ if (partialLoadInfo && isPartiallyLoadedCopy(partialLoadInfo)) {
+ toast(t(partialLoadCopyHintKey(partialLoadInfo), { loaded: partialLoadInfo.loadedRows, total: partialLoadInfo.totalRows ?? undefined }), 5000);
+ }
return true;
} catch (error: unknown) {
toast(t("grid.copyFailed", { message: formatError(error) }), 5000);
diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.ts
index 8e84949918..7df79649ec 100644
--- a/apps/desktop/src/i18n/locales/az.ts
+++ b/apps/desktop/src/i18n/locales/az.ts
@@ -1775,6 +1775,8 @@ export default withEnglishFallback({
rows: "{count} sətir",
totalRows: "Cəmi {count} sətir",
loadedRows: "{count} sətir yükləndi",
+ copyPartialRowsHintWithTotal: "Yüklənmiş {loaded} sətir kopyalandı (cəmi {total} sətir; nəticə tam yüklənməyib)",
+ copyPartialRowsHint: "Yüklənmiş {loaded} sətir kopyalandı (nəticə tam yüklənməyib)",
totalRowCount: "(cəmi {count})",
totalRowCountWithAction: "({button}cəmi {count})",
totalRowCountAtLeast: "(cəmi ən azı {count})",
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 7dbd33341c..bbcdccb178 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -2174,6 +2174,8 @@ export default {
rows: "{count} rows",
totalRows: "Total {count} rows",
loadedRows: "Loaded {count} rows",
+ copyPartialRowsHintWithTotal: "Copied the {loaded} loaded rows ({total} rows in total — the result set is not fully loaded)",
+ copyPartialRowsHint: "Copied the {loaded} loaded rows (the result set is not fully loaded)",
totalRowCount: "({count} total)",
totalRowCountWithAction: "({button}{count} total)",
totalRowCountAtLeast: "(at least {count} total)",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 69308bace9..8bbca2d0b2 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -2125,6 +2125,8 @@ export default withEnglishFallback({
rows: "{count} filas",
totalRows: "Total {count} filas",
loadedRows: "{count} filas cargadas",
+ copyPartialRowsHintWithTotal: "Se copiaron las {loaded} filas cargadas ({total} filas en total; el resultado no está completamente cargado)",
+ copyPartialRowsHint: "Se copiaron las {loaded} filas cargadas (el resultado no está completamente cargado)",
totalRowCount: "({count} en total)",
totalRowCountWithAction: "({button}{count} en total)",
totalRowCountAtLeast: "(al menos {count} en total)",
diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.ts
index 9467f5ba69..bb40535a26 100644
--- a/apps/desktop/src/i18n/locales/id.ts
+++ b/apps/desktop/src/i18n/locales/id.ts
@@ -2015,6 +2015,8 @@ export default withEnglishFallback({
rows: "{count} baris",
totalRows: "Total {count} baris",
loadedRows: "{count} baris dimuat",
+ copyPartialRowsHintWithTotal: "Mengcopy {loaded} baris yang dimuat (total {total} baris; hasil belum dimuat seluruhnya)",
+ copyPartialRowsHint: "Mengcopy {loaded} baris yang dimuat (hasil belum dimuat seluruhnya)",
totalRowCount: "({count} total)",
totalRowCountWithAction: "({button}{count} total)",
totalRowCountAtLeast: "(minimal {count} total)",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 52bfbb2b62..b484f74fe9 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -2024,6 +2024,8 @@ export default withEnglishFallback({
rows: "{count} righe",
totalRows: "Totale {count} righe",
loadedRows: "{count} righe caricate",
+ copyPartialRowsHintWithTotal: "Copiate le {loaded} righe caricate ({total} righe in totale: il risultato non è completamente caricato)",
+ copyPartialRowsHint: "Copiate le {loaded} righe caricate (il risultato non è completamente caricato)",
totalRowCount: "({count} in totale)",
totalRowCountWithAction: "({button}{count} in totale)",
totalRowCountAtLeast: "(almeno {count} in totale)",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index 7b9d192f8e..8f0b02a82d 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -2045,6 +2045,8 @@ export default withEnglishFallback({
rows: "{count}行",
totalRows: "{count}件表示",
loadedRows: "{count}件読み込み済み",
+ copyPartialRowsHintWithTotal: "読み込み済みの {loaded} 行をコピーしました(結果セットは全 {total} 行、未読み込みのデータがあります)",
+ copyPartialRowsHint: "読み込み済みの {loaded} 行をコピーしました(結果セットはまだ全件読み込まれていません)",
totalRowCount: "(全{count}件)",
totalRowCountWithAction: "({button}全{count}件)",
totalRowCountAtLeast: "(少なくとも{count}件)",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 0f9b7a300d..e503c0d563 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -2021,6 +2021,8 @@ export default withEnglishFallback({
rows: "{count}행",
totalRows: "전체 {count}행",
loadedRows: "{count}행 로드됨",
+ copyPartialRowsHintWithTotal: "로드된 {loaded}행을 복사했습니다(총 {total}행 중, 아직 전체를 로드하지 않음)",
+ copyPartialRowsHint: "로드된 {loaded}행을 복사했습니다(결과 집합이 아직 전체 로드되지 않았습니다)",
totalRowCount: "(전체 {count})",
totalRowCountWithAction: "({button}전체 {count})",
totalRowCountAtLeast: "(최소 {count})",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index adb2fdf5f0..8023c114e8 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -2026,6 +2026,8 @@ export default withEnglishFallback({
rows: "{count} linhas",
totalRows: "Total de {count} linhas",
loadedRows: "{count} linhas carregadas",
+ copyPartialRowsHintWithTotal: "Copiadas as {loaded} linhas carregadas ({total} linhas no total; o resultado não está totalmente carregado)",
+ copyPartialRowsHint: "Copiadas as {loaded} linhas carregadas (o resultado não está totalmente carregado)",
totalRowCount: "({count} no total)",
totalRowCountWithAction: "({button}{count} no total)",
totalRowCountAtLeast: "(pelo menos {count} no total)",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index daa54e02ef..bf9330abfd 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -2082,6 +2082,8 @@ export default withEnglishFallback({
rows: "Строк: {count}",
totalRows: "Всего строк: {count}",
loadedRows: "Загружено строк: {count}",
+ copyPartialRowsHintWithTotal: "Скопированы загруженные строки: {loaded} (всего {total} — результат загружен не полностью)",
+ copyPartialRowsHint: "Скопированы загруженные строки: {loaded} (результат загружен не полностью)",
totalRowCount: "(всего {count})",
totalRowCountWithAction: "({button}всего {count})",
totalRowCountAtLeast: "(не менее {count} всего)",
diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts
index c0b85c389f..4efe7e7409 100644
--- a/apps/desktop/src/i18n/locales/tr.ts
+++ b/apps/desktop/src/i18n/locales/tr.ts
@@ -1774,6 +1774,8 @@ export default withEnglishFallback({
rows: "{count} satır",
totalRows: "Toplam {count} satır",
loadedRows: "{count} satır yüklendi",
+ copyPartialRowsHintWithTotal: "Yüklenen {loaded} satır kopyalandı (toplam {total} satır; sonuç kümesi tamamen yüklenmedi)",
+ copyPartialRowsHint: "Yüklenen {loaded} satır kopyalandı (sonuç kümesi tamamen yüklenmedi)",
totalRowCount: "(toplam {count})",
totalRowCountWithAction: "({button}toplam {count})",
totalRowCountAtLeast: "(en az {count} toplam)",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 2597f9d3cd..a8aa615f0f 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -2110,6 +2110,8 @@ export default withEnglishFallback({
rows: "{count} 行",
totalRows: "共 {count} 行",
loadedRows: "已加载 {count} 行",
+ copyPartialRowsHintWithTotal: "已复制已加载的 {loaded} 行(结果集共 {total} 行,尚未加载全部数据)",
+ copyPartialRowsHint: "已复制已加载的 {loaded} 行(结果集尚未加载全部数据)",
totalRowCount: "(总计 {count} 行)",
totalRowCountWithAction: "({button}总计 {count} 行)",
totalRowCountAtLeast: "(至少 {count} 行)",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index d23a99e49b..53fb8f18dc 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -1996,6 +1996,8 @@ export default withEnglishFallback({
rows: "{count} 列",
totalRows: "共 {count} 筆",
loadedRows: "已載入 {count} 筆",
+ copyPartialRowsHintWithTotal: "已複製已載入的 {loaded} 列(結果集共 {total} 列,尚未載入全部資料)",
+ copyPartialRowsHint: "已複製已載入的 {loaded} 列(結果集尚未載入全部資料)",
totalRowCount: "(總計 {count} 筆)",
totalRowCountWithAction: "({button}總計 {count} 筆)",
totalRowCountAtLeast: "(至少 {count} 筆)",
diff --git a/apps/desktop/src/lib/__tests__/dataGrid/copyPartialLoadHint.spec.ts b/apps/desktop/src/lib/__tests__/dataGrid/copyPartialLoadHint.spec.ts
new file mode 100644
index 0000000000..31c9062bac
--- /dev/null
+++ b/apps/desktop/src/lib/__tests__/dataGrid/copyPartialLoadHint.spec.ts
@@ -0,0 +1,20 @@
+import { describe, expect, it } from "vitest";
+import { isPartiallyLoadedCopy, partialLoadCopyHintKey } from "@/lib/dataGrid/copyPartialLoadHint";
+
+describe("partial-load copy hint", () => {
+ it("flags copies as partial when the backend reported more rows", () => {
+ expect(isPartiallyLoadedCopy({ loadedRows: 50, totalRows: null, hasMore: true })).toBe(true);
+ expect(isPartiallyLoadedCopy({ loadedRows: 50, totalRows: 51, hasMore: false })).toBe(true);
+ expect(isPartiallyLoadedCopy({ loadedRows: 50, totalRows: 50, hasMore: false })).toBe(false);
+ expect(isPartiallyLoadedCopy({ loadedRows: 50, totalRows: null, hasMore: false })).toBe(false);
+ });
+
+ it("never flags an empty grid", () => {
+ expect(isPartiallyLoadedCopy({ loadedRows: 0, totalRows: 51, hasMore: true })).toBe(false);
+ });
+
+ it("picks the hint variant by whether the total is known", () => {
+ expect(partialLoadCopyHintKey({ loadedRows: 50, totalRows: 51, hasMore: false })).toBe("grid.copyPartialRowsHintWithTotal");
+ expect(partialLoadCopyHintKey({ loadedRows: 50, totalRows: null, hasMore: true })).toBe("grid.copyPartialRowsHint");
+ });
+});
diff --git a/apps/desktop/src/lib/dataGrid/copyPartialLoadHint.ts b/apps/desktop/src/lib/dataGrid/copyPartialLoadHint.ts
new file mode 100644
index 0000000000..0904396b9e
--- /dev/null
+++ b/apps/desktop/src/lib/dataGrid/copyPartialLoadHint.ts
@@ -0,0 +1,18 @@
+export interface PartialLoadCopyInfo {
+ loadedRows: number;
+ /** Server-known total row count, or null when unknown. */
+ totalRows: number | null;
+ /** The backend reported more rows after the loaded ones. */
+ hasMore: boolean;
+}
+
+/** True when a copy from this grid cannot cover the whole result set. */
+export function isPartiallyLoadedCopy(info: PartialLoadCopyInfo): boolean {
+ if (info.loadedRows <= 0) return false;
+ if (info.hasMore) return true;
+ return info.totalRows !== null && info.totalRows > info.loadedRows;
+}
+
+export function partialLoadCopyHintKey(info: PartialLoadCopyInfo): string {
+ return info.totalRows !== null ? "grid.copyPartialRowsHintWithTotal" : "grid.copyPartialRowsHint";
+}