@@ -3,7 +3,8 @@ import { computed, onUnmounted, ref, watch } from 'vue'
3
3
import { Pane , Splitpanes } from ' splitpanes'
4
4
import { DevToolsMessagingEvents , rpc } from ' @vue/devtools-core'
5
5
import { parse } from ' @vue/devtools-kit'
6
- import type { CustomInspectorNode , CustomInspectorState } from ' @vue/devtools-kit'
6
+ import type { CustomInspectorNode , CustomInspectorOptions , CustomInspectorState } from ' @vue/devtools-kit'
7
+ import { vTooltip } from ' @vue/devtools-ui'
7
8
import Navbar from ' ~/components/basic/Navbar.vue'
8
9
import DevToolsHeader from ' ~/components/basic/DevToolsHeader.vue'
9
10
import Empty from ' ~/components/basic/Empty.vue'
@@ -16,6 +17,8 @@ const { expanded: expandedTreeNodes } = createExpandedContext()
16
17
const { expanded : expandedStateNodes } = createExpandedContext (' pinia-store-state' )
17
18
18
19
const inspectorId = ' pinia'
20
+ const nodeActions = ref <CustomInspectorOptions [' nodeActions' ]>([])
21
+ const actions = ref <CustomInspectorOptions [' nodeActions' ]>([])
19
22
20
23
const selected = ref (' ' )
21
24
const tree = ref <CustomInspectorNode []>([])
@@ -63,6 +66,30 @@ function flattenTreeNodes(tree: CustomInspectorNode[]) {
63
66
return res
64
67
}
65
68
69
+ function getNodeActions() {
70
+ rpc .value .getInspectorNodeActions (inspectorId ).then ((actions ) => {
71
+ nodeActions .value = actions
72
+ })
73
+ }
74
+
75
+ function getActions() {
76
+ rpc .value .getInspectorActions (inspectorId ).then ((_actions ) => {
77
+ actions .value = _actions
78
+ })
79
+ }
80
+
81
+ getNodeActions ()
82
+
83
+ getActions ()
84
+
85
+ function callNodeAction(index : number ) {
86
+ rpc .value .callInspectorNodeAction (inspectorId , index , selected .value )
87
+ }
88
+
89
+ function callAction(index : number ) {
90
+ rpc .value .callInspectorAction (inspectorId , index )
91
+ }
92
+
66
93
function filterEmptyState(data : Record <string , unknown [] | undefined >) {
67
94
for (const key in data ) {
68
95
if (! data [key ]?.length )
@@ -156,12 +183,28 @@ onUnmounted(() => {
156
183
</DevToolsHeader >
157
184
<Splitpanes class =" flex-1 overflow-auto" >
158
185
<Pane border =" r base" size =" 40" h-full >
159
- <div h-full select-none overflow-scroll p2 class =" no-scrollbar" >
160
- <ComponentTree v-model =" selected" :data =" tree" />
186
+ <div class =" h-full flex flex-col p2" >
187
+ <div v-if =" actions?.length" class =" mb-1 flex justify-end pb-1" border =" b dashed base" >
188
+ <div class =" flex items-center gap-2 px-1" >
189
+ <div v-for =" (action, index) in actions" :key =" index" v-tooltip.bottom-end =" { content: action.tooltip }" class =" flex items-center gap1" @click =" callAction(index)" >
190
+ <i :class =" `i-ic-baseline-${action.icon.replace(/\_/g, '-')}`" cursor-pointer op70 text-base hover:op100 />
191
+ </div >
192
+ </div >
193
+ </div >
194
+ <div class =" no-scrollbar flex-1 select-none overflow-scroll" >
195
+ <ComponentTree v-model =" selected" :data =" tree" />
196
+ </div >
161
197
</div >
162
198
</Pane >
163
199
<Pane size =" 60" >
164
- <div h-full select-none overflow-scroll class =" no-scrollbar" >
200
+ <div class =" h-full flex flex-col p2" >
201
+ <div v-if =" nodeActions?.length" class =" mb-1 flex justify-end pb-1" border =" b dashed base" >
202
+ <div class =" flex items-center gap-2 px-1" >
203
+ <div v-for =" (action, index) in nodeActions" :key =" index" v-tooltip.bottom-end =" { content: action.tooltip }" class =" flex items-center gap1" @click =" callNodeAction(index)" >
204
+ <i :class =" `i-ic-baseline-${action.icon.replace(/\_/g, '-')}`" cursor-pointer op70 text-base hover:op100 />
205
+ </div >
206
+ </div >
207
+ </div >
165
208
<RootStateViewer v-if =" selected && !emptyState" class =" p3" :data =" state" :node-id =" selected" :inspector-id =" inspectorId" expanded-state-id =" pinia-store-state" />
166
209
<Empty v-else >
167
210
No Data
0 commit comments