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(objects): add virtual object browser
t8y20e0195f7346c
diff --git a/src/App.vue b/src/App.vueindex ee1519950e..48e1e74ef7 100644--- a/src/App.vue+++ b/src/App.vue@@ -599,6 +599,17 @@ onUnmounted(() => {@sort="onSort"@execute-sql="onExecuteSql"@click-table="onClickTable"+ @open-object-table="+ (target) =>+ activeTab &&+ openTableTarget({+ connectionId: activeTab.connectionId,+ database: activeTab.database,+ schema: target.schema,+ tableName: target.tableName,+ })+ "+ @object-schema-change="(schema) => activeTab && queryStore.updateSchema(activeTab.id, schema)"/></div><WelcomeScreendiff --git a/src/components/layout/AppTabBar.vue b/src/components/layout/AppTabBar.vueindex 23d2945eba..9fe02ce97d 100644--- a/src/components/layout/AppTabBar.vue+++ b/src/components/layout/AppTabBar.vue@@ -1,7 +1,7 @@<script setup lang="ts">import { ref, watch, nextTick } from "vue";import { useI18n } from "vue-i18n";-import { X, Pin, ChevronRight, Table2, Code2 } from "lucide-vue-next";+import { X, Pin, ChevronRight, Table2, Code2, TableProperties } from "lucide-vue-next";import {ContextMenu,ContextMenuContent,@@ -73,6 +73,11 @@ function tabColorStyle(tab: QueryTab) {borderColor: isActive ? hexToRgba(color, 0.72) : hexToRgba(color, 0.18),};}++function tabIconClass(tab: QueryTab) {+ if (tab.mode === "data" || tab.mode === "objects") return "text-emerald-600 dark:text-emerald-400";+ return "text-blue-600 dark:text-blue-400";+}</script><template>@@ -126,13 +131,9 @@ function tabColorStyle(tab: QueryTab) {@click="queryStore.activeTabId = tab.id"@mousedown.middle.prevent="queryStore.closeTab(tab.id)">- <span- class="shrink-0"- :class="- tab.mode === 'data' ? 'text-emerald-600 dark:text-emerald-400' : 'text-blue-600 dark:text-blue-400'- "- >+ <span class="shrink-0" :class="tabIconClass(tab)"><Table2 v-if="tab.mode === 'data'" class="h-3.5 w-3.5" />+ <TableProperties v-else-if="tab.mode === 'objects'" class="h-3.5 w-3.5" /><Code2 v-else class="h-3.5 w-3.5" /></span><span class="min-w-0 truncate flex-1">{{ tabDisplayTitle(tab) }}</span>diff --git a/src/components/layout/ContentArea.vue b/src/components/layout/ContentArea.vueindex 321d30f3b7..282fc0c36a 100644--- a/src/components/layout/ContentArea.vue+++ b/src/components/layout/ContentArea.vue@@ -9,6 +9,7 @@ import QueryEditor from "@/components/editor/QueryEditor.vue";import DataGrid from "@/components/grid/DataGrid.vue";import RedisKeyBrowser from "@/components/redis/RedisKeyBrowser.vue";import MongoDocBrowser from "@/components/mongo/MongoDocBrowser.vue";+import ObjectBrowser from "@/components/objects/ObjectBrowser.vue";import ColumnInfoPanel from "@/components/editor/ColumnInfoPanel.vue";import type { ColumnInfo } from "@/components/editor/ColumnInfoPanel.vue";const ExplainPlanViewer = defineAsyncComponent(() => import("@/components/explain/ExplainPlanViewer.vue"));@@ -44,6 +45,8 @@ const emit = defineEmits<{sort: [column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string];executeSql: [sql: string];clickTable: [tableName: string];+ openObjectTable: [target: { tableName: string; schema?: string }];+ objectSchemaChange: [schema: string | undefined];}>();const { t } = useI18n();@@ -430,5 +433,17 @@ function onHandleCloseColumnPanel() {/></div></template>++ <!-- Objects mode: virtualized database object browser -->+ <template v-else-if="activeTab.mode === 'objects' && activeConnection">+ <ObjectBrowser+ :key="`${activeTab.id}-${activeTab.objectBrowser?.schema || ''}`"+ :connection="activeConnection"+ :database="activeTab.database"+ :schema="activeTab.objectBrowser?.schema"+ @open-table="emit('openObjectTable', $event)"+ @schema-change="emit('objectSchemaChange', $event)"+ />+ </template></div></template>diff --git a/src/components/objects/ObjectBrowser.vue b/src/components/objects/ObjectBrowser.vuenew file mode 100644index 0000000000..df1c5076e2--- /dev/null+++ b/src/components/objects/ObjectBrowser.vue@@ -0,0 +1,251 @@+<script setup lang="ts">+import { computed, ref, watch } from "vue";+import { RecycleScroller } from "vue-virtual-scroller";+import { Loader2, RefreshCw, Search, Table2, Eye } from "lucide-vue-next";+import { useI18n } from "vue-i18n";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";+import * as api from "@/lib/api";+import type { ConnectionConfig, TableInfo } from "@/types/database";+import { isSchemaAware } from "@/lib/databaseCapabilities";++type ObjectRow = {+ id: string;+ name: string;+ schema?: string;+ type: "TABLE" | "VIEW";+ comment?: string | null;+};++type ObjectFilter = "all" | "tables" | "views";++const props = defineProps<{+ connection: ConnectionConfig;+ database: string;+ schema?: string;+}>();++const emit = defineEmits<{+ openTable: [target: { tableName: string; schema?: string }];+ schemaChange: [schema: string | undefined];+}>();++const { t } = useI18n();++const schemas = ref<string[]>([]);+const selectedSchema = ref<string | undefined>(props.schema);+const rows = ref<ObjectRow[]>([]);+const search = ref("");+const objectFilter = ref<ObjectFilter>("all");+const loadingSchemas = ref(false);+const loadingObjects = ref(false);+const error = ref("");+let loadId = 0;++const needsSchema = computed(() => isSchemaAware(props.connection.db_type));+const tableCount = computed(() => rows.value.filter((row) => row.type === "TABLE").length);+const viewCount = computed(() => rows.value.filter((row) => row.type === "VIEW").length);+const showObjectFilter = computed(() => tableCount.value > 0 && viewCount.value > 0);+const hasComments = computed(() => rows.value.some((row) => row.comment?.trim()));+const gridTemplateColumns = computed(() =>+ hasComments.value ? "minmax(0,1fr) 120px 160px minmax(160px,0.7fr)" : "minmax(0,1fr) 120px 160px",+);+const searchedRows = computed(() => {+ const q = search.value.trim().toLowerCase();+ if (!q) return rows.value;+ return rows.value.filter((row) =>+ [row.name, row.schema, row.type, row.comment]+ .filter(Boolean)+ .some((value) => String(value).toLowerCase().includes(q)),+ );+});+const filteredRows = computed(() => {+ if (objectFilter.value === "tables") return searchedRows.value.filter((row) => row.type === "TABLE");+ if (objectFilter.value === "views") return searchedRows.value.filter((row) => row.type === "VIEW");+ return searchedRows.value;+});++function normalizeType(type: string): ObjectRow["type"] {+ const value = type.toUpperCase();+ if (value.includes("VIEW")) return "VIEW";+ return "TABLE";+}++function iconFor(row: ObjectRow) {+ return row.type === "VIEW" ? Eye : Table2;+}++function typeLabel(type: ObjectRow["type"]) {+ return type === "VIEW" ? t("objects.view") : t("objects.table");+}++async function loadSchemas() {+ if (!needsSchema.value) {+ schemas.value = [];+ selectedSchema.value = undefined;+ return;+ }+ loadingSchemas.value = true;+ try {+ const names = await api.listSchemas(props.connection.id, props.database);+ schemas.value = names;+ if (!selectedSchema.value || !names.includes(selectedSchema.value)) {+ selectedSchema.value = names.includes("public") ? "public" : names[0];+ }+ } finally {+ loadingSchemas.value = false;+ }+}++async function loadObjects() {+ const id = ++loadId;+ loadingObjects.value = true;+ error.value = "";+ rows.value = [];+ try {+ const schema = needsSchema.value ? selectedSchema.value || "" : props.database;+ const tables: TableInfo[] = await api.listTables(props.connection.id, props.database, schema);+ if (id !== loadId) return;+ rows.value = tables.map((table) => ({+ id: `${schema || props.database}:${table.name}:${table.table_type}`,+ name: table.name,+ schema: needsSchema.value ? schema : undefined,+ type: normalizeType(table.table_type),+ comment: table.comment,+ }));+ } catch (e: any) {+ if (id !== loadId) return;+ error.value = e?.message || String(e);+ } finally {+ if (id === loadId) loadingObjects.value = false;+ }+}++async function reload() {+ await loadSchemas();+ await loadObjects();+}++function onSchemaChange(value: any) {+ selectedSchema.value = typeof value === "string" && value ? value : undefined;+ emit("schemaChange", selectedSchema.value);+ void loadObjects();+}++function filterCount(filter: ObjectFilter) {+ if (filter === "tables") return tableCount.value;+ if (filter === "views") return viewCount.value;+ return rows.value.length;+}++function filterLabel(filter: ObjectFilter) {+ const key = filter === "tables" ? "objects.tables" : filter === "views" ? "objects.views" : "objects.all";+ return `${t(key)} ${filterCount(filter)}`;+}++watch(+ () => [props.connection.id, props.database, props.schema] as const,+ () => {+ selectedSchema.value = props.schema;+ void reload();+ },+ { immediate: true },+);+</script>++<template>+ <div class="flex h-full min-h-0 flex-col bg-background">+ <div class="flex h-10 shrink-0 items-center gap-2 border-b px-3">+ <div class="flex min-w-0 flex-1 items-center gap-2">+ <Table2 class="h-4 w-4 text-muted-foreground" />+ <div class="min-w-0 truncate text-sm font-medium">+ {{ props.database }}<template v-if="selectedSchema"> / {{ selectedSchema }}</template>+ </div>+ <div class="shrink-0 rounded border bg-muted/40 px-1.5 py-0.5 text-xs text-muted-foreground">+ {{ filteredRows.length }} / {{ rows.length }}+ </div>+ </div>+ <div class="flex min-w-[240px] flex-1 items-center gap-2">+ <Search class="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <Input v-model="search" class="h-7 text-xs" :placeholder="t('objects.search')" />+ <div v-if="showObjectFilter" class="flex h-7 shrink-0 items-center rounded border bg-muted/20 p-0.5">+ <button+ v-for="filter in ['all', 'tables', 'views'] as ObjectFilter[]"+ :key="filter"+ type="button"+ class="h-6 rounded-sm px-2 text-xs text-muted-foreground transition-colors hover:text-foreground"+ :class="{ 'bg-background text-foreground shadow-sm': objectFilter === filter }"+ @click="objectFilter = filter"+ >+ {{ filterLabel(filter) }}+ </button>+ </div>+ </div>+ <Select+ v-if="needsSchema"+ :model-value="selectedSchema"+ :disabled="loadingSchemas"+ @update:model-value="onSchemaChange"+ >+ <SelectTrigger class="h-7 w-36 text-xs">+ <SelectValue :placeholder="loadingSchemas ? t('objects.loadingSchemas') : t('objects.schema')" />+ </SelectTrigger>+ <SelectContent>+ <SelectItem v-for="schema in schemas" :key="schema" :value="schema">{{ schema }}</SelectItem>+ </SelectContent>+ </Select>+ <Button variant="ghost" size="icon" class="h-7 w-7" :disabled="loadingObjects" @click="reload">+ <RefreshCw class="h-3.5 w-3.5" :class="{ 'animate-spin': loadingObjects }" />+ </Button>+ </div>++ <div v-if="loadingObjects" class="flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground">+ <Loader2 class="h-4 w-4 animate-spin" />+ {{ t("objects.loading") }}+ </div>+ <div v-else-if="error" class="flex flex-1 items-center justify-center px-6 text-center text-sm text-destructive">+ {{ error }}+ </div>+ <div+ v-else-if="filteredRows.length === 0"+ class="flex flex-1 items-center justify-center text-sm text-muted-foreground"+ >+ {{ t("objects.empty") }}+ </div>+ <div v-else class="flex min-h-0 flex-1 flex-col">+ <div+ class="grid h-8 shrink-0 items-center gap-3 border-b bg-muted/40 px-3 text-xs font-medium text-muted-foreground"+ :style="{ gridTemplateColumns }"+ >+ <div class="truncate">{{ t("objects.name") }}</div>+ <div class="truncate">{{ t("objects.type") }}</div>+ <div class="truncate">{{ t("objects.schemaColumn") }}</div>+ <div v-if="hasComments" class="truncate">{{ t("objects.comment") }}</div>+ </div>+ <RecycleScroller class="flex-1 min-h-0" :items="filteredRows" :item-size="36" key-field="id">+ <template #default="{ item }">+ <div+ class="grid h-9 cursor-pointer items-center gap-3 border-b px-3 text-xs hover:bg-accent/50"+ :style="{ gridTemplateColumns }"+ @click="emit('openTable', { tableName: item.name, schema: item.schema })"+ >+ <div class="flex min-w-0 items-center gap-2">+ <component+ :is="iconFor(item)"+ class="h-3.5 w-3.5 shrink-0"+ :class="item.type === 'VIEW' ? 'text-purple-500' : 'text-green-500'"+ />+ <span class="truncate font-medium">{{ item.name }}</span>+ </div>+ <div class="truncate text-muted-foreground">{{ typeLabel(item.type) }}</div>+ <div class="truncate text-muted-foreground">{{ item.schema || props.database }}</div>+ <div v-if="hasComments" class="truncate text-muted-foreground" :title="item.comment || ''">+ {{ item.comment || "" }}+ </div>+ </div>+ </template>+ </RecycleScroller>+ </div>+ </div>+</template>diff --git a/src/components/sidebar/TreeItem.vue b/src/components/sidebar/TreeItem.vueindex 345b3c948f..41b8b8938f 100644--- a/src/components/sidebar/TreeItem.vue+++ b/src/components/sidebar/TreeItem.vue@@ -155,6 +155,8 @@ function getIconInfo(node: TreeNode): { icon: any; colorClass: string } | null {return { icon: Link, colorClass: "text-blue-400" };case "group-triggers":return { icon: Zap, colorClass: "text-orange-400" };+ case "object-browser":+ return { icon: TableProperties, colorClass: "text-primary" };case "saved-sql-root":return { icon: FolderOpen, colorClass: "text-blue-500" };case "saved-sql-folder":@@ -183,6 +185,7 @@ const leafTypes: Set<TreeNodeType> = new Set(["index","fkey","trigger",+ "object-browser","redis-db","mongo-collection","saved-sql-file",@@ -210,10 +213,16 @@ function isGroupLabel(node: TreeNode): boolean {return groupTypes.has(node.type);}+function displayLabel(node: TreeNode): string {+ if (node.type === "object-browser") return t(node.label, { count: node.objectCount ?? 0 });+ return isGroupLabel(node) ? t(node.label) : node.label;+}+async function toggle() {const node = props.node;if (node.isLoading) return;emit("search-toggle", node);+ const wasExpanded = !!node.isExpanded;if (node.type === "connection-group") {node.isExpanded = !node.isExpanded;@@ -277,12 +286,23 @@ async function toggle() {await connectionStore.loadTriggers(node.connectionId, node.database, node.tableName, node.schema);}} catch (e: any) {+ if (!wasExpanded) node.isExpanded = false;toast(t("connection.connectFailed", { message: e?.message || String(e) }), 5000);}}function onClick() {const node = props.node;+ if (canOpenObjectBrowser.value) {+ const shouldOpenObjectBrowser = !canExpand || !node.isExpanded;+ if (canExpand) void toggle();+ if (shouldOpenObjectBrowser) void openObjectBrowser();+ return;+ }+ if (node.type === "object-browser") {+ void openObjectBrowser();+ return;+ }const action = treeNodeRowAction(node.type, canExpand);if (action === "open-data") {openData();@@ -293,6 +313,32 @@ function onClick() {}}+async function openObjectBrowser() {+ const node = props.node;+ if (!node.connectionId) return;+ try {+ await connectionStore.ensureConnected(node.connectionId);+ connectionStore.activeConnectionId = node.connectionId;++ if (node.database) {+ queryStore.openObjectBrowser(node.connectionId, node.database, node.schema);+ return;+ }++ const connection = connectionStore.getConfig(node.connectionId);+ if (!connection) return;+ const options = await getDatabaseOptions(node.connectionId);+ const database = resolveDefaultDatabase(connection, options);+ if (database) {+ queryStore.openObjectBrowser(node.connectionId, database);+ } else {+ await toggle();+ }+ } catch (e: any) {+ toast(t("connection.connectFailed", { message: e?.message || String(e) }), 5000);+ }+}+function openSavedSqlFile() {const id = props.node.savedSqlId;if (!id) return;@@ -1024,6 +1070,16 @@ const canOpenDatabaseSearch = computed(() => {const config = props.node.connectionId ? connectionStore.getConfig(props.node.connectionId) : undefined;return !!props.node.database && !!config && DATABASE_SEARCH_SUPPORTED_TYPES.has(config.db_type);});+const canOpenObjectBrowser = computed(() => {+ const config = props.node.connectionId ? connectionStore.getConfig(props.node.connectionId) : undefined;+ return (+ (props.node.type === "database" || props.node.type === "schema" || props.node.type === "object-browser") &&+ !!config &&+ config.db_type !== "redis" &&+ config.db_type !== "mongodb" &&+ config.db_type !== "elasticsearch"+ );+});const canOpenTableImport = computed(() => {const config = props.node.connectionId ? connectionStore.getConfig(props.node.connectionId) : undefined;return (@@ -1363,7 +1419,7 @@ const isDragging = computed(() => dragState.active && dragState.draggedId === pr@click.stop@vue:mounted="($event: any) => $event.el.focus()"/>- <span v-else class="min-w-0 flex-1 truncate">{{ isGroupLabel(node) ? t(node.label) : node.label }}</span>+ <span v-else class="min-w-0 flex-1 truncate">{{ displayLabel(node) }}</span><Badge v-if="isNodeDefaultDatabase" variant="secondary" class="h-4 px-1.5 text-[10px]">{{ t("editor.defaultDatabase") }}</Badge>@@ -1493,6 +1549,9 @@ const isDragging = computed(() => dragState.active && dragState.draggedId === pr</template><template v-if="node.type === 'database' || node.type === 'schema'">+ <ContextMenuItem v-if="canOpenObjectBrowser" @click="openObjectBrowser">+ <TableProperties class="w-4 h-4" /> {{ t("contextMenu.openObjectBrowser") }}+ </ContextMenuItem><ContextMenuItem @click="newQuery"><TerminalSquare class="w-4 h-4" /> {{ t("contextMenu.newQuery") }}</ContextMenuItem>diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.tsindex ee5450be3d..7758746b0a 100644--- a/src/i18n/locales/en.ts+++ b/src/i18n/locales/en.ts@@ -181,10 +181,12 @@ export default {tableData: "Table Data",redis: "Redis",mongo: "Mongo",+ objects: "Objects",tooltipConnection: "Connection:",tooltipDatabase: "Database:",tooltipTable: "Table:",tooltipCollection: "Collection:",+ tooltipSchema: "Schema:",resultN: "Result {n}",scrollLeft: "Scroll tabs left",scrollRight: "Scroll tabs right",@@ -480,6 +482,7 @@ export default {editConnection: "Edit Connection",duplicateConnection: "Duplicate Connection",newQuery: "New Query",+ openObjectBrowser: "Browse Objects",viewData: "View Data",editStructure: "Edit Structure",refreshChildren: "Refresh",@@ -540,6 +543,23 @@ export default {indexes: "Indexes",foreignKeys: "Foreign Keys",triggers: "Triggers",+ objectBrowser: "Browse in Object Browser ({count})",+ },+ objects: {+ all: "All",+ tables: "Tables",+ views: "Views",+ table: "Table",+ view: "View",+ name: "Name",+ type: "Type",+ schemaColumn: "Schema",+ comment: "Comment",+ loadingSchemas: "Loading schemas...",+ schema: "Schema",+ search: "Search tables or views...",+ loading: "Loading objects...",+ empty: "No objects found",},structureEditor: {title: "Edit Table Structure",diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.tsindex ee65f993ad..5afa54fe93 100644--- a/src/i18n/locales/zh-CN.ts+++ b/src/i18n/locales/zh-CN.ts@@ -180,10 +180,12 @@ export default {tableData: "数据表",redis: "Redis",mongo: "Mongo",+ objects: "对象",tooltipConnection: "连接:",tooltipDatabase: "数据库:",tooltipTable: "表:",tooltipCollection: "集合:",+ tooltipSchema: "Schema:",resultN: "结果 {n}",scrollLeft: "向左滚动标签页",scrollRight: "向右滚动标签页",@@ -472,6 +474,7 @@ export default {editConnection: "编辑连接",duplicateConnection: "复制连接",newQuery: "新建查询",+ openObjectBrowser: "浏览对象",viewData: "查看数据",editStructure: "编辑表结构",refreshChildren: "刷新",@@ -529,6 +532,23 @@ export default {indexes: "索引",foreignKeys: "外键",triggers: "触发器",+ objectBrowser: "在对象浏览器中查看 ({count})",+ },+ objects: {+ all: "全部",+ tables: "表",+ views: "视图",+ table: "表",+ view: "视图",+ name: "名称",+ type: "类型",+ schemaColumn: "Schema",+ comment: "注释",+ loadingSchemas: "加载 Schema...",+ schema: "Schema",+ search: "搜索表或视图...",+ loading: "正在加载对象...",+ empty: "没有找到对象",},structureEditor: {title: "编辑表结构",diff --git a/src/lib/openTabsPersistence.ts b/src/lib/openTabsPersistence.tsindex 240d9258ee..258d682cdd 100644--- a/src/lib/openTabsPersistence.ts+++ b/src/lib/openTabsPersistence.ts@@ -10,6 +10,7 @@ export interface SavedOpenTab {savedSqlId?: string;pinned?: boolean;mode?: QueryTab["mode"];+ objectBrowser?: QueryTab["objectBrowser"];tableMeta?: QueryTab["tableMeta"];}@@ -29,6 +30,7 @@ export function serializeOpenTabs(tabs: QueryTab[]): SavedOpenTab[] {savedSqlId: tab.savedSqlId,pinned: tab.pinned,mode: tab.mode,+ objectBrowser: tab.objectBrowser,tableMeta: tab.tableMeta,}));}diff --git a/src/lib/tabPresentation.ts b/src/lib/tabPresentation.tsindex d2ee4d056e..771f9ee03e 100644--- a/src/lib/tabPresentation.ts+++ b/src/lib/tabPresentation.ts@@ -42,6 +42,10 @@ export function tabDisplayTitle(tab: QueryTab): string {if (tab.mode === "redis") {return `${connectionDisplayName(tab.connectionId)}@${database}`;}+ if (tab.mode === "objects") {+ const schema = tab.objectBrowser?.schema;+ return schema ? `${schema}@${database}` : `${tab.title}@${database}`;+ }return tab.title;}@@ -59,6 +63,9 @@ export function tabTooltipLines(tab: QueryTab): { label: string; value: string }if (tab.mode === "mongo" && tab.sql) {lines.push({ label: t("tabs.tooltipCollection"), value: tab.sql });}+ if (tab.mode === "objects" && tab.objectBrowser?.schema) {+ lines.push({ label: t("tabs.tooltipSchema"), value: tab.objectBrowser.schema });+ }return lines;}@@ -68,5 +75,6 @@ export function tabModeLabel(tab: QueryTab): string {if (tab.mode === "query") return t("tabs.sql");if (tab.mode === "mongo") return t("tabs.mongo");if (tab.mode === "redis") return t("tabs.redis");+ if (tab.mode === "objects") return t("tabs.objects");return tab.mode;}diff --git a/src/stores/connectionStore.ts b/src/stores/connectionStore.tsindex f02837ea80..a4969abd12 100644--- a/src/stores/connectionStore.ts+++ b/src/stores/connectionStore.ts@@ -26,6 +26,7 @@ import { buildSqlServerDatabaseTreeNodes, SQLSERVER_DEFAULT_SCHEMA } from "@/libimport { useSavedSqlStore } from "@/stores/savedSqlStore";const PINNED_TREE_NODES_STORAGE_KEY = "dbx-pinned-tree-nodes";+const SIDEBAR_TABLE_NODE_LIMIT = 15;interface LoadTreeOptions {force?: boolean;@@ -291,6 +292,24 @@ export const useConnectionStore = defineStore("connection", () => {await api.saveSchemaCache(cacheKey, children).catch(() => undefined);}+ function buildObjectBrowserNode(+ nodeId: string,+ connectionId: string,+ database: string,+ schema: string | undefined,+ objectCount: number,+ ): TreeNode {+ return {+ id: `${nodeId}:__object_browser`,+ label: "tree.objectBrowser",+ type: "object-browser",+ connectionId,+ database,+ schema,+ objectCount,+ };+ }+function useCachedChildren(node: TreeNode, options?: LoadTreeOptions): boolean {if (options?.force || !loadedTreeNodeChildrenIds.value.has(node.id)) return false;node.isExpanded = true;@@ -637,7 +656,26 @@ export const useConnectionStore = defineStore("connection", () => {api.listSchemas(connectionId, database),api.listTables(connectionId, database, SQLSERVER_DEFAULT_SCHEMA),]);- const children = buildSqlServerDatabaseTreeNodes(connectionId, database, schemas, defaultSchemaTables);+ let children = buildSqlServerDatabaseTreeNodes(connectionId, database, schemas, defaultSchemaTables);+ if (defaultSchemaTables.length > SIDEBAR_TABLE_NODE_LIMIT) {+ const previewTables = buildSqlServerDatabaseTreeNodes(+ connectionId,+ database,+ [],+ defaultSchemaTables.slice(0, SIDEBAR_TABLE_NODE_LIMIT),+ );+ children = [+ ...previewTables,+ buildObjectBrowserNode(+ `${nodeId}:${SQLSERVER_DEFAULT_SCHEMA}`,+ connectionId,+ database,+ SQLSERVER_DEFAULT_SCHEMA,+ defaultSchemaTables.length,+ ),+ ...children.filter((child) => child.type === "schema"),+ ];+ }setChildren(node, children);await savePersistedTreeChildren(cacheKey, children);node.isExpanded = true;@@ -661,7 +699,8 @@ export const useConnectionStore = defineStore("connection", () => {const tables = await api.listTables(connectionId, database, querySchema);const config = getConfig(connectionId);const effectiveSchema = schema || (config?.db_type && isSchemaAware(config.db_type) ? database : undefined);- const children = tables.map((t) => ({+ const visibleTables = tables.slice(0, SIDEBAR_TABLE_NODE_LIMIT);+ const children: TreeNode[] = visibleTables.map((t) => ({id: `${nodeId}:${t.name}`,label: t.name,type: (t.table_type === "VIEW" ? "view" : "table") as "view" | "table",@@ -671,6 +710,9 @@ export const useConnectionStore = defineStore("connection", () => {isExpanded: false,children: [],}));+ if (tables.length > SIDEBAR_TABLE_NODE_LIMIT) {+ children.push(buildObjectBrowserNode(nodeId, connectionId, database, effectiveSchema, tables.length));+ }setChildren(node, children);await savePersistedTreeChildren(cacheKey, children);node.isExpanded = true;diff --git a/src/stores/queryStore.ts b/src/stores/queryStore.tsindex 685419f8c4..84f05e9dad 100644--- a/src/stores/queryStore.ts+++ b/src/stores/queryStore.ts@@ -45,12 +45,7 @@ export const useQueryStore = defineStore("query", () => {return tabs.value.find((t) => t.connectionId === connectionId && t.database === database && t.title === title);}- function createTab(- connectionId: string,- database: string,- title?: string,- mode: "data" | "query" | "redis" | "mongo" = "query",- ) {+ function createTab(connectionId: string, database: string, title?: string, mode: QueryTab["mode"] = "query") {if (title) {const existing = findTabByTitle(connectionId, database, title);if (existing) {@@ -76,6 +71,42 @@ export const useQueryStore = defineStore("query", () => {return id;}+ function openObjectBrowser(connectionId: string, database: string, schema?: string) {+ const title = schema ? `${schema} objects` : `${database} objects`;+ const existing = tabs.value.find(+ (tab) =>+ tab.mode === "objects" &&+ tab.connectionId === connectionId &&+ tab.database === database &&+ (tab.objectBrowser?.schema || "") === (schema || ""),+ );+ if (existing) {+ activeTabId.value = existing.id;+ return existing.id;+ }++ const id = uuid();+ const tab: QueryTab = {+ id,+ title,+ connectionId,+ database,+ schema,+ sql: "",+ isExecuting: false,+ isCancelling: false,+ isExplaining: false,+ mode: "objects",+ objectBrowser: {+ schema,+ objectType: "tables",+ },+ };+ tabs.value.push(tab);+ activeTabId.value = id;+ return id;+ }+function closeTab(id: string) {const idx = tabs.value.findIndex((t) => t.id === id);if (idx < 0) return;@@ -157,6 +188,7 @@ export const useQueryStore = defineStore("query", () => {if (!tab || tab.database === database) return;tab.database = database;tab.schema = undefined;+ tab.objectBrowser = undefined;tab.result = undefined;tab.lastExecutedSql = undefined;tab.resultBaseSql = undefined;@@ -169,6 +201,7 @@ export const useQueryStore = defineStore("query", () => {const tab = tabs.value.find((t) => t.id === id);if (!tab || tab.schema === schema) return;tab.schema = schema;+ if (tab.mode === "objects") tab.objectBrowser = { ...tab.objectBrowser, schema };}function updateConnection(id: string, connectionId: string, database = "") {@@ -460,6 +493,7 @@ export const useQueryStore = defineStore("query", () => {closeOtherTabs,closeAllTabs,updateSql,+ openObjectBrowser,linkSavedSql,openSavedSql,togglePinnedTab,diff --git a/src/types/database.ts b/src/types/database.tsindex a90314dff7..fff39447d0 100644--- a/src/types/database.ts+++ b/src/types/database.ts@@ -88,6 +88,7 @@ export interface DatabaseInfo {export interface TableInfo {name: string;table_type: string;+ comment?: string | null;}export interface ColumnInfo {@@ -146,6 +147,7 @@ export type TreeNodeType =| "group-indexes"| "group-fkeys"| "group-triggers"+ | "object-browser"| "saved-sql-root"| "saved-sql-folder"| "saved-sql-file"@@ -184,6 +186,7 @@ export interface TreeNode {database?: string;schema?: string;tableName?: string;+ objectCount?: number;savedSqlId?: string;savedSqlFolderId?: string;meta?: ColumnInfo | IndexInfo | ForeignKeyInfo | TriggerInfo;@@ -213,7 +216,11 @@ export interface QueryTab {executionId?: string;isExplaining?: boolean;explainExecutionId?: string;- mode: "data" | "query" | "redis" | "mongo";+ mode: "data" | "query" | "redis" | "mongo" | "objects";+ objectBrowser?: {+ schema?: string;+ objectType?: "tables";+ };tableMeta?: {schema?: string;tableName: string;