perf(sidebar): fix UI lag with 100+ databases (closes #201)

- Lower virtual scrolling threshold from 400 to 100 nodes so
  RecycleScroller activates earlier with many databases
- Memoize getConfig() with a computed Map to avoid O(n) linear
  search on every TreeItem computed property evaluation
This commit is contained in:
t8y2
2026-05-11 13:08:57 +08:00
parent 7c38af6cbb
commit 7197f83eda
3 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -23,5 +23,5 @@ export function flattenTree(nodes: TreeNode[]): FlatTreeNode[] {
}
export function shouldVirtualizeFlatTree(count: number): boolean {
return count >= 400;
return count >= 100;
}
+4 -2
View File
@@ -1,6 +1,6 @@
import { defineStore } from "pinia";
import { uuid } from "@/lib/utils";
import { ref, watch } from "vue";
import { ref, computed, watch } from "vue";
import type { ColumnInfo, ConnectionConfig, SidebarLayout, TreeNode } from "@/types/database";
import { orderPinnedFirst } from "@/lib/pinnedItems";
import {
@@ -111,8 +111,10 @@ export const useConnectionStore = defineStore("connection", () => {
newConnectionGroupId.value = null;
}
const configById = computed(() => new Map(connections.value.map((c) => [c.id, c])));
function getConfig(connectionId: string) {
return connections.value.find((c) => c.id === connectionId);
return configById.value.get(connectionId);
}
function connectionErrorMessage(error: unknown): string {