From a6f3425ac964f3b7f69fa8fffb6344253ba57f3a Mon Sep 17 00:00:00 2001 From: nightwhite Date: Thu, 5 Dec 2024 00:54:16 +0800 Subject: [PATCH 1/4] fix: Fixed the list display bug caused by more than 200 cloud functions --- .../functions/mods/FunctionPanel/index.tsx | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/web/src/pages/app/functions/mods/FunctionPanel/index.tsx b/web/src/pages/app/functions/mods/FunctionPanel/index.tsx index 4fb05e11e5..c2d2446c41 100644 --- a/web/src/pages/app/functions/mods/FunctionPanel/index.tsx +++ b/web/src/pages/app/functions/mods/FunctionPanel/index.tsx @@ -128,30 +128,31 @@ export default function FunctionList() { const nameParts = item.name.split("/"); let currentNode = root; nameParts.forEach((_, index) => { - if (currentNode.children.find((node) => node.name === item.name)) { - const index = currentNode.children.findIndex((node) => node.name === item.name); - currentNode.children[index] = item; - return; - } else if (index === nameParts.length - 1) { - currentNode.children.push(item); - return; + const isFinalPart = index === nameParts.length - 1; + const existingItemIndex = currentNode.children.findIndex((node) => node.name === item.name); + if (existingItemIndex !== -1) { + currentNode.children[existingItemIndex] = item; + return; + } else if (isFinalPart) { + // 如果是最后一部分,直接添加项 + currentNode.children.push(item); + return; } const name = nameParts.slice(0, index + 1).join("/"); let existingNode = currentNode.children.find( - (node) => node.name === name && node.level === index, + (node) => node.name === name && node.level === index, ); + if (!existingNode) { - // dir - const newNode = { - _id: item._id, - name, - level: index, - isExpanded: false, - children: [], - }; - currentNode.children.push(newNode); - existingNode = newNode; + existingNode = { + _id: item._id, + name, + level: index, + isExpanded: false, + children: [], + }; + currentNode.children.push(existingNode); } currentNode = existingNode; }); @@ -160,7 +161,7 @@ export default function FunctionList() { return root; }, [functionRoot], - ); +); const filterFunctions = useMemo(() => { const res = generateRoot( @@ -669,9 +670,9 @@ export default function FunctionList() { title={
{t`FunctionPanel.FunctionList`} - {filterFunctions.length ? ( + {allFunctionList.length ? ( - {filterFunctions.length} + {allFunctionList.length} ) : null}
From a685cb5993c4597a748609408ce6985ffe99f42b Mon Sep 17 00:00:00 2001 From: nightwhite Date: Thu, 5 Dec 2024 00:55:24 +0800 Subject: [PATCH 2/4] 1 --- web/src/pages/app/functions/mods/FunctionPanel/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/web/src/pages/app/functions/mods/FunctionPanel/index.tsx b/web/src/pages/app/functions/mods/FunctionPanel/index.tsx index c2d2446c41..7b798f209e 100644 --- a/web/src/pages/app/functions/mods/FunctionPanel/index.tsx +++ b/web/src/pages/app/functions/mods/FunctionPanel/index.tsx @@ -134,7 +134,6 @@ export default function FunctionList() { currentNode.children[existingItemIndex] = item; return; } else if (isFinalPart) { - // 如果是最后一部分,直接添加项 currentNode.children.push(item); return; } From 4d3998b2966f29a413dba121a014bdf77a324652 Mon Sep 17 00:00:00 2001 From: nightwhite Date: Thu, 5 Dec 2024 00:55:53 +0800 Subject: [PATCH 3/4] 2 --- .../app/functions/mods/FunctionPanel/index.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/web/src/pages/app/functions/mods/FunctionPanel/index.tsx b/web/src/pages/app/functions/mods/FunctionPanel/index.tsx index 7b798f209e..f005ea7247 100644 --- a/web/src/pages/app/functions/mods/FunctionPanel/index.tsx +++ b/web/src/pages/app/functions/mods/FunctionPanel/index.tsx @@ -137,21 +137,19 @@ export default function FunctionList() { currentNode.children.push(item); return; } - const name = nameParts.slice(0, index + 1).join("/"); let existingNode = currentNode.children.find( (node) => node.name === name && node.level === index, ); - if (!existingNode) { - existingNode = { - _id: item._id, - name, - level: index, - isExpanded: false, - children: [], - }; - currentNode.children.push(existingNode); + existingNode = { + _id: item._id, + name, + level: index, + isExpanded: false, + children: [], + }; + currentNode.children.push(existingNode); } currentNode = existingNode; }); From b53b1a90faf662630fd0837f2f9d286359d21d26 Mon Sep 17 00:00:00 2001 From: nightwhite Date: Thu, 5 Dec 2024 00:56:15 +0800 Subject: [PATCH 4/4] 4 --- .../pages/app/functions/mods/FunctionPanel/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/src/pages/app/functions/mods/FunctionPanel/index.tsx b/web/src/pages/app/functions/mods/FunctionPanel/index.tsx index f005ea7247..b674f6993b 100644 --- a/web/src/pages/app/functions/mods/FunctionPanel/index.tsx +++ b/web/src/pages/app/functions/mods/FunctionPanel/index.tsx @@ -143,11 +143,11 @@ export default function FunctionList() { ); if (!existingNode) { existingNode = { - _id: item._id, - name, - level: index, - isExpanded: false, - children: [], + _id: item._id, + name, + level: index, + isExpanded: false, + children: [], }; currentNode.children.push(existingNode); }