UNPKG

@fesjs/fes-design

Version:
27 lines (24 loc) 616 B
import { getCurrentInstance, inject, computed, provide } from 'vue'; import { MENU_KEY } from './const'; var useMenu = instance => { instance = instance !== null && instance !== void 0 ? instance : getCurrentInstance(); const node = { name: instance.type.name, uid: instance.props.value || instance.uid }; const { parentPath } = inject(MENU_KEY, { parentPath: computed(() => []) }); const indexPath = computed(() => { return parentPath.value.concat(node); }); provide(MENU_KEY, { parentPath: indexPath }); return { indexPath }; }; export { useMenu as default };