From e6dac1ebda5e35bd57921b231364c0bb85211d65 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 29 Mar 2023 22:25:53 +0800 Subject: [PATCH] =?UTF-8?q?REVIEW=20=E4=BB=A3=E7=A0=81=E9=A2=84=E8=A7=88(P?= =?UTF-8?q?reviewCode)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/tree.ts | 10 ++-- src/views/infra/codegen/PreviewCode.vue | 74 +++++++++++++++++-------- src/views/infra/codegen/index.vue | 4 +- 3 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/utils/tree.ts b/src/utils/tree.ts index 8f1f92cc..20f97a38 100644 --- a/src/utils/tree.ts +++ b/src/utils/tree.ts @@ -276,7 +276,7 @@ export const handleTree = (data: any[], id?: string, parentId?: string, children export const handleTree2 = (data, id, parentId, children, rootId) => { id = id || 'id' parentId = parentId || 'parentId' - children = children || 'children' + // children = children || 'children' rootId = rootId || Math.min( @@ -285,16 +285,16 @@ export const handleTree2 = (data, id, parentId, children, rootId) => { }) ) || 0 - //对源数据深度克隆 + // 对源数据深度克隆 const cloneData = JSON.parse(JSON.stringify(data)) - //循环所有项 + // 循环所有项 const treeData = cloneData.filter((father) => { const branchArr = cloneData.filter((child) => { - //返回每一项的子级数组 + // 返回每一项的子级数组 return father[id] === child[parentId] }) branchArr.length > 0 ? (father.children = branchArr) : '' - //返回第一层 + // 返回第一层 return father[parentId] === rootId }) return treeData !== '' ? treeData : data diff --git a/src/views/infra/codegen/PreviewCode.vue b/src/views/infra/codegen/PreviewCode.vue index 82307d59..df521f5a 100644 --- a/src/views/infra/codegen/PreviewCode.vue +++ b/src/views/infra/codegen/PreviewCode.vue @@ -1,13 +1,20 @@