@@ -37,6 +37,20 @@ const selectedComponentTreeNode = computed<ComponentTreeNode>(() => {
3737 find (treeNode .value )
3838 return res [0 ]
3939})
40+
41+ const treeNodeIdLinkedList = computed <string [][]>(() => {
42+ const res: string [][] = []
43+ const find = (treeNode : ComponentTreeNode [], linkedList : string [] = []) => {
44+ treeNode .forEach ((item ) => {
45+ res .push ([... linkedList , item .id ])
46+ if (item .children ?.length )
47+ find (item .children , [... linkedList , item .id ])
48+ })
49+ }
50+ find (treeNode .value )
51+ return res
52+ })
53+
4054// selected component file path
4155const selectedComponentFilePath = computed (() => selectedComponentTreeNode .value ?.file ?? ' ' )
4256
@@ -127,9 +141,22 @@ function inspectComponentInspector() {
127141 selectedComponentTree .value = data .id
128142 selectComponentTree (data .id )
129143 const linkedList = componentTreeLinkedList .value [data .id ]
130- linkedList .forEach ((id ) => {
131- componentTreeCollapseMap .value [id ] = true
132- })
144+ if (linkedList ) {
145+ linkedList .forEach ((id ) => {
146+ componentTreeCollapseMap .value [id ] = true
147+ })
148+ }
149+ else {
150+ treeNodeIdLinkedList .value .forEach ((item ) => {
151+ let index = item .indexOf (data .id )
152+ if (index > - 1 ) {
153+ while (index >= 0 ) {
154+ componentTreeCollapseMap .value [item [index ]] = true
155+ index --
156+ }
157+ }
158+ })
159+ }
133160 }).finally (() => {
134161 bridge .value .emit (' toggle-panel' , true )
135162 })
0 commit comments