Skip to content

Commit

Permalink
feat(vue2): store inspector edit, fix #1683
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Feb 8, 2022
1 parent 275d147 commit daee884
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/app-backend-vue2/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ export function setupPlugin (api: DevtoolsApi, app: App, Vue) {
}
})

api.on.editInspectorState((payload) => {
if (payload.inspectorId === VUEX_INSPECTOR_ID) {
let path = payload.path
if (payload.nodeId !== 'root') {
path = [
...payload.nodeId.substring(0, payload.nodeId.length - 1).split('/'),
...path,
]
}
store._committing = true
payload.set(store._vm.$data.$$state, path)
store._committing = false
}
})

api.addTimelineLayer({
id: VUEX_MUTATIONS_ID,
label: 'Vuex Mutations',
Expand Down
2 changes: 2 additions & 0 deletions packages/shell-dev-vue2/src/Counter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@

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

<pre>{{ $store.state.nested.nestedNested }}</pre>

<NoProp />
</div>
</template>
Expand Down
9 changes: 9 additions & 0 deletions packages/shell-dev-vue2/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ export default new Vuex.Store({
state.foo = state.foo.substring('bar'.length)
},
},
modules: {
nestedNested: {
state () {
return {
answer: 42,
}
},
},
},
},
notNamespaced: {
state () {
Expand Down

0 comments on commit daee884

Please sign in to comment.