From ad6e13dba8b8ff452729b92c6d0e7e8bee04ad2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E4=B8=AB=E8=AE=B2=E6=A2=B5?= Date: Fri, 26 Jun 2026 09:54:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(sidebar):=20=E6=B7=BB=E5=8A=A0=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E5=85=A8=E9=83=A8=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=A4=9A=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 loadAllObjectGroupChildren 函数以加载所有对象组子项 - 在侧边栏菜单中添加“展开全部”选项 - 更新多语言文件以支持“展开全部”文本 --- .../src/components/sidebar/TreeItem.vue | 18 +++++++++++++ apps/desktop/src/i18n/locales/en.ts | 1 + apps/desktop/src/i18n/locales/es.ts | 1 + apps/desktop/src/i18n/locales/it.ts | 1 + apps/desktop/src/i18n/locales/ja.ts | 1 + apps/desktop/src/i18n/locales/pt-BR.ts | 1 + apps/desktop/src/i18n/locales/zh-CN.ts | 1 + apps/desktop/src/i18n/locales/zh-TW.ts | 1 + apps/desktop/src/stores/connectionStore.ts | 26 +++++++++++++++++++ 9 files changed, 51 insertions(+) diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vue index a0e257894a..2b5a8aa049 100644 --- a/apps/desktop/src/components/sidebar/TreeItem.vue +++ b/apps/desktop/src/components/sidebar/TreeItem.vue @@ -10,6 +10,7 @@ import { Eye, ChevronRight, ChevronDown, + ChevronsDown, Loader2, FolderOpen, FolderClosed, @@ -599,6 +600,14 @@ async function loadMoreObjectGroupChildren() { } } +async function loadAllObjectGroupChildren() { + try { + await connectionStore.loadAllObjectGroupChildren(props.node); + } catch (e: any) { + toast(t("connection.connectFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000); + } +} + function visibleTreeNodes(): TreeNode[] { if (sidebarTreeContext) return sidebarTreeContext.getVisibleNodes(); return flattenTree(connectionStore.treeNodes).map((item) => item.node); @@ -3958,6 +3967,7 @@ function treeItemMenuItems(): ContextMenuItem[] { // 9. Group Labels (group-columns, group-tables, etc.) if (isGroupLabel(node)) { const hasGroupCreateAction = (node.type === "group-tables" && canCreateTable.value) || (node.type === "group-views" && !!node.connectionId && !!node.database); + const canLoadAllObjectGroup = node.type === "group-tables" || node.type === "group-views" || node.type === "group-materialized-views"; if (node.type === "group-tables" && canCreateTable.value) { items.push({ label: t("contextMenu.createTable"), action: createTable, icon: Plus }); } @@ -3967,6 +3977,14 @@ function treeItemMenuItems(): ContextMenuItem[] { if (hasGroupCreateAction) { items.push({ label: "", separator: true }); } + if (canLoadAllObjectGroup) { + items.push({ + label: t("contextMenu.expandAll"), + action: loadAllObjectGroupChildren, + icon: ChevronsDown, + disabled: node.isLoading, + }); + } if (node.type !== "group-partitions") { items.push({ label: t("contextMenu.refreshChildren"), diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts index 926c8fb5df..7a0f9f5f44 100644 --- a/apps/desktop/src/i18n/locales/en.ts +++ b/apps/desktop/src/i18n/locales/en.ts @@ -1172,6 +1172,7 @@ export default { viewData: "View Data", editStructure: "Edit Structure", refreshChildren: "Refresh", + expandAll: "Expand All", pin: "Pin", unpin: "Unpin", refreshTab: "Refresh Data", diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts index 3b03b43fd4..2185224dfc 100644 --- a/apps/desktop/src/i18n/locales/es.ts +++ b/apps/desktop/src/i18n/locales/es.ts @@ -990,6 +990,7 @@ export default { viewData: "Ver datos", editStructure: "Editar estructura", refreshChildren: "Actualizar", + expandAll: "Expandir todo", pin: "Fijar", unpin: "Desfijar", refreshTab: "Actualizar datos", diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts index 479a812cb4..787e34b66c 100644 --- a/apps/desktop/src/i18n/locales/it.ts +++ b/apps/desktop/src/i18n/locales/it.ts @@ -1097,6 +1097,7 @@ export default { viewData: "Visualizza Dati", editStructure: "Modifica Struttura", refreshChildren: "Aggiorna", + expandAll: "Espandi tutto", pin: "Fissa", unpin: "Sblocca", refreshTab: "Aggiorna Dati", diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts index 18e2d76aa2..e419172586 100644 --- a/apps/desktop/src/i18n/locales/ja.ts +++ b/apps/desktop/src/i18n/locales/ja.ts @@ -1151,6 +1151,7 @@ export default { viewData: "データを表示", editStructure: "構造を編集", refreshChildren: "更新", + expandAll: "すべて展開", pin: "ピン留め", unpin: "ピン留め解除", refreshTab: "データを更新", diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts index 46e9201627..0d1a6fbba6 100644 --- a/apps/desktop/src/i18n/locales/pt-BR.ts +++ b/apps/desktop/src/i18n/locales/pt-BR.ts @@ -1097,6 +1097,7 @@ export default { viewData: "Ver Dados", editStructure: "Editar Estrutura", refreshChildren: "Atualizar", + expandAll: "Expandir tudo", pin: "Fixar", unpin: "Desafixar", refreshTab: "Atualizar Dados", diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts index 7b662cac26..fcde49ee0b 100644 --- a/apps/desktop/src/i18n/locales/zh-CN.ts +++ b/apps/desktop/src/i18n/locales/zh-CN.ts @@ -1171,6 +1171,7 @@ export default { viewData: "查看数据", editStructure: "编辑表结构", refreshChildren: "刷新", + expandAll: "展开全部", pin: "置顶", unpin: "取消置顶", refreshTab: "刷新数据", diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts index cd83620852..5195985232 100644 --- a/apps/desktop/src/i18n/locales/zh-TW.ts +++ b/apps/desktop/src/i18n/locales/zh-TW.ts @@ -1077,6 +1077,7 @@ export default { viewData: "檢視資料", editStructure: "編輯資料表結構", refreshChildren: "重新整理", + expandAll: "展開全部", pin: "置頂", unpin: "取消置頂", refreshTab: "重新整理資料", diff --git a/apps/desktop/src/stores/connectionStore.ts b/apps/desktop/src/stores/connectionStore.ts index 5054cdb1ec..814c75eece 100644 --- a/apps/desktop/src/stores/connectionStore.ts +++ b/apps/desktop/src/stores/connectionStore.ts @@ -2028,6 +2028,31 @@ export const useConnectionStore = defineStore("connection", () => { } } + async function loadAllObjectGroupChildren(parent: TreeNode) { + if (!parent.connectionId || !hasTreeNodeDatabaseContext(parent)) return; + if (!objectTypesForGroupNode(parent.type)) return; + parent.isLoading = true; + try { + await ensureConnected(parent.connectionId); + if (!isTreeNodeChildrenLoaded(parent.id)) { + await loadObjectGroupChildren(parent); + } + + let loadMoreNode = parent.children?.find((child) => child.type === "load-more"); + while (loadMoreNode?.loadMore) { + loadMoreNode.isLoading = true; + await loadMoreObjectGroupChildren(loadMoreNode); + loadMoreNode = parent.children?.find((child) => child.type === "load-more"); + } + parent.isExpanded = true; + } catch (e) { + recordMetadataLoadError(parent.connectionId, e); + throw e; + } finally { + parent.isLoading = false; + } + } + function normalizedObjectTreeKind(type: string): DatabaseObjectTreeKind { return normalizeSidebarObjectKind(type); } @@ -3635,6 +3660,7 @@ export const useConnectionStore = defineStore("connection", () => { loadTables, loadObjectGroupChildren, loadMoreObjectGroupChildren, + loadAllObjectGroupChildren, loadTableGroups, loadColumns, loadIndexes,