From 7afd3ae2e51109b2642ac026671fcd5e805930aa Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Fri, 29 Mar 2024 11:23:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=95=B0=E6=8E=92=E5=BA=8F=E8=A7=84=E5=88=99?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=BC=93=E5=AD=98=E5=88=B0=E6=9C=AC=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/src/utils/treeSortUtils.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/core-frontend/src/utils/treeSortUtils.ts b/core/core-frontend/src/utils/treeSortUtils.ts index ec951e1880..5f72db52f3 100644 --- a/core/core-frontend/src/utils/treeSortUtils.ts +++ b/core/core-frontend/src/utils/treeSortUtils.ts @@ -3,13 +3,18 @@ import _ from 'lodash' export default function treeSort(tree: BusiTreeNode[], sortType: string) { const result = _.cloneDeep(tree) - sortPer(result, sortType) - _.forEach(result, node => { + sortCircle(result, sortType) + return result +} + +export function sortCircle(tree: BusiTreeNode[], sortType: string) { + sortPer(tree, sortType) + _.forEach(tree, node => { if (node.children && node.children.length > 0) { - sortPer(node.children, sortType) + sortCircle(node.children, sortType) } }) - return result + return tree } export const sortPer = (subTree: BusiTreeNode[], sortType: string) => {