@fesjs/fes-design
Version:
fes-design for PC
27 lines (24 loc) • 616 B
JavaScript
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 };