feat(sidebar): 添加展开全部功能并支持多语言

- 新增 loadAllObjectGroupChildren 函数以加载所有对象组子项
- 在侧边栏菜单中添加“展开全部”选项
- 更新多语言文件以支持“展开全部”文本
This commit is contained in:
二丫讲梵 2026-06-26 09:54:20 +08:00 committed by GitHub
parent 058bbf72cc
commit ad6e13dba8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 51 additions and 0 deletions

View File

@ -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"),

View File

@ -1172,6 +1172,7 @@ export default {
viewData: "View Data",
editStructure: "Edit Structure",
refreshChildren: "Refresh",
expandAll: "Expand All",
pin: "Pin",
unpin: "Unpin",
refreshTab: "Refresh Data",

View File

@ -990,6 +990,7 @@ export default {
viewData: "Ver datos",
editStructure: "Editar estructura",
refreshChildren: "Actualizar",
expandAll: "Expandir todo",
pin: "Fijar",
unpin: "Desfijar",
refreshTab: "Actualizar datos",

View File

@ -1097,6 +1097,7 @@ export default {
viewData: "Visualizza Dati",
editStructure: "Modifica Struttura",
refreshChildren: "Aggiorna",
expandAll: "Espandi tutto",
pin: "Fissa",
unpin: "Sblocca",
refreshTab: "Aggiorna Dati",

View File

@ -1151,6 +1151,7 @@ export default {
viewData: "データを表示",
editStructure: "構造を編集",
refreshChildren: "更新",
expandAll: "すべて展開",
pin: "ピン留め",
unpin: "ピン留め解除",
refreshTab: "データを更新",

View File

@ -1097,6 +1097,7 @@ export default {
viewData: "Ver Dados",
editStructure: "Editar Estrutura",
refreshChildren: "Atualizar",
expandAll: "Expandir tudo",
pin: "Fixar",
unpin: "Desafixar",
refreshTab: "Atualizar Dados",

View File

@ -1171,6 +1171,7 @@ export default {
viewData: "查看数据",
editStructure: "编辑表结构",
refreshChildren: "刷新",
expandAll: "展开全部",
pin: "置顶",
unpin: "取消置顶",
refreshTab: "刷新数据",

View File

@ -1077,6 +1077,7 @@ export default {
viewData: "檢視資料",
editStructure: "編輯資料表結構",
refreshChildren: "重新整理",
expandAll: "展開全部",
pin: "置頂",
unpin: "取消置頂",
refreshTab: "重新整理資料",

View File

@ -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,