@@ -37,6 +37,20 @@ const selectedComponentTreeNode = computed<ComponentTreeNode>(() => {
37
37
find (treeNode .value )
38
38
return res [0 ]
39
39
})
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
+
40
54
// selected component file path
41
55
const selectedComponentFilePath = computed (() => selectedComponentTreeNode .value ?.file ?? ' ' )
42
56
@@ -127,9 +141,22 @@ function inspectComponentInspector() {
127
141
selectedComponentTree .value = data .id
128
142
selectComponentTree (data .id )
129
143
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
+ }
133
160
}).finally (() => {
134
161
bridge .value .emit (' toggle-panel' , true )
135
162
})
0 commit comments