提交 edbbc537 编写于 作者: G Guillaume Chau

feat(vuex): special state inspector section for dynamic module "mutations"

上级 e248e305
......@@ -61,6 +61,8 @@ const keyOrder = {
props: 1,
undefined: 3,
computed: 4,
'register module': 1,
'unregister module': 1,
state: 2,
getters: 3,
mutation: 1,
......
......@@ -135,22 +135,39 @@ export default {
...mapGetters('vuex', [
'inspectedState',
'filteredHistory'
'filteredHistory',
'inspectedEntry'
]),
filteredState () {
const getProcessedState = (state, type) => {
if (!Array.isArray(state)) {
return Object.keys(state).map(key => ({
key,
editable: type === 'state',
value: state[key]
}))
} else {
return state
}
}
const inspectedState = [].concat(
...Object.keys(this.inspectedState).map(
type => {
const state = this.inspectedState[type]
let processedState
if (!Array.isArray(this.inspectedState[type])) {
processedState = Object.keys(this.inspectedState[type]).map(key => ({
key,
editable: type === 'state',
value: this.inspectedState[type][key]
}))
} else {
processedState = this.inspectedState[type]
if (type === 'mutation' && this.inspectedEntry) {
const { options } = this.inspectedEntry
if (options.registerModule || options.unregisterModule) {
processedState = getProcessedState(state.payload, type)
type = options.registerModule ? 'register module' : 'unregister module'
}
}
if (!processedState) {
processedState = getProcessedState(state, type)
}
return processedState.map(
......
......@@ -155,6 +155,10 @@ const getters = {
return history.indexOf(entry)
}
return -1
},
inspectedEntry ({ inspectedIndex }, { filteredHistory }) {
return filteredHistory[inspectedIndex]
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册