Skip to content

Commit daee884

Browse files
committed
feat(vue2): store inspector edit, fix #1683
1 parent 275d147 commit daee884

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

packages/app-backend-vue2/src/plugin.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ export function setupPlugin (api: DevtoolsApi, app: App, Vue) {
116116
}
117117
})
118118

119+
api.on.editInspectorState((payload) => {
120+
if (payload.inspectorId === VUEX_INSPECTOR_ID) {
121+
let path = payload.path
122+
if (payload.nodeId !== 'root') {
123+
path = [
124+
...payload.nodeId.substring(0, payload.nodeId.length - 1).split('/'),
125+
...path,
126+
]
127+
}
128+
store._committing = true
129+
payload.set(store._vm.$data.$$state, path)
130+
store._committing = false
131+
}
132+
})
133+
119134
api.addTimelineLayer({
120135
id: VUEX_MUTATIONS_ID,
121136
label: 'Vuex Mutations',

packages/shell-dev-vue2/src/Counter.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117

118118
<pre>{{ $store.state.deeplyNested }}</pre>
119119

120+
<pre>{{ $store.state.nested.nestedNested }}</pre>
121+
120122
<NoProp />
121123
</div>
122124
</template>

packages/shell-dev-vue2/src/store.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ export default new Vuex.Store({
8181
state.foo = state.foo.substring('bar'.length)
8282
},
8383
},
84+
modules: {
85+
nestedNested: {
86+
state () {
87+
return {
88+
answer: 42,
89+
}
90+
},
91+
},
92+
},
8493
},
8594
notNamespaced: {
8695
state () {

0 commit comments

Comments
 (0)