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(grid): align canvas selection visuals

t8y206a862c539d6
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue
index cfb083f1e9..d77ede5ba7 100644
--- a/apps/desktop/src/components/grid/DataGrid.vue
+++ b/apps/desktop/src/components/grid/DataGrid.vue
@@ -3610,6 +3610,10 @@ function currentSelectedCellPosition() {
function scrollCellIntoView(rowIndex: number, colIndex: number) {
nextTick(() => {
scrollGridColumnIntoView(colIndex);
+ if (useCanvasGridRows.value) {
+ scrollCanvasRowIntoView(rowIndex, "nearest");
+ return;
+ }
nextTick(() => {
const rowEl = gridRef.value?.querySelector<HTMLElement>(`[data-row-index="${rowIndex}"]`);
const cellEl = rowEl?.querySelector<HTMLElement>(`[data-visible-col-index="${colIndex}"]`);
@@ -3634,11 +3638,30 @@ function scrollGridColumnIntoView(visibleColIdx: number) {
updateGridHorizontalViewport(scroller);
if (headerRef.value) headerRef.value.scrollLeft = scroller.scrollLeft;
+ if (useCanvasGridRows.value) syncCanvasViewport();
+}
+
+function scrollCanvasRowIntoView(rowIndex: number, block: "nearest" | "start") {
+ const target = Math.max(0, Math.min(displayItems.value.length - 1, rowIndex));
+ const scroller = canvasScrollerElement();
+ if (!scroller) return;
+ const rowTop = target * CANVAS_DATA_GRID_ROW_HEIGHT;
+ const rowBottom = rowTop + CANVAS_DATA_GRID_ROW_HEIGHT;
+ if (block === "start" || rowTop < scroller.scrollTop) {
+ scroller.scrollTop = rowTop;
+ } else if (rowBottom > scroller.scrollTop + scroller.clientHeight) {
+ scroller.scrollTop = Math.max(0, rowBottom - scroller.clientHeight);
+ }
+ syncCanvasViewport();
}
function scrollGridRowIntoView(rowIndex: number) {
const target = Math.max(0, Math.min(displayItems.value.length - 1, rowIndex));
nextTick(() => {
+ if (useCanvasGridRows.value) {
+ scrollCanvasRowIntoView(target, "start");
+ return;
+ }
const scroller = scrollerRef.value;
if (scroller && !(scroller instanceof HTMLElement)) {
scroller.scrollToItem?.(target);
diff --git a/apps/desktop/src/lib/canvasDataGridRenderer.ts b/apps/desktop/src/lib/canvasDataGridRenderer.ts
index f511209cde..685453ef37 100644
--- a/apps/desktop/src/lib/canvasDataGridRenderer.ts
+++ b/apps/desktop/src/lib/canvasDataGridRenderer.ts
@@ -249,8 +249,6 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions) {
ctx.beginPath();
ctx.moveTo(rowNumberWidth + 0.5, y);
ctx.lineTo(rowNumberWidth + 0.5, y + CANVAS_DATA_GRID_ROW_HEIGHT);
- ctx.moveTo(0, y + CANVAS_DATA_GRID_ROW_HEIGHT - 0.5);
- ctx.lineTo(width, y + CANVAS_DATA_GRID_ROW_HEIGHT - 0.5);
ctx.stroke();
const rowNumberText =
@@ -317,16 +315,12 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions) {
ctx.fillRect(clippedX, y, cellPaintWidth, CANVAS_DATA_GRID_ROW_HEIGHT);
}
if (isSearchMatch) {
- ctx.globalAlpha = 1;
ctx.fillStyle = searchFill;
ctx.fillRect(clippedX, y, cellPaintWidth, CANVAS_DATA_GRID_ROW_HEIGHT);
- ctx.globalAlpha = item.isDeleted ? 0.7 : 1;
}
if (isCurrentSearchMatch) {
- ctx.globalAlpha = 1;
ctx.fillStyle = currentSearchFill;
ctx.fillRect(clippedX, y, cellPaintWidth, CANVAS_DATA_GRID_ROW_HEIGHT);
- ctx.globalAlpha = item.isDeleted ? 0.7 : 1;
}
ctx.save();
@@ -356,9 +350,30 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions) {
setCanvasNumericVariant(ctx, "normal");
ctx.font = normalFont;
- if (selectedBorderVisual) {
+ ctx.strokeStyle = theme.border;
+ ctx.beginPath();
+ ctx.moveTo(x + colWidth - 0.5, y);
+ ctx.lineTo(x + colWidth - 0.5, y + CANVAS_DATA_GRID_ROW_HEIGHT);
+ ctx.stroke();
+
+ if (selectedBorderVisual && cellPaintWidth >= 2) {
+ const selectedLeftX = clippedX + 0.5;
+ const selectedRightX = clippedX + cellPaintWidth - 1.5;
+ const selectedTopY = y + 0.5;
+ const selectedBottomY = y + CANVAS_DATA_GRID_ROW_HEIGHT - 1.5;
ctx.strokeStyle = theme.cellSelectedBorder;
- ctx.strokeRect(clippedX + 0.5, y + 0.5, Math.max(0, cellPaintWidth - 1), CANVAS_DATA_GRID_ROW_HEIGHT - 1);
+ ctx.beginPath();
+ if (!rowSelectionVisual) {
+ ctx.moveTo(selectedLeftX, selectedTopY);
+ ctx.lineTo(selectedRightX, selectedTopY);
+ ctx.moveTo(selectedLeftX, selectedBottomY);
+ ctx.lineTo(selectedRightX, selectedBottomY);
+ }
+ ctx.moveTo(selectedLeftX, selectedTopY);
+ ctx.lineTo(selectedLeftX, selectedBottomY);
+ ctx.moveTo(selectedRightX, selectedTopY);
+ ctx.lineTo(selectedRightX, selectedBottomY);
+ ctx.stroke();
}
if (isCurrentSearchMatch) {
@@ -367,15 +382,16 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions) {
ctx.strokeRect(clippedX + 1, y + 1, Math.max(0, cellPaintWidth - 2), CANVAS_DATA_GRID_ROW_HEIGHT - 2);
ctx.lineWidth = 1;
}
-
- ctx.strokeStyle = theme.border;
- ctx.beginPath();
- ctx.moveTo(x + colWidth - 0.5, y);
- ctx.lineTo(x + colWidth - 0.5, y + CANVAS_DATA_GRID_ROW_HEIGHT);
- ctx.stroke();
}
x += colWidth;
}
+ if (!isRowSelected(item.id)) {
+ ctx.strokeStyle = theme.border;
+ ctx.beginPath();
+ ctx.moveTo(0, y + CANVAS_DATA_GRID_ROW_HEIGHT - 0.5);
+ ctx.lineTo(width, y + CANVAS_DATA_GRID_ROW_HEIGHT - 0.5);
+ ctx.stroke();
+ }
ctx.globalAlpha = 1;
}
}
diff --git a/apps/desktop/src/lib/dataGridPaintTheme.ts b/apps/desktop/src/lib/dataGridPaintTheme.ts
index ea2ae4d37a..82b64346a3 100644
--- a/apps/desktop/src/lib/dataGridPaintTheme.ts
+++ b/apps/desktop/src/lib/dataGridPaintTheme.ts
@@ -59,10 +59,11 @@ export function resolveDataGridPaintTheme(options: {
const destructive = cssVarColor(getVar, "--destructive", "oklch(0.6 0.22 25)");
const accent = cssVarColor(getVar, "--accent", isDark ? "oklch(0.269 0 0)" : "oklch(0.97 0 0)");
const yellow500 = "oklch(0.795 0.184 86.047)";
+ const activeSurface = isDark ? "rgb(64 64 64)" : `color-mix(in oklab, ${primary} 10%, ${background})`;
const rowMuted = `color-mix(in oklab, ${muted} 30%, transparent)`;
const rowNew = `color-mix(in oklab, ${primary} 5%, transparent)`;
const rowDeleted = `color-mix(in oklab, ${destructive} 5%, transparent)`;
- const cellActive = `color-mix(in oklab, ${primary} 15%, transparent)`;
+ const cellActive = activeSurface;
const cellDirty = `color-mix(in oklab, ${yellow500} 10%, transparent)`;
const cellSelected = `color-mix(in oklab, ${primary} 25%, transparent)`;
const cellSelectedDirty = `color-mix(in oklab, oklch(0.8 0.15 85) 30%, color-mix(in oklab, ${primary} 18%, transparent))`;
@@ -75,7 +76,7 @@ export function resolveDataGridPaintTheme(options: {
const rowNumberNew = `color-mix(in oklab, rgb(16 185 129) 15%, ${background})`;
const rowNumberEdited = `color-mix(in oklab, rgb(245 158 11) 15%, ${background})`;
const rowNumberDeleted = `color-mix(in oklab, ${destructive} 15%, ${background})`;
- const rowNumberActive = `color-mix(in oklab, ${primary} 15%, ${background})`;
+ const rowNumberActive = activeSurface;
const rowNumberSelected = `color-mix(in oklab, ${primary} 25%, ${background})`;
return {