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
fix(grid): guard DataGrid startup initialization
t8y2f267f4ccfbd9
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vueindex 4bb52f469f..5733f1c5ca 100644--- a/apps/desktop/src/components/grid/DataGrid.vue+++ b/apps/desktop/src/components/grid/DataGrid.vue@@ -364,14 +364,14 @@ const DataGridInsertRowsDialog = defineAsyncComponent(() => import("@/componentsconst ExportProgressDialog = defineAsyncComponent(() => import("@/components/export/ExportProgressDialog.vue"));const FORMATTED_JSON_EDIT_WARNING_COUNT_STORAGE_KEY = "dbx-cell-detail-formatted-json-edit-warning-count";const FORMATTED_JSON_EDIT_WARNING_MAX_COUNT = 3;-let largeValueRuntime: ReturnType<typeof useDataGridLargeValues>;+let largeValueRuntime: ReturnType<typeof useDataGridLargeValues> | undefined;function scheduleVisibleLargeValuePreviewHydration(delay = 150) {- largeValueRuntime.scheduleVisibleLargeValuePreviewHydration(delay);+ largeValueRuntime?.scheduleVisibleLargeValuePreviewHydration(delay);}async function hydrateLargeValueCell(rowId: number, columnIndex: number): Promise<boolean> {- return largeValueRuntime.hydrateLargeValueCell(rowId, columnIndex);+ return largeValueRuntime?.hydrateLargeValueCell(rowId, columnIndex) ?? false;}const { t } = useI18n();@@ -3503,7 +3503,7 @@ const editor = useDataGridEditor({cacheKey: computed(() => props.pendingStateKey ?? props.cacheKey),onResultPayloadMutated: () => queryStore.invalidateResultEstimateForPayload(props.result),refreshSavedRows,- onCellValueChanged: (rowId, columnIndex) => largeValueRuntime.invalidateVisibleLargeValuePreviewCell(rowId, columnIndex),+ onCellValueChanged: (rowId, columnIndex) => largeValueRuntime?.invalidateVisibleLargeValuePreviewCell(rowId, columnIndex),prepareFullReload,emit,});diff --git a/apps/desktop/src/components/grid/__tests__/DataGridInitializationOrder.spec.ts b/apps/desktop/src/components/grid/__tests__/DataGridInitializationOrder.spec.tsindex 0a0d701154..3cde354a5b 100644--- a/apps/desktop/src/components/grid/__tests__/DataGridInitializationOrder.spec.ts+++ b/apps/desktop/src/components/grid/__tests__/DataGridInitializationOrder.spec.ts@@ -21,4 +21,10 @@ describe("DataGrid setup initialization order", () => {expect(filterPreviewDeclaration).toBeGreaterThan(canUseWhereSearchDeclaration);expect(filterPreviewWatcher).toBeGreaterThan(filterPreviewDeclaration);});++ it("does not expose an uninitialized large-value runtime to startup callbacks", () => {+ expect(dataGridSource).toContain("let largeValueRuntime: ReturnType<typeof useDataGridLargeValues> | undefined;");+ expect(dataGridSource).toContain("largeValueRuntime?.scheduleVisibleLargeValuePreviewHydration(delay)");+ expect(dataGridSource).toContain("largeValueRuntime?.hydrateLargeValueCell(rowId, columnIndex) ?? false");+ });});diff --git a/apps/desktop/src/composables/useDataGridColumnResize.ts b/apps/desktop/src/composables/useDataGridColumnResize.tsindex 9a153a6be2..295acbc98a 100644--- a/apps/desktop/src/composables/useDataGridColumnResize.ts+++ b/apps/desktop/src/composables/useDataGridColumnResize.ts@@ -86,7 +86,7 @@ export function useDataGridColumnResize(options: UseDataGridColumnResizeOptions)});}- const neededColumnWidths = computed(() => columns.value.map((_, colIdx) => neededColumnWidth(colIdx)));+ const neededColumnWidths = computed(() => (columns.value ?? []).map((_, colIdx) => neededColumnWidth(colIdx)));const neededColumnWidthSignature = computed(() => neededColumnWidths.value.join("|"));/** Grow-only: late pages with larger keys must not stay stuck at a short-header / early-page width. */@@ -123,9 +123,10 @@ export function useDataGridColumnResize(options: UseDataGridColumnResizeOptions)const nextColumnIndexes = [...columnIndexes.value];const cachedState = !force && previousColumnIndexes.length === 0 ? loadDataGridColumnWidthState(columnWidthStateIdentity(), nextColumnIndexes) : undefined;if (cachedState) userSizedColumnIndexes = new Set(cachedState.userSizedColumnIndexes);- const currentNeededWidths = neededColumnWidths.value;- if (force || columnWidths.value.length !== columns.value.length || previousColumnIndexes.join("\0") !== nextColumnIndexes.join("\0")) {- columnWidths.value = columns.value.map((_, colIdx) => {+ const currentNeededWidths = neededColumnWidths.value ?? [];+ const columnCount = columns.value?.length ?? 0;+ if (force || columnWidths.value.length !== columnCount || previousColumnIndexes.join("\0") !== nextColumnIndexes.join("\0")) {+ columnWidths.value = (columns.value ?? []).map((_, colIdx) => {if (!force) {const existingWidth = previousWidthsByColumnIndex.get(nextColumnIndexes[colIdx]);if (existingWidth !== undefined) return existingWidth;