diff --git a/packages/app-backend-vue2/src/plugin.ts b/packages/app-backend-vue2/src/plugin.ts index 9a9b3bf05..ade044fa0 100644 --- a/packages/app-backend-vue2/src/plugin.ts +++ b/packages/app-backend-vue2/src/plugin.ts @@ -116,7 +116,7 @@ export function setupPlugin (api: DevtoolsApi, app: App, Vue) { api.on.getInspectorState((payload) => { if (payload.inspectorId === VUEX_INSPECTOR_ID) { const modulePath = payload.nodeId - const module = getStoreModule(store._modules, modulePath) + const { module, getterPath } = getStoreModule(store._modules, modulePath) if (!module) { return } @@ -126,7 +126,7 @@ export function setupPlugin (api: DevtoolsApi, app: App, Vue) { payload.state = formatStoreForInspectorState( module, store._makeLocalGettersCache, - modulePath, + getterPath, ) } }) @@ -498,12 +498,20 @@ function transformPathsToObjectTree (getters) { function getStoreModule (moduleMap, path) { const names = path.split(VUEX_MODULE_PATH_SEPARATOR).filter((n) => n) return names.reduce( - (module, moduleName, i) => { - const child = module ? module[moduleName === VUEX_ROOT_PATH ? 'root' : moduleName] : null + ({ module, getterPath }, moduleName, i) => { + const child = module[moduleName === VUEX_ROOT_PATH ? 'root' : moduleName] if (!child) return null - return i === names.length - 1 ? child : child._children + return { + module: i === names.length - 1 ? child : child._children, + getterPath: child._rawModule.namespaced + ? getterPath + : getterPath.replace(`${moduleName}${VUEX_MODULE_PATH_SEPARATOR}`, ''), + } + }, + { + module: path === VUEX_ROOT_PATH ? moduleMap : moduleMap.root._children, + getterPath: path, }, - path === VUEX_ROOT_PATH ? moduleMap : moduleMap.root._children, ) }