This repository was archived by the owner on Jan 6, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -61,23 +61,36 @@ const normalizedComponentState = computed(() => {
61
61
return list
62
62
})
63
63
64
+ function findComponentNode(treeNode : any [], uid : number ) {
65
+ for (const node of treeNode ) {
66
+ if (node .uid === uid ) {
67
+ return node
68
+ }
69
+ else if (node .children ) {
70
+ const findNode = findComponentNode (node .children , uid )
71
+ if (findNode )
72
+ return findNode
73
+ }
74
+ }
75
+ return undefined
76
+ }
77
+
64
78
function init() {
65
79
componentWalker .value = new ComponentWalker (500 , null , true )
66
- selectedComponent .value = instance .value
67
- selectedComponentState .value = getInstanceState (instance .value ! )
68
80
componentWalker .value .getComponentTree (instance .value ! ).then ((res ) => {
81
+ const currentNode = findComponentNode (res , selectedComponentNode .value ?.uid || 0 ) || res [0 ]
69
82
componentTree .value = res
70
- selectedComponentName .value = res ?.[0 ]?.name ?? ' '
71
- selectedComponentNode .value = res ?.[0 ]
83
+ selected .value = currentNode .id
84
+ selectedComponentName .value = currentNode .name
85
+ selectedComponentNode .value = currentNode
86
+ selectedComponentState .value = getInstanceState (currentNode .instance )
72
87
})
73
88
}
74
89
75
90
onMounted (() => {
76
91
onVueInstanceUpdate ((v ) => {
77
- if (v ) {
92
+ if (v )
78
93
init ()
79
- selected .value = ' vue-devtools:root'
80
- }
81
94
})
82
95
})
83
96
You can’t perform that action at this time.
0 commit comments